?
Solved

WM_SYSCOMMAND & SC_MOUSEMENU

Posted on 2004-04-08
8
Medium Priority
?
1,663 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 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

765 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