开发者

how to create taskbar button w/o any window?

I have simple no-UI application that will be then converted to windows service. but for testing it would be useful to see when it's running. so I'd like to create a taskbar button as other applications with UI have. is it possible with reasonable effor开发者_如何学Got?


No, it's not possible. Buttons on the taskbar represent windows. You can't have a button without a window, and that window needs to be visible. (The window can have coordinates that place it off the screen(s), and it can have zero dimensions, but it needs to have the WS_VISIBLE style.)

Another option is to create a notification icon. It needs to have a window, too, but the window doesn't have to be visible. Getting that set up might be more effort than you want, though, if the end goal is for the program to be a service; services can't show notification icons or have windows.

Perhaps the easiest change is to simply make your program be a console program. Then the OS will create a console window for you. Your program doesn't have to create it or manage it in any way.


Create an Object of type ITaskbarList, then invoke the method AddTab on it. You don't need a visible window for this to work. A dummy, invisible window will do. Of course such a window won't show up in the taskbar if you don't add it manually with the mentioned method above.


Create a custom window class and keep the window always minimized or always invisible (size of 0 and position somewhere near -32767)


Windows services should have UI. In fact, in Windows Vista and Windows 7 they are running in a different session and have no access to the desktop.

To monitor you service you need to write another application. Usually such applications run with hidden windows and use the notification area for interacting with the user.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜