用mfc的wizard生成一个最简单的Single document程序,这里mainframe中的菜单不知道是在哪里创建的(我知道工具栏和状态栏是在OnCreate()里创建的)
本人是菜鸟,最近在看书,可能是看书不仔细,这个问题没想明白,请大虾指点

解决方案 »

  1.   

    我知道工具栏和状态栏是在OnCreate()里创建的
    ======================================
    同一个位置int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
            if (CFrameWnd::OnCreate(lpCreateStruct) == -1)//看一下lpCreateStruct结构体
    return -1;

    if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
    | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
    !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
    {
    TRACE0("Failed to create toolbar\n");
    return -1;      // fail to create
    } if (!m_wndStatusBar.Create(this) ||
    !m_wndStatusBar.SetIndicators(indicators,
      sizeof(indicators)/sizeof(UINT)))
    {
    TRACE0("Failed to create status bar\n");
    return -1;      // fail to create
    } // TODO: Delete these three lines if you don't want the toolbar to
    //  be dockable
    m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
    EnableDocking(CBRS_ALIGN_ANY);
    DockControlBar(&m_wndToolBar); return 0;
    }typedef struct tagCREATESTRUCTA {
        LPVOID      lpCreateParams;
        HINSTANCE   hInstance;
        HMENU       hMenu;//这里
        HWND        hwndParent;
        int         cy;
        int         cx;
        int         y;
        int         x;
        LONG        style;
        LPCSTR      lpszName;
        LPCSTR      lpszClass;
        DWORD       dwExStyle;
    } CREATESTRUCTA, *LPCREATESTRUCTA;
      

  2.   

    窗口创建函数Create中有一个参数指定了菜单句柄HMENU
      

  3.   

    HMENU hMenu = NULL;
    if (lpszMenuName != NULL)
    {
    // load in a menu that will get destroyed when window gets destroyed
    HINSTANCE hInst = AfxFindResourceHandle(lpszMenuName, RT_MENU);
    if ((hMenu = ::LoadMenu(hInst, lpszMenuName)) == NULL)
    {
    TRACE(traceAppMsg, 0, "Warning: failed to load menu for CFrameWnd.\n");
    PostNcDestroy();            // perhaps delete the C++ object
    return FALSE;
    }
    } m_strTitle = lpszWindowName;    // save title for later if (!CreateEx(dwExStyle, lpszClassName, lpszWindowName, dwStyle,
    rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
    pParentWnd->GetSafeHwnd(), hMenu, (LPVOID)pContext))
    {
    在CFrameWnd的Create中有这样的代码
      

  4.   

    SyntaxHRESULT create(          VARIANT width,
        VARIANT height,
        IHTMLImgElement **ppImgElement
    );
    Parameterswidth
    [in] Width, in pixels, of the new img element. 
    height
    [in] Height, in pixels, of the new img element. 
    ppImgElement
    [out, retval] Address of a pointer to a variable that receives an interface pointer to the new img element. 
    Return ValueReturns S_OK if successful, or an error value otherwise.