Setting a callback for tray icon message handling in a console project?

You need to create a hidden window to use with the notification icon. Call CreateWindow as usual to create a window, but just refrain from showing it. Make sure that you do not pass WS_VISIBLE when creating the window.

Up vote 0 down vote favorite share g+ share fb share tw.

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?

Winapi callback link|improve this question asked Nov 8 '11 at 19:50Panayiotis1128 100% accept rate.

You need to create a hidden window to use with the notification icon. Call CreateWindow as usual to create a window, but just refrain from showing it. Make sure that you do not pass WS_VISIBLE when 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.

I propose you do not make your project console. If you want to handle window messages in legitimate way (without hooks and hacks) and you want to have a console then typical solution is to use AllocConsole function.

Console apps can perfectly legitimately use windows and message loops. Creating a hidden window to handle the message (likely on its own thread) is the simplest way to go here if the OP need the app to remain a console app. – BrendanMcK Nov 9 '11 at 0:06.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions