Results 1 to 2 of 2

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

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2012
    Posts
    4

    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
    Last edited by GEL63; Nov 18th, 2012 at 10:13 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width