您需要做的第一件事是处理TTN_
- ON_NOTIFY_EX(TTN_NEEDTEXT,0,&YourClass::OnToolNeedText)
然后添加您的成员函数,注意文档中说TTN_
- BOOL CBlockManagerTabDlg::OnToolNeedText( UINT id, NMHDR* pNMHDR, LRESULT* pResult )
- {
- if(pNMHDR)
- {
- //get the resource ID from sender
- UINT nID = ::GetDlgCtrlID((HWND)pNMHDR->idFrom);
- LPTOOLTIPTEXT lpTTT = (LPTOOLTIPTEXT)pNMHDR;
- //is window handle to the tool
- if ( !(lpTTT->uFlags & TTF_IDISHWND) )
- return FALSE;
- CToolTipCtrl* pToolTip = ::AfxGetModuleThreadState()->m_pToolTip;
- if (!pToolTip)
- return FALSE;
- //magically enables \r\n
- pToolTip->SetMaxTipWidth(SHRT_MAX);
- //init ptr
- LPCTSTR lpszTipMsg = NULL;
- //add our text(TCHAR[80] max) when we find our resource ID
- switch(nID)
- {
- case IDC_BUTTON_DSK_TOP:
- {
- lpszTipMsg = _T("Go to Desktop Folder");
- }
- break;
- case IDC_BUTTON_HOME:
- {
- lpszTipMsg = _T("Go to Default Folder");
- }
- break;
- case IDC_BUTTON_MY_DOC:
- {
- lpszTipMsg = _T("Go to My Documents Folder");
- }
- break;
- case IDC_LIST_BLKICON:
- {
- pToolTip->CenterWindow(CWnd::FromHandle((HWND)pNMHDR->idFrom));
- lpszTipMsg = _T("Double Click or Drag a block to insert");
- }
- break;
- case IDC_TREE_FLDR:
- {
- pToolTip->CenterWindow(CWnd::FromHandle((HWND)pNMHDR->idFrom));
- lpszTipMsg = _T("Double Click to insert\r\nDrag to open\r\nRight Click Folder to set as default");
- }
- break;
- } //switch
- if(!lpszTipMsg)
- return FALSE;
- //copy buf to tooltip
- ::lstrcpyn(lpTTT->szText,lpszTipMsg,sizeof(lpTTT->szText));
- }
- return TRUE;
- }
n4x5gfu2cp2.PNG
本帖以下内容被隐藏保护;需要你回复后,才能看到! 游客,如果您要查看本帖隐藏内容请 回复 |