Solved

selecting a menu item programatically in another app

Posted on 1998-08-01
3
426 Views
Last Modified: 2013-12-03
I will like to select a menu item programatically. What I am doing (think should be done)  is_
1. Get a handle to the applications window using 'FindWindowEx'
          hWndApp = FindWindowEx(NULL,  NULL, NULL, AppCap);
2. Get a handle (HMENU) the the top level menu using 'GetMenu'
          hMMenu = ::GetMenu(hWndApp);
3. Get the Menu Handle (HMENU)  to the first entry in the menu (usually 'File') using 'GetSubMenu'
      hMItem1 = ::GetSubMenu(hMMenu, 0);
4. Then select the first entry in the 'FIle' menu item (usually 'New') using 'PostMessage'
      wParam = MAKEWPARAM( 0,  (WORD) MF_MOUSESELECT);
      x = ::PostMessage(hWndApp, WM_MENUSELECT, wParam,(LPARAM) hMItem1);

Well the problem is it is not working. Each of these calls return success. But it does not work.
Will the expert gurus point out the hole in my logic?

Thanks a lot.

0
Comment
Question by:robin_raul
[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
  • 2
3 Comments
 

Author Comment

by:robin_raul
ID: 1412905
Edited text of question
0
 

Author Comment

by:robin_raul
ID: 1412906
Edited text of question
0
 
LVL 11

Accepted Solution

by:
alexo earned 50 total points
ID: 1412907
Conssider a different approach:  Send a WM_COMMAND message with the ID of the menu item.  Works for me...
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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 video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

724 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