Solved

selecting a menu item programatically in another app

Posted on 1998-08-01
3
420 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
  • 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

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…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

809 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