I have a systray application without any taskbar icon. Nowdays most systray icons are hidden and I want to make an easier access to app.
There are no forms created with Application.FormCreate so Delphi cannot show icon itself.
How to show a normal app icon always on taskbar even when there is no visible form available?
I want to catch the click like this and when its clicked show the GUI with my custom function:
class procedure TTrayMain.HandleMessages(var Msg: TMsg; var Handled: Boolean);
begin
if (Msg.wparam = SC_RESTORE ) then begin
MenuPopup (popup,2);
Exit;
end;
CodePudding user response:
A Taskbar button cannot exist without a window to represent. There are only 3 ways for a Taskbar button to be created:
- create a visible window with the
WS_EX_APPWINDOW
style - create a visible top-level unowned window
- use
ITaskbarList::AddTab()
All of them require a window. But, that doesn't mean the user has to see the window. You can create a visible window with width/height set to 0 (some frameworks do this so no single app window owns the Taskbar button, but the button can show/hide the entire app as a whole), or move it offscreen. And then the window can respond to state changes as need, such as via the Taskbar button.
Otherwise, since your tray app likely has a hidden window to receive icon notifications, you can try using that window with ITaskbarList
. I just don't know if it will actually do anything meaningful when the user clicks on the button. So, consider changing your tray app to use a visible but unseen window for notifications, then it can have a Taskbar button without involving ITaskbarList
.