|
VC制作类似于IE4的酷工具条(4) afx_msg void OnDropDown(NMHDR* pNotifyStruct, LRESULT* pResult); 在MainFrame.cpp中的MESSAGE_MAP加入消息映射 ON_NOTIFY(TBN_DROPDOWN, AFX_IDW_TOOLBAR, OnDropDown) 和处理函数体: void CMainFrame::OnDropDown(NMHDR* pNotifyStruct, LRESULT* pResult) { // this function handles the dropdown menus from the toolbar NMTOOLBAR* pNMToolBar = (NMTOOLBAR*)pNotifyStruct; CRect rect;
// translate the current toolbar item rectangle into screen coordinates // so that we'll know where to pop up the menu m_wndToolBar.GetToolBarCtrl().GetRect(pNMToolBar->iItem, &rect); rect.top = rect.bottom; ::ClientToScreen(pNMToolBar->hdr.hwndFrom, &rect.TopLeft()); if(pNMToolBar->iItem == ID_FILE_PRINT_SETUP) { CMenu menu; CMenu* pPopup;
// the font popup is stored in a resource menu.LoadMenu(IDR_PRINT_POPUP); pPopup = menu.GetSubMenu(0); pPopup->TrackPopupMenu(TPM_LEFTALIGN ¦ TPM_LEFTBUTTON, rect.left, rect.top + 1, AfxGetMainWnd()); } *pResult = TBDDRET_DEFAULT; }
7. 处理对Combox的响应,这里只对内容改变的消息进行处理,若要添加别的处理,参看Combo Box Handlers的消息映射。 在MainFrame.h中加入 afx_msg void OnNewAddress(); 在MainFrame.cpp中的MESSAGE_MAP中加入消息映射 ON_CBN_SELENDOK(AFX_IDW_TOOLBAR + 1,OnNewAddress) 同时加入函数体 void CMainFrame::OnNewAddress() { CString str;
|