selecting a menu item programatically in another app
Posted on 1998-08-01
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.