Thanks!
Georg
georg.d...@t-online.de
Knowledge Base Q172276, Bug: CToolTipCtrl Not
Displaying After VS SP1 and SP2 Install.
Also, Q167650, Q133257, Q141758, Q143313
Ken
Georg Deisinger <Georg.D...@t-online.de> wrote in article
<6ee9jt$8sf$1...@news01.btx.dtag.de>...
Georg,
I wrestled with this same problem several weeks ago. For an MFC dialog
I found the following works for me:
The CWnd class has its own tooltip control built in. Therefore all I
do is:
BEGIN_MESSAGE_MAP(CMfcDlgttDlg, CDialog)
//{{AFX_MSG_MAP(CMfcDlgttDlg)
...
//}}AFX_MSG_MAP
ON_NOTIFY_EX( TTN_NEEDTEXT, 0, HandleNeedText )
END_MESSAGE_MAP()
BOOL CMfcDlgttDlg::HandleNeedText( UINT id, NMHDR * pNMHDR, LRESULT *
pResult )
{
TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
UINT nID =pNMHDR->idFrom;
if (pTTT->uFlags & TTF_IDISHWND)
{
// idFrom is actually the HWND of the tool
nID = ::GetDlgCtrlID((HWND)nID);
if(nID)
{
/* Assumes you have a string resource with the
same ID as the dialog control ID for the tooltip text */
pTTT->lpszText = MAKEINTRESOURCE(nID);
pTTT->hinst = AfxGetResourceHandle();
return(TRUE);
}
}
return(FALSE);
}
And in OnInitDialog I call EnableToolTips().
There's no tooltip control to add/create, no AddTool calls, and no
PreTranslateMessage needed. It seems to work fine for me. Let me know
if it works for you (if you try it of course).
Dave
----
Address is altered to discourage junk mail.
Remove ".---" for the real address.
my implementation code for the "ON_NOTIFY_EX" - message is similar to your
sample code.
I also override the "virtual int CWnd::OnToolHitTest" method to provide
different information than the default provides (for example I set the hwnd
and uId of the TOOLINFO structure to the handle of my own CEdit derived
class ("this>m_hWnd")
and "lpszText = LPSTR_TEXTCALLBACK" etc.).
All these things (and "EnableToolTips()") are done within !! my own CEdit
derived class.
So every parent of my control class (View/CDialog etc) can take advantage
of the tooltips( the "GetParent()->EnableToolTips()" is done from my control
too).
As long as my control is enabled it works fine (the parent of my control is
a View).
The framework calls my control "OnToolHitTest" and the
"ON_NOTIFY_EX"-message is passed to my control and activates my method and
the tooltips are displayed.
But when I disable my control it seems to me as if no "WM_NOTIFY" - message
(or no message at all ?) is passed to my control.
So the above mentioned methods are not activated and tooltips are not
displayed.
My problem: What can I do to get messages passed to my disabled control ??
Georg
David Lowndes wrote in message <351f4f66...@msnews.microsoft.com>...
Georg,
I'm afraid the more I find about tooltips the less I understand them.
If I get time I'll try to do something like you have to see if I get
the same problem.
One of the biggest issues seems to be quite what MFC does with the
tooltip - I've looked at the code several times, but not having an
in-depth understanding of how the native tooltip control works I find
it's difficult to really know if there are problems in how MFC handles
things or not. VC5 sp2 apparently introduced some problems with
tooltips but I believe they were remedied in sp3.
David Lowndes <dav...@mvps.org.---> wrote in article
<352e0645...@msnews.microsoft.com>...
> >As long as my control is enabled it works fine (the parent of my control
is
> >a View).
[...]
> One of the biggest issues seems to be quite what MFC does with the
> tooltip - I've looked at the code several times, but not having an
There lies possible answers. Look at RelayToolTipMessage() in MFC
(TOOLTIP.CPP)
- it changes the window handle of the message (calling the tooltip itself
to find the right window).
Looks like disabled windows don't actually get messages sent to them and
the tooltip will
therefore not match the window handle.
I have made tooltips work for disabled controls on a dialog by using the
DevStudio Tooltips component and modifying the code it adds to
PreTranslateMessage() to do the same translation
as MFC does in RelayToolTipMessage().
Unfortunately all the MFC tooltip stuff appears to rely on
PreTranslateMessage which never happens in an ActiveX control... does
anyone know how to do tooltips in an MFC activeX control ?
[ yes I know there are examples in the docs, but they are all
one-tooltip-over-one-window, I want
tooltips over lots of different child windows, on dialogs, toolbars etc.
- within an ActiveX control ].
> in-depth understanding of how the native tooltip control works I find
> it's difficult to really know if there are problems in how MFC handles
> things or not. VC5 sp2 apparently introduced some problems with
> tooltips but I believe they were remedied in sp3.
Not all of them, at least from my point of view. eg:
Try using CWnd::EnableToolTips() in an activex control as described in the
1997 MSJ article titled
"Tiptoe Through the ToolTips With Our All-Encompassing ToolTip Programmer's
Guide"
(also in MSDN). Then put said control in an MFC container, and watch the
asserts fly (in debug versions) or the spectacular lack of any tooltips (in
release).
MFC uses one common tooltip and tries to pass it CWnd pointers to it across
modules. CWnd handle map is per thread/module... bang.
Ray Auchterlounie
<r...@apso.com>