Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

WM_SYSCOMMAND & SC_MOUSEMENU

Posted on 2004-04-08
8
Medium Priority
?
1,692 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
6 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 2000 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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…
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
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…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

810 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