ee-user
asked on
TreeView tooltips with Win32 api (not mfc)
I'm attempting to get the ToolTips for a TreeView to work. I was able to intercept a message when the mouse hovers over the TreeView item, but I didn't know what to do next.
case WM_NOTIFY:
pnmhdr = (LPNMHDR) lParam;
// TreeView
if (pnmhdr->hwndFrom == hWndTree) {
if (pnmhdr->code == TVN_SELCHANGED || pnmhdr->code == TVN_KEYDOWN) {
LoadDocument(lParam);
}
else if (code == TVN_GETINFOTIP) { // Gets here
NMLVGETINFOTIP* nmTip = (NMLVGETINFOTIP*)lParam;
nmTip.pszText = greeting; // set to "Hello"
nmTip.cchTextMax = 20;
// SendMessageA(????????????) ;
}
}
break;// WM_NOTIFY
Once the TVN_GETINFOTIP message is handled, what next? I was trying to just put up a "Hello" message at first. I've gotten something similar to work with MFC ListControl, but want to use native Win32 api calls.
case WM_NOTIFY:
pnmhdr = (LPNMHDR) lParam;
// TreeView
if (pnmhdr->hwndFrom == hWndTree) {
if (pnmhdr->code == TVN_SELCHANGED || pnmhdr->code == TVN_KEYDOWN) {
LoadDocument(lParam);
}
else if (code == TVN_GETINFOTIP) { // Gets here
NMLVGETINFOTIP* nmTip = (NMLVGETINFOTIP*)lParam;
nmTip.pszText = greeting; // set to "Hello"
nmTip.cchTextMax = 20;
// SendMessageA(????????????)
}
}
break;// WM_NOTIFY
Once the TVN_GETINFOTIP message is handled, what next? I was trying to just put up a "Hello" message at first. I've gotten something similar to work with MFC ListControl, but want to use native Win32 api calls.
ASKER
strcpy(nmTip->pszText, str);
results in access error.
With a List control, the infotip shows up with:
nmTip->pszText = str;
results in access error.
With a List control, the infotip shows up with:
nmTip->pszText = str;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
THANKS!
Sorry to be slow checking your answer ... and realizing my error with using "LV" rather than "TV". That cleared up everything :-)
One of those "forehead, meet palm" blunders on my part :-(
Sorry to be slow checking your answer ... and realizing my error with using "LV" rather than "TV". That cleared up everything :-)
One of those "forehead, meet palm" blunders on my part :-(
nmTip.pszText = greeting; // set to "Hello"
nmTip.pszText is a pointer to a buffer that you should copy your new string into,
whereas all you're doing is making the pointer point elsewhere, which has no effect.
You need to do this instead:
strcpy(nmTip.pszText, greeting);