Pregunta

I'd like to use Shell_NotifyIcon() to add an icon to the system tray but I do not want to have a visible window in my application. That's why I'm passing a handle to a message-only window to Shell_NotifyIcon(). The window has been created like that:

hTrayWnd = CreateWindowEx(0, CLASSNAME, "tray_dummy", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, HINSTANCE, NULL);

CLASSNAME points to the name of my class that I've registered using RegisterClassEx() and HINSTANCE is the handle of my instance.

Now the problem is: The tray icon is added but the WindowProc() of my class is never called. If I use a normal top-level window instead, everything is working fine.

Is there no way to create a tray icon without a top-level window? I've seen apps having a tray icon without a top level window so it must be possible somehow. But why does it not work with a HWND_MESSAGE window?

Thanks!

¿Fue útil?

Solución

Oops, sorry, it was my fault. The reason why it didn't work was that I called CreateWindowEx() from a different thread. When I use the main thread it is working fine.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top