0
votes

I have an application created with LabVIEW and I need to show/hide the application icon on the Windows taskbar at run time. I think that WINAPI can be used for this purpose and I tried to use the ShowWindow function (user32.dll)

ShowWindow(hWnd,SW_HIDE) -> hides the application window. The taskbar icon disappears for a second than re-appears.

ShowWindow(hWnd,SW_SHOWMINIMIZED) -> It simply minimizes the application window, so the taskbar icon remains

1
Even though it may be obvious to you, it certainly isn't to me: What is your question? Also consider taking the tour and visit the help center. Reading How to Ask is highly recommended as well.IInspectable
Some basic websearch would tell you that the taskbar button is shown if and only if the associated window is visible. There are nuances, but that's the main way to hide the button. Make the window invisible.David Heffernan

1 Answers

1
votes

By default a "normal" visible un-owned window gets a taskbar button and the taskbar button is visible in every state except SW_HIDE.

MSDN also documents a couple of tricks you can use to override the button:

The Shell creates a button on the taskbar whenever an application creates a window that isn't owned. To ensure that the window button is placed on the taskbar, create an unowned window with the WS_EX_APPWINDOW extended style. To prevent the window button from being placed on the taskbar, create the unowned window with the WS_EX_TOOLWINDOW extended style. As an alternative, you can create a hidden window and make this hidden window the owner of your visible window.

... If you want to dynamically change a window's style to one that does not support visible taskbar buttons, you must hide the window first (by calling ShowWindow with SW_HIDE), change the window style, and then show the window.

Another alternative is to use the ITaskbarList interface, it gives you full control over your taskbar button.