SDI中菜单的Prompt可以直接在CStatusBar中显示出来.现在想在Dialog窗体中的一个CStatic上显示菜单的Prompt,不知道怎么做.

解决方案 »

  1.   

    Handle the WM_MENUSELECT message. The wParam is the menu index, which is also the index of the stringtable entry that describes the menu. This prompting is ordinarily handled by the mainframe, but in a dialog-based app you have to add your own handler You can look at the code in the mfc\src\winfrm.cpp, although it is very general; you 
    probably only need a subset of it.
      

  2.   

    重载CFrameWnd的virtual void GetMessageString(UINT nID, CString& rMessage) const;函数 实现:
    --------------------------------------------------------------------------------
    void CMainFrame::GetMessageString(UINT nID, CString& rMessage) const
    {
    if(nID == ID_FILE_NEW) //这里可以动态改变
    {
    //rMessage中的内容就是菜单ID_FILE_NEW的提示内容,也可以在这里自己改
    return;
    }
    CFrameWnd::GetMessageString(nID,rMessage); //调用默认的处理过程
    }
    --------------------------------------------------------------------------------
      

  3.   

    谢谢大家,问题已经成功解决.因为是在Dialog上用Static显示,所以没有CMainFrame.根据jiangsheng(蒋晟.Net[MVP])提示响应了消息WM_MENUSELECT,在OnMenuSelect中添加:         TCHAR szTip[MAX_PATH];
    LoadString(NULL,nItemID, szTip,MAX_PATH);//nItemID为鼠标正在移动的菜单上
    GetDlgItem(IDC_STATIC_MSG)->SetWindowText(szTip);