Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement ToolTips with Measurement Studio 6 & VC++ 6?

I've run into a problem using ToolTips in my dialog based application. I have ToolTips working for MFC controls, but all of the CNiControls return an ID of 0 when GetDlgCtrlID((HWND)nID) is called in the standard ToolTip handler:

bool CToolTipTestDlg::OnToolTipNotify(UINT id, NMHDR *pNMHDR, LRESULT *pResult)
{
// need to handle both ANSI and UNICODE versions of the message
TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
CString strTipText;
UINT nID = pNMHDR->idFrom;

if (pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) ||
pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND))
{
// idFrom is actually the HWND of the tool
nID = ::GetDlgCtrlID((HWND)nID);
}
.
.
.

Can anyone see what I've got wrong here?
0 Kudos
Message 1 of 2
(3,087 Views)
Found a solution:

// Work-around for CNiControls returning nID = 0 with
// ::GetDlgCtrlID((HWND)nID)
CWnd* cwnd = this->FromHandle((HWND)nID);
nID = cwnd->GetDlgCtrlID();
0 Kudos
Message 2 of 2
(3,055 Views)