设置 MFC 控件的工具提示
您需要做的第一件事是处理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 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;
}
**** Hidden Message ***** 所以我可以稍后找到它
对于调色板使用
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXT,0,0xFFFF,&CPalette***ChildDlg::OnToolNeedText)
&&
this->EnableToolTips(TRUE);
页:
[1]