News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Window Popup Menus

Started by zemtex, October 04, 2010, 03:41:17 AM

Previous topic - Next topic

zemtex

Hello folks.

I am playing around with the title-bar popup menu in my windowed program. You kow the title bar popup menu where you have the different items related to maximizing, minimizing, closing, restoring window (resizing it etc).

I am trying to eliminate the delay between right clicking and releasing the right mouse button until the popup shows, i've done that by processing the WM_NCLBUTTONDOWN message and by using API calls GetSystemMenu and by using TrackPopupMenu. The menu is now very fast and shows up immediately when you right click your mouse button, you don't have to wait until you release the right mouse button anymore.

But I have a problem. I don't know how to call the subitems of that popup menu, it doesnt do anything, it just shows up and sometimes the popup menu is a bit corrupted compared to the popup menu that shows up if you click the program icon on the left side of the window.

According to windows SDK you should use WM_SYSCOMMAND to call the different commands in the popup menu, but my problem is that the menu returns menu identifiers, it doesnt actually return the different commands. How can I effectively call the different commands in the popup menu?

By the way, if there are more efficient ways of eliminating the Right Click - Release Right click any other ways than I have done here, feel free to tell me how this can be done effectively. I love the quickness of popup menus that only needs the down position of the mouse button instead of down and up.

The preferable setup would be to be able to: 1: Right click and hold mouse button down. 2: Popup menu appears. 3: Move your mouse button to an item 4: Let go of mouse button 5: And then that command gets executed.

So far I have to let go of the mouse button and then click again for the command to execute.

EDIT: I managed to get the items to work now. But there is a problem that the popup menu doesnt update itself. When you click Maximize, it will not be grayed out when the window is maximized. You have to close the popup and then reopen it one or two times for it to become grayed out. I think this problem is related to that the popup menu is created in a custom windows message by me, and it doesnt pass the default handler in windows, which sets the items to grayed out.

Is there a way I can initialize / run the popup and then pass the execution / handler back to windows without handling it myself. I just want the popup to appear when I want to?

Never mind, I solved it. I changed constant in parameter 3 in API call EnableMenuItem from MF_BYCOMMAND to MF_BYPOSITION and now it seems to work.
I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.