|
From: Laurs on 7 May 2008 04:54 Hi I need a piece of code to show each button enlarged, when the mouse is moving over a button, eventually delayed like the tooltip message. Both the enlarged button and the tooltip text must pop up. I use VC++9 (2008), mfc unmanaged. -- Laurs Laursen
From: foobar on 7 May 2008 07:17 To show tooltip message when mouse hovers over a button, you need to call EnableToolTips(TRUE) from its parent. In a dialog based application it is typically done inside OnInitDialog method. Also the dialog need to handle TTN_NEEDTEXT events. ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify) ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify) Finally the tooltip message string has to be passed to the MFC from your OnToolTipNotify handler method. I think MSDN has the example code for it. Regarding changing the button size, one way you can achieve this is by sending a special message to button's parent window and handling the message in the parent window to change the size of the button. This message can be sent to parent window when mouse enters the region occupied by button and also when mouse leave the button region. On May 7, 1:54 pm, Laurs <La...(a)discussions.microsoft.com> wrote: > Hi > I need a piece of code to show each button enlarged, when the mouse is > moving over a button, eventually delayed like the tooltip message. > Both the enlarged button and the tooltip text must pop up. > I use VC++9 (2008), mfc unmanaged. > -- > Laurs Laursen
From: Laurs on 7 May 2008 07:30 I allready handle the TTN_NEEDTEXT events, but how do I know when the mouse is in the region of the button. I have a virtual OnMouseMove(UINT nFlags, CPoint pnt) but I get no message when the mouse is in a toolbar. -- Laurs Laursen
From: Scott McPhillips [MVP] on 7 May 2008 08:46 "Laurs" <Laurs(a)discussions.microsoft.com> wrote in message news:22F374A4-B45A-4365-A1D7-1B27669CED24(a)microsoft.com... >I allready handle the TTN_NEEDTEXT events, but how do I know when the mouse > is in the region of the button. I have a virtual OnMouseMove(UINT nFlags, > CPoint pnt) but I get no message when the mouse is in a toolbar. When the mouse is in a toolbar the mouse messages go to the toolbar window. So I guess your OnMouseMove is in the wrong class. You need to subclass the toolbar, creating a member variable derived from CToolbar. In that class you can receive the mouse messages for the toolbar. -- Scott McPhillips [VC++ MVP]
From: foobar on 7 May 2008 09:02
Where is your OnMouseMove handler? If it is in your button class then as I understand, it should get executed when mouse enters the button region. To get mouse leave event you would need to handle WM_MOUSELEAVE message ON_MESSAGE(WM_MOUSELEAVE, OnMouseLeave) WM_MOUSELEAVE message won't be generated by default. We need to track mouse event for TME_LEAVE so that it gets generated. OnMouseMove handler can include code similar to following lines to let button receive MouseLeave event if (!m_bMouseTracking) { TRACKMOUSEEVENT mouseevent; mouseevent.cbSize = sizeof(TRACKMOUSEEVENT); mouseevent.dwFlags = TME_LEAVE; mouseevent.hwndTrack = this->m_hWnd; if (::_TrackMouseEvent(&mouseevent)) { m_bMouseTracking = TRUE; } } and inside OnMouseLeave method handler we set m_bMouseTracking back to FALSE so that next time mouse enters we again start tracking mouse event for its leave message. HTH On May 7, 4:30 pm, Laurs <La...(a)discussions.microsoft.com> wrote: > I allready handle the TTN_NEEDTEXT events, but how do I know when the mouse > is in the region of the button. I have a virtual OnMouseMove(UINT nFlags, > CPoint pnt) but I get no message when the mouse is in a toolbar. > > -- > Laurs Laursen |