Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- INT_PTR SomeFunction(HWND hWndChild, TOOLINFO *pTI)
- {
- if (hWndChild != NULL) // Your HWND being tested
- {
- // return positive hit if control ID isn't -1
- INT_PTR nHit = _AfxGetDlgCtrlID(hWndChild);
- // Replace with GetDlgCtrlID().
- // hits against child windows always center the tip
- if (pTI != NULL && pTI->cbSize >= sizeof(AFX_OLDTOOLINFO))
- {
- // setup the TOOLINFO structure
- pTI->hwnd = m_hWnd;
- pTI->uId = (UINT_PTR)hWndChild;
- pTI->uFlags |= TTF_IDISHWND;
- pTI->lpszText = LPSTR_TEXTCALLBACK;
- // set TTF_NOTBUTTON and TTF_CENTERTIP if it isn't a button
- if (!(::SendMessage(hWndChild, WM_GETDLGCODE, 0, 0) & DLGC_BUTTON))
- pTI->uFlags |= TTF_NOTBUTTON|TTF_CENTERTIP;
- }
- return nHit;
- }
- return -1; // not found
- }
- HWND hToolTipWnd = NULL;
- BOOL GetToolTipText(HWND hWnd, UINT nId, std::wstring& strTooltip)
- {
- hToolTipWnd = NULL;
- EnumWindows(FindToolTip, (LPARAM)hWnd);
- if (hToolTipWnd == NULL)
- return FALSE;
- WCHAR szToolText[256];
- TOOLINFO ti;
- ti.cbSize = sizeof(ti);
- ti.hwnd = hWnd;
- ti.uId = nId;
- ti.lpszText = szToolText;
- SendMessage(hToolTipWnd, TTM_GETTEXT, 256, (LPARAM)&ti);
- strTooltip = szToolText;
- return TRUE;
- }
- BOOL CALLBACK FindToolTip(HWND hWnd, LPARAM lParam)
- {
- WCHAR szClassName[256];
- if (GetClassName(hWnd, szClassName, 256) == 0)
- return TRUE;
- if (wcscmp(szClassName, L"tooltips_class32") != 0)
- return TRUE;
- if (GetParent(hWnd) != (HWND)lParam)
- return TRUE;
- hToolTipWnd = hWnd;
- return FALSE;
- }
Add Comment
Please, Sign In to add comment