我动态添加一个菜单,怎么在鼠标划过菜单的时候在状态栏里显示提示信息?

解决方案 »

  1.   

    http://www.codeguru.com/Cpp/controls/statusbar/article.php/c5935/
      

  2.   

    如果想浮动工具条中加控件,可以通过继承CToolBar,然后在创建工具条的时候,在Toolbar上创建控件,就像在一般窗口的操作,不过需要调整位置
    BOOL CComboxToolBar::InsertCombox()
    {
    const int nDropHeight = 800;

    // test
    CToolBarCtrl &pCtrl = GetToolBarCtrl();
    TBBUTTON tb ={0}; tb.idCommand = IDW_COMBO;
    // tb.fsState = TBSTATE_ENABLED;

    // Insert it in existing toolbar control
    pCtrl.InsertButton(3, &tb);
    SetButtonInfo(3, IDW_COMBO, TBBS_SEPARATOR, 100);

    CRect rect;
    GetItemRect(3, &rect);
    rect.top = 0;
    rect.bottom = rect.top + nDropHeight;
    rect.left -= 3;
    rect.right -= 3;
    if (!m_comboBox.Create(
    CBS_DROPDOWNLIST|WS_VISIBLE|WS_TABSTOP,
    rect, this, IDW_COMBO))
    {
    TRACE0("Failed to create combo-box\n");
    return FALSE;
    }

    //  Fill the combo box
    CString szStyle;
    for (INT i=0; i<4; i++)
    {
    szStyle.Format("%d%%", 25*(i+1));
    m_comboBox.AddString((LPCTSTR)szStyle);
    } szStyle.Format("%d%%", 150);
    m_comboBox.AddString((LPCTSTR)szStyle);
    szStyle.Format("%d%%", 200);
    m_comboBox.AddString((LPCTSTR)szStyle);
    szStyle.Format("%d%%", 500);
    m_comboBox.AddString((LPCTSTR)szStyle); m_comboBox.SetCurSel(0);
    return TRUE;
    }
      

  3.   

    http://www.codeguru.com/Cpp/controls/
    void CChangeMenu::OnClear() 
       {
        AfxGetMainWnd()->SetMenu(NULL);
        AfxGetMainWnd()->DrawMenuBar();
       }   void CChangeMenu::OnGoone() 
       {
        if(!menu1){
         menu1.LoadMenu(IDR_MENU1);
         AfxGetMainWnd()->SetMenu(&menu1);
         AfxGetMainWnd()->DrawMenuBar();
         menu1.Detach();
        }
       }  void CChangeMenu::OnGotwo() 
       {
        if(!menu2){
         menu2.LoadMenu(IDR_MAINFRAME);
         AfxGetMainWnd()->SetMenu(&menu2);
         AfxGetMainWnd()->DrawMenuBar();
         menu2.Detach();
        }
       }  void CChangeMenu::OnAdd() 
       {
        static int x=400;
        AfxGetMainWnd()->GetMenu()->AppendMenu(MF_STRING,x,"mynew");
        AfxGetMainWnd()->DrawMenuBar();
        x++;
       }  void CChangeMenu::OnAdditem() 
       {
        static int y=500;
        AfxGetMainWnd()->GetMenu()->GetSubMenu(0)->InsertMenu(1,MF_BYPOSITION,y,"mynewitem");
        AfxGetMainWnd()->DrawMenuBar();
        y++;
       }  void CChangeMenu::OnEdit() 
       {
        AfxGetMainWnd()->GetMenu()->ModifyMenu(0,MF_BYPOSITION,402,"dfd");
        AfxGetMainWnd()->DrawMenuBar();
       }
      

  4.   

    这个消息好像是在String Table里面直接写就可以的。
      

  5.   

    在资源里的item properties里的prompt里加入提示的时候,须加入\n如Open an existing document\nOpen,前一段是在状态栏显示,后一个是鼠标移动的tip
      

  6.   

    如果要实现动态菜单提示,必须重载CFrameWnd::OnMenuSelect和 用提示串发送WM_SETMESSAGESTRIN消息。void CMainFrame::OnMenuSelect(UINT nItemID, UINT nFlags,
    HMENU hSysMenu) 

    if (/* nItemID has a dynamic prompt */)
     {
    CString sPrompt = // whatever you want 
    SendMessage(WM_SETMESSAGESTRING, 0, (LPARAM)(LPCTSTR)sPrompt); 
    m_nIDTracking = nItemID; 
    } else { 
    CFrameWnd::OnMenuSelect(nItemID, nFlags, hSysMenu);