把CFrameWnd的代码复制出来改改 Before the tool tip is displayed, the TTN_NEEDTEXT notification message is sent to the owner window of the toolbar to retrieve the descriptive text for the button. If the owner window of the toolbaris a CFrameWnd window, tool tips are displayed wihout any extra effort, because CFrameWnd has a default handler for the TTN_NEEDTEXT notification. If the owner window of the toolbaris not derived from CFrameWnd, such as a dialog box or form view, you must add an entry to the message map of your owner window and provide a notification handler in the message map. The entry to the message map of your owner window is as follows:ON_NOTIFY_EX( TTN_NEEDTEXT, 0, memberFxn ) memberFxn The method to be called when text is needed for this button. Note that the id of a tool tip is always 0.In addition to the TTN_NEEDTEXT notification, a tool tip control can send the following notifications to a toolbar control:Notification Meaning TTN_NEEDTEXTA Tool tip control requires ASCII text (Win95 only). TTN_NEEDTEXTW Tool tip control requires UNICODE text (Windows NT only). TBN_HOTITEMCHANGE Indicates that the hot (highlighted) item has changed. NM_RCLICK Indicates the user has right-clicked a button. TBN_DRAGOUT Indicates the user has clicked the button and dragged the pointer off the button. It allows an application to implement drag and drop from a toolbar button. When receiving this notification, the application will begin the drag and drop operation. TBN_DROPDOWN Indicates the user has clicked a button that uses the TBSTYLE_DROPDOWN style. TBN_GETOBJECT Indicates the user moved the pointer over a button ithat uses the TBSTYLE_DROPPABLE style. The message.
不是CFrameWnd才需要ON_NOTIFY_EX,那么CFrameWnd又应该怎样呢?
class CToolTipCtrl : public CWnd Res The CToolTipCtrl class encapsulates the functionality of a "tool tip control," a small pop-up window that displays a single line of text describing the purpose of a tool in an application. A "tool" is either a window, such as a child window or control, or an application-defined rectangular area within a window's client area. A tool tip is hidden most of the time, appearing only when the user puts the cursor on a tool and leaves it there for approximately one-half second. The tool tip appears near the cursor and disappears when the user clicks a mouse button or moves the cursor off the tool.CToolTipCtrl provides the functionality to control the initial time and duration of the tool tip, the margin widths surrounding the tool tip text, the width of the tool tip window itself, and the background and text color of the tool tip. A single tool tip control can provide information for more than one tool.The CToolTipCtrl class provides the functionality of the Windows common tool tip control. This control (and therefore the CToolTipCtrl class) is available only to programs running under Windows 95/98 and Windows NT versions 3.51 and later.For more information about enabling tool tips, see Tool Tips in Windows not Derived from CFrameWnd.For more information on using CToolTipCtrl, see Controls and Using CToolTipCtrl.Requirements Header: afxcmn.hSetToolInfo() : Sets the information that a tool tip maintains for a tool.
void SetToolInfo( LPTOOLINFO lpToolInfo );
你必须去响应
BOOL CMainFrame::TipNeedText(UINT id, NMHDR * pMHDR, LRESULT * pResult)
{
TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pMHDR;
UINT nID =pMHDR->idFrom;
if(nID>=0x8008)
{
nID=nID-0x8008;
szTipText=m_strMontageName[nID];
pTTT->lpszText=szTipText.GetBuffer(0);
pTTT->hinst = AfxGetResourceHandle();
return(TRUE);
}
return(FALSE);
}
{...
m_wndToolBar.SetButtonText(0,"New");
m_wndToolBar.SetButtonText(1,"Open");
m_wndToolBar.SetButtonText(2,"Save");
m_wndToolBar.SetButtonText(4,"Cut");
m_wndToolBar.SetButtonText(5,"Copy");
m_wndToolBar.SetButtonText(6,"Paste");
m_wndToolBar.SetButtonText(8,"Print");
m_wndToolBar.SetButtonText(10,"About");
m_wndToolBar.SetButtonText(11,"hello");
m_wndToolBar.SetSizes(CSize(42,38),CSize(16,15));
..
}
Before the tool tip is displayed, the TTN_NEEDTEXT notification message is sent to the owner window of the toolbar to retrieve the descriptive text for the button. If the owner window of the toolbaris a CFrameWnd window, tool tips are displayed wihout any extra effort, because CFrameWnd has a default handler for the TTN_NEEDTEXT notification. If the owner window of the toolbaris not derived from CFrameWnd, such as a dialog box or form view, you must add an entry to the message map of your owner window and provide a notification handler in the message map. The entry to the message map of your owner window is as follows:ON_NOTIFY_EX( TTN_NEEDTEXT, 0, memberFxn )
memberFxn
The method to be called when text is needed for this button.
Note that the id of a tool tip is always 0.In addition to the TTN_NEEDTEXT notification, a tool tip control can send the following notifications to a toolbar control:Notification Meaning
TTN_NEEDTEXTA Tool tip control requires ASCII text (Win95 only).
TTN_NEEDTEXTW Tool tip control requires UNICODE text (Windows NT only).
TBN_HOTITEMCHANGE Indicates that the hot (highlighted) item has changed.
NM_RCLICK Indicates the user has right-clicked a button.
TBN_DRAGOUT Indicates the user has clicked the button and dragged the pointer off the button. It allows an application to implement drag and drop from a toolbar button. When receiving this notification, the application will begin the drag and drop operation.
TBN_DROPDOWN Indicates the user has clicked a button that uses the TBSTYLE_DROPDOWN style.
TBN_GETOBJECT Indicates the user moved the pointer over a button ithat uses the TBSTYLE_DROPPABLE style. The message.
Res
The CToolTipCtrl class encapsulates the functionality of a "tool tip control," a small pop-up window that displays a single line of text describing the purpose of a tool in an application. A "tool" is either a window, such as a child window or control, or an application-defined rectangular area within a window's client area. A tool tip is hidden most of the time, appearing only when the user puts the cursor on a tool and leaves it there for approximately one-half second. The tool tip appears near the cursor and disappears when the user clicks a mouse button or moves the cursor off the tool.CToolTipCtrl provides the functionality to control the initial time and duration of the tool tip, the margin widths surrounding the tool tip text, the width of the tool tip window itself, and the background and text color of the tool tip. A single tool tip control can provide information for more than one tool.The CToolTipCtrl class provides the functionality of the Windows common tool tip control. This control (and therefore the CToolTipCtrl class) is available only to programs running under Windows 95/98 and Windows NT versions 3.51 and later.For more information about enabling tool tips, see Tool Tips in Windows not Derived from CFrameWnd.For more information on using CToolTipCtrl, see Controls and Using CToolTipCtrl.Requirements
Header: afxcmn.hSetToolInfo() : Sets the information that a tool tip maintains for a tool.