Hide App button from TaskBar when it goes to Systray icon

I’m trying to hide an App Button from the taskbar when I create a systray icon for it, but it keeps reappearing. Having to roll my own code to replace the FrameExtension template/class.

Anyone know why?

SysTrayAddTrayIcon                      Procedure()

    Code
    Loc:SysTrayIcon                   = 'pcWTApp_ico'

    Loc:TrayIcon.cbSize               = Size(Loc:TrayIcon)
    Loc:TrayIcon.hWnd                 = MF:Handle
    Loc:TrayIcon.uID                  = 1 ! The application-defined identifier of the taskbar icon. The Shell uses either (hWnd plus uID
    Loc:TrayIcon.uFlags               = 0 ! Flags that either indicate which of the other members of the structure contain valid data or provide additional information to the tooltip as to how it should display
    Loc:TrayIcon.uFlags              += ISEQ:NOTIFYICONDATAA:NIF_Message
    Loc:TrayIcon.uFlags              += ISEQ:NOTIFYICONDATAA:NIF_Icon
    Loc:TrayIcon.uFlags              += ISEQ:NOTIFYICONDATAA:NIF_Tip

    Loc:TrayIcon.uCallbackMessage     = UserEvent:SysTrayEvents ! An application-defined message identifier. The system uses this identifier to send notification messages to the window identified in hWnd.
    Loc:TrayIcon.hIcon                = ISWA_LoadImage( System{PROP:AppInstance}, Address(Loc:SysTrayIcon),1,16,16,0)
    Loc:TrayIcon.szTip                = 'pcWorkTime' ! A null-terminated string that specifies the text for a standard tooltip. It can have a maximum of 64 characters,

    ISWA_Shell_NotifyIconA( ISEQ:SysTray:NIM_ADD, Address(Loc:TrayIcon) )  ! Adds an icon to the SysTray

!    !ISWA_ShowWindow(MF:Handle, ISEQ:Window:SW_HIDE ) ! Hide the MainFrame
!    !ISWA_ShowWindow(MF:Handle, ISEQ:Window:SW_HIDE )
!    AppFrame{Prop:Hide} = True
!    AppFrame{PROP:Active} = False

The 4 commented out lines, hide the taskbar button, but it keeps reappearing. The MS docs state

This parameter is ignored the first time an application calls ShowWindow, if the program that launched the application provides a STARTUPINFO structure. Otherwise, the first time ShowWindow is called, the value should be the value obtained by the WinMain function in its nCmdShow parameter.

which is why ShowWindow() is listed twice.

TIA

Maybe not the prettiest solution, but it works.
You should remove the WS_EX_TOOLWINDOW style again when removing it from the tray.

      lError = Shell_NotifyIcon(NIM_ADD,ADDRESS(gNotifyIconData))
      ShowWindow(wTest{Prop:Handle},SW_HIDE)
      lStyle = GetWindowLong(wTest{PROP:Handle}, GWL_EXSTYLE)
      lStyle = BOR(lStyle, WS_EX_TOOLWINDOW)
      ret# = SetWindowLong(wTest{PROP:Handle}, GWL_EXSTYLE, lStyle)
      ShowWindow(wTest{Prop:Handle},SW_SHOW)

Hope it helps…

I had most of the code in place, as shown here : Using a small pop-up window for Find or similar - #9 by RchdR

The problem at the time was the mainframe window was also appearing, I’ve since fixed that now, but just trying to change the default Clarion triangle icon that appears on the taskbar button.

SYSTEM{PROP:ICON} doesn’t work?

Sadly no, but I’m investigating the windows classes at the moment.

And what about setting the icon in the window and disable the system buttons? Or trying to hide them?

It doesnt work once I remove the Owner. I need to do this, to get the window to appear on the taskbar as a button to its own standalone window.