Reputation: 1388
I have a program that literally consists of a tray icon. No GUI is needed. However, when writing the win32 code, is it necessary to still initialize a hWnd object to be associated with the tray icon?
For instance, it is normal to have a the NOTIFYICONDATA hWnd field point to the window's handle. Like
nid.hWnd = hwnd;
Essentially, will my icon be able to still receive messages if i set
nid.hwnd = NULL;
Upvotes: 4
Views: 1757
Reputation: 1378
You could create a message-only window by specifying HWND_MESSAGE
creating the window. However, message-only windows do not receive broadcast messages and you would miss out on the TaskbarCreated
message. This message tells your application that explorer.exe
has restarted and that your application needs to re-add its notification icons. Rather important. So create a window that never becomes visible: never call ShowWindow()
.
Upvotes: 4
Reputation: 36896
How would you receive messages without a window?
Yes you need a window associated with the tray icon.
Upvotes: 7