views:

45

answers:

1

I have added a menu item to the SystemMenu of the console window of my application which i created using the AllocConsole() function. but I could not figure out how to process the events for the menu items I've added.

How can i process those menu events?

Thank you

+1  A: 

Did you try overriding window proc of the console window? ie once you have obtained the window handle with GetConsoleWindow and then hooked its window proc with SetWindowLongPtr, you have to listen the WM_SYSCOMMAND message. See this article on how to process menu items from system menu.

Ismael
Yeah i tried that.But i get an ERROR_ACCESS_DENIED when i try to subclass the console window
NightCoder
According to this message http://groups.google.com/group/comp.os.ms-windows.programmer.win32/msg/e98bac69a7052d9b, you can't subclas console window. Also you can try using a window hok http://msdn.microsoft.com/en-us/library/ms644959%28VS.85%29.aspx. The last option is to override the window proc using a trampoline, but I think that doing this is too far, just for adding a few menuitems.
Ismael
+1 Thanks.I shall try windows hooks
NightCoder