Solved

WM_SYSCOMMAND & SC_MOUSEMENU

Posted on 2004-04-08
8
1,648 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

705 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