I was used to using WndProc for handling proc messages, but now I have a console project and I want somehow to handle a custom WM_TRAYICON message.
I have the callback function, I just need to make Windows call it whenever someone interacts with the tray icon. In a recent program I did I used SetWindowsHookEx, can something similar be used?
You need to create a hidden window to use with the notification icon. Call
CreateWindowas usual to create a window, but just refrain from showing it. Make sure that you do not passWS_VISIBLEwhen creating the window.The other issue is that you need a message loop. Since a console application will not run a message loop by default, the simplest solution is to run the notification icon out of a separate thread which implements the message loop. Naturally this implies that the hidden window needs to be created and destroyed in that thread also.