Quantcast
Viewing all articles
Browse latest Browse all 168

How to get a Menu Item string of an MDI Applications?

Hello All,

What I need to do is to read the string of a target application menu item from my own application .
The target application is a MDI Application(CATIA V5).
My application and target application are running in different processes.
To do this I am calling the following function GetMenuItemContentByID as follows:

Code:


CHAR MenuItemStringW[50] = {};
...
GetMenuItemContentByID(hWnd, wID, MenuItemString);


Code:

// GetMenuItemContentByID
// =======================================================
// hWnd : handle of the target's application frame window
// wID    : ID of the menu item
//
BOOL _stdcall GetMenuItemContentByID(HWND hWnd, UINT wID, LPSTR lpString)
{
    HMENU              hMenu = GetMenu(hWnd);
    MENUITEMINFOA MenuII = {};

    MenuII.cbSize        = sizeof(MENUITEMINFOA);
    MenuII.fMask          = MIIM_STRING;
    MenuII.dwTypeData = NULL;
    GetMenuItemInfoA(hMenu, wID, FALSE, &MenuII);
    MenuII.dwTypeData = (LPSTR)lpString;
    MenuII.fMask          = MIIM_STRING;
    MenuII.cch++;
    BOOL retValue = GetMenuItemInfoA(hMenu, wID, FALSE, &MenuII);
    return retValue;
}



Testing this code with a SDI target application (like Notepad) everything works fine (ie after first call of GetMenuItemInfoA the member MenuII.cch has the number of characters of the menu item text and after the second call of GetMenuItemInfoA the lpString holds the menu item text). Testing this code with an MDI Application (like CATIA V5) I am getting nothing (ie after the first call of GetMenuItemInfoA the member MenuII.cch has zero value and after the second call of GetMenuItemInfoA the lpString content is the empty string).

Can anyone help me to understand why is not working and how to do what I want?

Thank you in advance.

-GEL

Viewing all articles
Browse latest Browse all 168

Trending Articles