15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Tooltips w/out controls in a CScrollview?

Deepak Saxena -- Deepak_Saxena@ccm.ch.intel.com
Wednesday, November 20, 1996

Environment: VC++ 4.2-flat, NT 3.51

I have a scrollview that displays several rectangular objects I want a
tooltip to be displayed when the user pauses over the rectangular area
of each object.  Each object is not a CWnd...it's just a rectangle.  In
ondraw, I loop through all my objects and add them to the CToolTip ctrl
that I have associated with this window.  Unfortunatly, this does not
work.  Here's what I have done:

o In CMyView::OnInitialUpdate(), I call EnableToolTips(TRUE);
o In CMyView::OnCreate, I call m_ctrlMyTT.Create(this)
o In CMyView::OnDraw(), I first remove all the old tools from the ctrl
	and insert new tools as objects may have changed position.
o After inserting the new tools, I call m_ctrlTT.Activate(TRUE);

I traced through the complete PreTranslageMessage() cycle that calls
CWnd::FilterToolTipMessage(), and the problem is that the tooltipctrl
that MFC gets a hold of in FilterToolTipMessage() is not the same as
CMyView::m_ctrlTT.  I made sure of this by comparing the hWnd's of the
two objects.  So instead of going through the MFC tooltip message
routing, I tried not calling EnableToolTip() and then overiding
CMyView::PreTranslageMessage() and routing the appropriate message to
m_ctrlTT:

BOOL CIOSimView::PreTranslateMessage(MSG* pMsg)
{
   if( pMsg->message >= WM_MOUSEFIRST &&
       pMsg->message <= WM_MOUSELAST )
   {
      m_ctrlToolTip.RelayEvent( pMsg );
   }

   return CScrollView::PreTranslateMessage(pMsg);
}

But...this doesn't make my tooltips appear either.

So...how exactly does one do this?


-- 
Deepak Saxena@ccm.ch.intel.com           
http://www.cernan.ecn.purdue.edu/~deepak 
Work: (602)554-1304, Home:(602)917-5183  
I do not speak for Intel Corporation



Mark Rudick/CAM/Lotus -- Mark_Rudick/CAM/Lotus.LOTUS@crd.lotus.com
Sunday, November 24, 1996

Deepak,

I just recently had problems with ToolTips myself.
There seems to be a big problem using the conventional way of implementing 
ToolTips.  The CToolTipCtrl is a child of your main CWnd, as are the controls 
over which you'd like to display the ToolTip.  Now, there's a bug where the 
main CWnd receives a message from its child control, but that message is not 
passed along to the other child...  your CToolTipCtrl.
You can try capturing the message in a PreTranslateMessage() method and relay 
it yourself to the ToolTip control, but that can get a bit confusing.  I 
recommend you have a look at Jeff Prosise's book, Programming Windows 95 with 
MFC.  Check out CToolTipCtrl in the Advanced Topics chapter.  Here, he explains 
the bug and gives you a great workaround.  It did the trick for me!

Hope this helps.

Mark Rudick
Software Engineer
Lotus Development Corp.



	Deepak_Saxena@ccm.ch.intel.com (Deepak Saxena) 
11/20/96 03:04 PM
To: mfc-l@netcom.com @ INTERNET
cc:  (bcc: Mark Rudick/CAM/Lotus)
Subject: Tooltips w/out controls in a CScrollview?

Environment: VC++ 4.2-flat, NT 3.51

I have a scrollview that displays several rectangular objects I want a
tooltip to be displayed when the user pauses over the rectangular area
of each object.  Each object is not a CWnd...it's just a rectangle.  In
ondraw, I loop through all my objects and add them to the CToolTip ctrl
that I have associated with this window.  Unfortunatly, this does not
work.  Here's what I have done:

o In CMyView::OnInitialUpdate(), I call EnableToolTips(TRUE);
o In CMyView::OnCreate, I call m_ctrlMyTT.Create(this)
o In CMyView::OnDraw(), I first remove all the old tools from the ctrl
 and insert new tools as objects may have changed position.
o After inserting the new tools, I call m_ctrlTT.Activate(TRUE);

I traced through the complete PreTranslageMessage() cycle that calls
CWnd::FilterToolTipMessage(), and the problem is that the tooltipctrl
that MFC gets a hold of in FilterToolTipMessage() is not the same as
CMyView::m_ctrlTT.  I made sure of this by comparing the hWnd's of the
two objects.  So instead of going through the MFC tooltip message
routing, I tried not calling EnableToolTip() and then overiding
CMyView::PreTranslageMessage() and routing the appropriate message to
m_ctrlTT:

BOOL CIOSimView::PreTranslateMessage(MSG* pMsg)
{
   if( pMsg->message >= WM_MOUSEFIRST &&
       pMsg->message <= WM_MOUSELAST )
   {
      m_ctrlToolTip.RelayEvent( pMsg );
   }

   return CScrollView::PreTranslateMessage(pMsg);
}

But...this doesn't make my tooltips appear either.

So...how exactly does one do this?


-- 
Deepak Saxena@ccm.ch.intel.com           
http://www.cernan.ecn.purdue.edu/~deepak 
Work: (602)554-1304, Home:(602)917-5183  
I do not speak for Intel Corporation







| Вернуться в корень Архива |