Solved

selecting a menu item programatically in another app

Posted on 1998-08-01
3
424 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Suggested Solutions

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
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…

732 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