Task Tray App Display

Discussions related to mouse, keyboard, fonts and Graphical User Interface
MattC
Posts: 114
Joined: Mon 16 Apr 2018, 06:17

Task Tray App Display

Post by MattC »

Hi.

I've got a program that sits on the desktop running all the time, and the app is displayed in the task tray. Is there a way to hide the task in the task band, but still have the program visible?

Matt
RichardRussell

Re: Task Tray App Display

Post by RichardRussell »

MattC wrote: Sun 21 Jul 2019, 20:56I've got a program that sits on the desktop running all the time, and the app is displayed in the task tray. Is there a way to hide the task in the task band, but still have the program visible?
I think removing the WS_EX_APPWINDOW extended style from your program's window should achieve this.
MattC
Posts: 114
Joined: Mon 16 Apr 2018, 06:17

Re: Task Tray App Display

Post by MattC »

Thanks Richard,

I have this code in the program and have added the two line containing the extended styles.

Code: Select all

      SYS "GetWindowLong", @hwnd%, GWL_STYLE TO ws%
      SYS "SetWindowLong", @hwnd%, GWL_STYLE, \
      \   ws% AND NOT WS_THICKFRAME AND NOT WS_MAXIMIZEBOX AND NOT WS_BORDER
      SYS "GetWindowLong", @hwnd%, GWL_EXSTYLE TO ws%
      SYS "SetWindowLong", @hwnd%, GWL_EXSTYLE, \
      \   ws% AND NOT WS_EX_APPWINDOW
      SYS "SetWindowPos", @hwnd%, HWND_TOPMOST, WinXpos%, WinYpos%, 300, 300, 0
However, the taskbar still displays the program. Maybe this isn't what you meant, but I couldn't see any other meaning.

Matt
RichardRussell

Re: Task Tray App Display

Post by RichardRussell »

MattC wrote: Tue 31 Mar 2020, 20:14 Maybe this isn't what you meant, but I couldn't see any other meaning.
Yes, it's what I meant, but I only got it from Google (as you could have), it's not something that I have any personal experience of. Searching Raymond Chen's blog (as close to 'from the horse's mouth' as you can get with Microsoft) he says this of the icon in the taskbar:
  • If the WS_EX_APPWINDOW extended style is set, then it will show (when visible).
  • If the window is a top-level unowned window, then it will show (when visible).
  • Otherwise it doesn’t show.
So it may be that the reason it is still showing is because your window is "top-level" and "unowned". In that case you would probably have to resort to making your 'main' window a child of a hidden window, if you think it's worth going to those lengths.
RichardRussell

Re: Task Tray App Display

Post by RichardRussell »

This may not be an acceptable solution in your application, but if you don't mind your main window having the WS_EX_TOOLWINDOW style (which has the effect of removing the maximize and minimize buttons in the title bar, and making the close button smaller) that will hide the taskbar icon:

Code: Select all

      GWL_EXSTYLE = -20
      SW_HIDE = 0
      SW_SHOW = 5
      WS_EX_APPWINDOW = &40000
      WS_EX_TOOLWINDOW = &80

      SYS "ShowWindow", @hwnd%, SW_HIDE
      SYS "GetWindowLong", @hwnd%, GWL_EXSTYLE TO ws%
      SYS "SetWindowLong", @hwnd%, GWL_EXSTYLE, ws% AND NOT WS_EX_APPWINDOW OR WS_EX_TOOLWINDOW
      SYS "ShowWindow", @hwnd%, SW_SHOW

      REPEAT : WAIT 2 : UNTIL FALSE
You can still minimize or maximize the window by right-clicking on the title bar (or typing Alt+Space) and selecting from the menu, but of course minimizing a window with no taskbar icon is not a great idea!
MattC
Posts: 114
Joined: Mon 16 Apr 2018, 06:17

Re: Task Tray App Display

Post by MattC »

Thanks Richard,

This is exactly what I needed. I had read the descriptions of the EX codes, but had missed the possibility of this one. It works a treat. It shows that sometimes you have to look outside the box. It also forced me into noticing several other mistakes I'd made in other areas of the code that were transparent without this.

Matt