Sign in to follow this  
Timkin

win32 menu problem [SOLVED]

Recommended Posts

Okay, I've been stepping well out of my comfort zone lately and playing around with windows programming and I've hit a snag in what should otherwise be a simple task... hence asking for help here... in this area, I'm a beginner!!! I'm working with MSVC++ .NET (7.1) and adding resources; in this case, a menu. I have no problem creating the menu resource, or adding it to my project, but it's producing weird functionality and I don't know enough about it to work out why it isn't working as I expect. I have a single popup menu (File) with one submenu item, Quit (to close my window). I can set up keys to make this work, but it's the mouse I'm having problems with. The base File menu won't respond to mouse clicks. However, if I open it with ALT+F, I can then use either the mouse or a keystroke to trigger the 'Quit' option and handle my window close process. Could someone please enlighten me as to basic resource functionality and how you get top level menus to respond to mouse clicks. Thanks, Timkin SOLVED: It turned out to be a problem with my message loop. Funnily enough I found this myself after several hours of reading and digesting information... only to come back here to post this update and notice Endurion's message pointing me in that direction! The problem did indeed arise because I wasn't passing correct return values from my message loop... I thought that it would be reasonable to set up my switch statement with with DefWindowProc as return value of the 'default' case and have specific message cases use break and a common return value... for some stupid reason that typical use of 'switch' doesn't want to work... it would only work if each 'case' returned 0. Go figure! [Edited by - Timkin on June 7, 2007 12:16:45 AM]

Share this post


Link to post
Share on other sites
Hey,

I had similliar problems w/MFC, but I don't know how the framework has changed with the .NET platform. W/MFC, you had to write seperate messgae handling routines for the WM_MOUSE* and WM_KEY* messages. The routines where virtual, and no-op until you overloaded them...

Share this post


Link to post
Share on other sites
Are you using pure Win32? If yes, please show the message loop. This sounds awfully like some message handling problem.

Do you pass messages on to the DefWindowProc? If not this might be the cause. The menu enters its own message loop once active so that could be the reason why the mouse suddenly works.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this