1, dialog. Add:
Protected: ctoolbar ctoolbar; //}} AFX_MSGAFX_MSG BOOL ONTOOLTIPTEXT (UINT NID, NMHDR * PNMHDR, LRESULT * PRESULT); DECLARE_MESSAGE_MAP ()
2, the dialog. Add: CPP file:
// add the tool bar to the dialogcToolBar.Create (this); cToolBar.LoadToolBar (IDR_TOOLBAR); cToolBar.ShowWindow (SW_SHOW); cToolBar.SetBarStyle (CBRS_ALIGN_TOP | CBRS_TOOLTIPS | CBRS_FLYBY); RepositionBars (AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0); FX_MSG_MAPON_NOTIFY_EX_RANGE (TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText) ON_NOTIFY_EX_RANGE (TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText) END_MESSAGE_MAP () BOOL CToolBarTipTestDialog :: OnToolTipText (UINT, NMHDR * pNMHDR, LRESULT * pResult) {ASSERT (pNMHDR-> code == TTN_NEEDTEXTA || pNMHDR-> code == TTN_NEEDTEXTW); // if there is a top level routing frame then let it handle the message if (GetRoutingFrame () = NULL) return FALSE;! // to be thorough we will need to handle UNICODE versions of the message also !! TOOLTIPTEXTA * pTTTA = (TOOLTIPTEXTA *) pNMHDR; TOOLTIPTEXTW * pTTTW = (TOOLTIPTEXTW *) pNMHDR; TCHAR szFullText [512]; CString strTipText; UINT nID = pNMHDR-> idFrom; if (pNMHDR-> code == TTN_NEEDTEXTA && (PTTTA-> UFLA gs & TTF_IDISHWND) || pNMHDR-> code == TTN_NEEDTEXTW && (pTTTW-> uFlags & TTF_IDISHWND)) {// idFrom is actually the HWND of the tool nID = :: GetDlgCtrlID ((HWND) nID);} if (nID ! = 0) // will be zero on a separator {AfxLoadString (nID, szFullText); // # include