-
April 16th, 2019, 02:11 PM
#1
CMFCToolTipCtrl in CView
Hi everyone. Would you give me a solution to a following issue: on an MDI app, with CView as CMyView, and here a spread a self developed control, derived from CWnd. This control draw some rectangles. The issue here is to display a CMFCToolTipCtrl when I am with mouse over these rectangles ... that is all. But I didn't make it by now.
I have tried to handle
Code:
ON_NOTIFY(TTN_NEEDTEXT, ID_MYCTRL, OnGetTooltipText)
in CMyView ... OnGetTooltipText is not called.
If I pass OnMouseMove from CMyCtrl (derived CWnd) to CMyView, and is this handler to call CMFCToolTipCtrl::Popup() is happen something: the tooltip is showing, CMyView is loosing the focus, and tooltip is closing, the CMyView is get the focus again, and CMyCtrl is send again OnMouseMove to the parent, which is CMyView, the tooltip is show again, and this is looping foe ever, which reveal me that is not the right solution ...
this is the architecture of my CMyView:
Code:
void CMyView::OnInitialUpdate()
{
CView::OnInitialUpdate();
VERIFY(m_pMyCtrl->Create(WS_CHILD | WS_VISIBLE | WS_VSCROLL, CRect(0, 0, 0, 0), this, ID_MYCTRL));
...
}
and
Code:
void CMyView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
if (NULL != m_pMyCtrl->GetSafeHwnd() && cx > 0 && cy > 0)
{
CRect rect(CPoint(0, 0), CSize(cx, cy));
m_pMyCtrl->MoveWindow(rect);
}
}
how you would show correctly a tooltip when you mouse pointer is somewhere on view ? What is the right way to do this ?
Thank you for any hint.
-
April 16th, 2019, 03:13 PM
#2
Re: CMFCToolTipCtrl in CView
Victor Nijegorodov
-
April 17th, 2019, 03:13 AM
#3
Re: CMFCToolTipCtrl in CView
Hi Victor, and thank you for your post. There is a small problem regarding this example, this one is showing the tooltip for a rectangle who is already setup during creation, and in my case the tooltip should be visible only when the mouse pointer is hovering certain rectangles inside of my control, control which is spread over entire CMyView ...
-
April 17th, 2019, 03:23 AM
#4
Re: CMFCToolTipCtrl in CView
Originally Posted by mesajflaviu
Hi Victor, and thank you for your post. There is a small problem regarding this example, this one is showing the tooltip for a rectangle who is already setup during creation, and in my case the tooltip should be visible only when the mouse pointer is hovering certain rectangles inside of my control, control which is spread over entire CMyView ...
You could update tooltip data after moving/resizing your control. Just use TTM_SETTOOLINFO message!
Victor Nijegorodov
-
April 17th, 2019, 04:34 AM
#5
Re: CMFCToolTipCtrl in CView
Originally Posted by VictorN
You could update tooltip data after moving/resizing your control. Just use TTM_SETTOOLINFO message!
Ok, I'll try.
-
April 17th, 2019, 05:36 AM
#6
Re: CMFCToolTipCtrl in CView
BTW, you could use MFC class CToolTipCtrl (or CMFCToolTipCtrl) and its methods like CToolTipCtrl::AddTool, CToolTipCtrl::SetToolRect rather than directly sending TTM_... messages.
See https://docs.microsoft.com/en-us/cpp...s?view=vs-2019
Victor Nijegorodov
-
April 17th, 2019, 05:47 AM
#7
Re: CMFCToolTipCtrl in CView
Yes, but that rectangles are changing dynamically, so I guess this is the long road to achieve the task ... I have in CMyCtrl a HitTest(CPoint pt) method which return me an item ID ... I guess sending TTM_ messages will be more suitable ... but I don't know if I could use CMFCToolTipCtrl with these messages (TTM_). I am studying this issue ...
-
April 18th, 2019, 03:27 AM
#8
Re: CMFCToolTipCtrl in CView
Originally Posted by VictorN
You are right, I think I can use CMFCToolTipCtrl with AddTool/SetToolRect methods ...
Thank you.
-
April 18th, 2019, 03:40 AM
#9
Re: CMFCToolTipCtrl in CView
You are welcome!
Victor Nijegorodov
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|