请问: 如何给子窗口添加菜单我建了一人对话框,设置了它的child窗口.当我在InitDialog()中加入如下代码之后, 为何显示不出菜单:
m_hMenu= ::LoadMenu(...);
::SetMenu(m_hMenu);谢谢先...

解决方案 »

  1.   

    直接在VC中对话框的“属性”里的Menu下拉框里选择菜单ID就可以了。
      

  2.   

    TO:lzzqqq(Jonersen)设置成子窗口后,你说的那个Menu下拉框就会变灰...
      

  3.   

    我刚建了一个基于对话框的新工程试了一下,可以,
    Dialog的属性没有修改,就是说既没有改成Child,也没有指定Menu
    然后再Dialog的class里加一个成员变量CMenu *m_pMenu;
    在OnInitDialog里
    m_pMenu = new CMenu;
    m_pMenu->LoadMenu(IDR_MAINMENU);
    SetMenu(m_pMenu);
    就OK了
      

  4.   

    谢谢以上两位.to:sjhunter>>Dialog的属性没有修改,就是说既没有改成Child,不设Child属性是可以. 可是想知道设了这个属性之后, 如何加菜单...
      

  5.   

    以一个专家的身份告诉你:
    子窗口不能有菜单。
    你看一下 CreateWindowEx() 函数就应该明白,在系统维护的窗口内部结构里,菜单句柄和子窗口 ID 共用一个变量,不是子窗口时,该变量表示菜单句柄,否则为子窗口 ID。
      

  6.   

    To dandycheung(珠穆朗玛) 
    长见识了,明天到公司时一定看看CreateWindowEx的源码
      

  7.   

    MSDN里面讲了
    CreateWindowEx
    The CreateWindowEx function creates an overlapped, pop-up, or child window with an extended window style; otherwise, this function is identical to the CreateWindow function. For more information about creating a window and for full descriptions of the other parameters of CreateWindowEx, see CreateWindow. HWND CreateWindowEx(
      DWORD dwExStyle,      // extended window style
      LPCTSTR lpClassName,  // registered class name
      LPCTSTR lpWindowName, // window name
      DWORD dwStyle,        // window style
      int x,                // horizontal position of window
      int y,                // vertical position of window
      int nWidth,           // window width
      int nHeight,          // window height
      HWND hWndParent,      // handle to parent or owner window
      HMENU hMenu,          // menu handle or child identifier  //注意这个
      HINSTANCE hInstance,  // handle to application instance
      LPVOID lpParam        // window-creation data
    );
    下面看看解释:hMenu 
    [in] Handle to a menu, or specifies a child-window identifier, depending on the window style. For an overlapped or pop-up window, hMenu identifies the menu to be used with the window; it can be NULL if the class menu is to be used. For a child window, hMenu specifies the child-window identifier, an integer value used by a dialog box control to notify its parent about events. The application determines the child-window identifier; it must be unique for all child windows with the same parent window. 
      

  8.   

    可以直接为对话框选择一个menu就行了
    直接在VC中对话框的“属性”里的Menu下拉框里选择菜单ID就可以了。
      

  9.   

    多谢各位.特别是: dandycheung(珠穆朗玛) 和 whwjn(菜鸟学飞) . 谢谢你们.下午过来结贴.
      

  10.   

    多谢whwjn(菜鸟学飞) 
    看了半天WINMDI.CPP,就是没想起来看看MSDN