Solved

selecting a menu item programatically in another app

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
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…
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now