Solved

WM_SYSCOMMAND & SC_MOUSEMENU

Posted on 2004-04-08
8
1,619 Views
Last Modified: 2013-12-03
SendMessage( targetWindow, WM_SYSCOMMAND, SC_MOUSEMENU, lParam );

The documentation for SC_MOUSEMENU says "Retrieves the window menu as a result of a mouse click.". Now I know the parameters I send are correct, but it does nothing. Can someone explain why it doesnt work? Or possibly explain how I could get it to work?

Additionally, while watching with Spy++, when a window normally gets a WM_SYSCOMMAND and SC_MOUSEMENU it is only sent and theres no matching return. When I send the message it is send and and returned always.

Alternatively I will give points to any technique that will open a menubar item normally givin the items screen position, ie not getting the submenu and calling TrackPopupMenu, but allowing the OS to handle it normally as if it was clicked with a mouse ( btw, the mouse is not actually over the item ).

Thanks,

Jason
0
Comment
Question by:mite51
  • 3
  • 2
8 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 500 total points
ID: 10786206
What are you passing in lParam?

lParam
The low-order word specifies the horizontal position of the cursor, in screen coordinates, if a window menu command is chosen with the mouse. Otherwise, this parameter is not used.
The high-order word specifies the vertical position of the cursor, in screen coordinates, if a window menu command is chosen with the mouse. This parameter is –1 if the command is chosen using a system accelerator, or zero if using a mnemonic.

To open a menu, use the SendInput() or keybd_event() API functions to simulate ALT-[X] key presses.
0
 
LVL 1

Author Comment

by:mite51
ID: 10786269
LPARAM lParam;
lParam = MAKELPARAM( screenIntersect.x, screenIntersect.y );

I have matched my screenIntersect to the values I got from Spy++ just to ensure they were correct compared to normal ( not gernerated by me ) messages.

I know I can send ALT+downarrow key command to open the first menu.. only problem with that is if the menu is already in tht "ALT" state sending another ALT will turn that state off. Also its not really the same since the ALT state will wait for a hotkey, not what normall happens when you open a menu with a mouse click.

0
 
LVL 86

Expert Comment

by:jkr
ID: 10786296
>>The documentation for SC_MOUSEMENU says "Retrieves the window menu as a result
>>of a mouse click.".

There seems to be a misconception, these messages are only sent to inform applications about menu access, not to actually open them (which is done by the system) - if you want to open a menubar item, send a 'mouse_event()' to the coordinates of your menubar item.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 23

Expert Comment

by:chensu
ID: 10786309
>I know I can send ALT+downarrow key command to open the first menu.. only problem with that is if the menu is already in tht "ALT" state sending another ALT will turn that state off.

I didn't mean ALT+downarrow. For example, to open the window menu, send a ALT+Space key press.
0
 
LVL 1

Author Comment

by:mite51
ID: 10786318
Ah, that does make sense, I supposed. But there must be a way to do this without SendInput. One problem I have with SendInput or mouse_event is that unless the corrdinates of the mouse position are over the item ( ie not obscured by another window ) the event will not be routed to the desired windows.

btw, the menu may not actually be on the screen or topmost ;)

0
 
LVL 1

Author Comment

by:mite51
ID: 10786330
chesu, same deal. space opens system menu , down arrow opens the first menu. In either case is not the same as a mouse click. Tho that is probably what I will end up having to do.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now