Results 1 to 2 of 2

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

  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.

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

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

    This is the API forum for Visual Basic and I see that your code appears to be written in C. Now I don't know much about C, but I know a little about API programming, so here are some ideas/questions:

    1. Doesn't a MDI window inherit its menu bar from its MDI child windows? Try retrieving a menu from one of its child windows.
    2. Did you use GetLastError to check for an error code directly after calling GetMenuItemInfo?
    Last edited by Peter Swinkels; Jan 9th, 2013 at 04:23 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