Gempin
asked on
How to use Class CRectTracker in ON_WM_MBUTTONDOWN?
At first look at the code:
void CTrackerView::OnMButtonDow n(UINT nFlags, CPoint point)
{
...
CRectTracker tracker;
if (tracker.TrackRubberBand(t his, point)
{
A(); // To do ON_WM_MBUTTONUP event while after the mouse midbutton is released
}
...
}
if these code is in OnLButtonDown, All is OK, but it's no way if it is moved into OnMButtonDown, CRectTracker can redraw the rectangle dynamically and perfectly when mouse pointer is moving on the view, but it can not know release event while the mouse midbutton is released.
How to get to the fuction A in codes? experts, help me! thanx.
void CTrackerView::OnMButtonDow
{
...
CRectTracker tracker;
if (tracker.TrackRubberBand(t
{
A(); // To do ON_WM_MBUTTONUP event while after the mouse midbutton is released
}
...
}
if these code is in OnLButtonDown, All is OK, but it's no way if it is moved into OnMButtonDown, CRectTracker can redraw the rectangle dynamically and perfectly when mouse pointer is moving on the view, but it can not know release event while the mouse midbutton is released.
How to get to the fuction A in codes? experts, help me! thanx.
ASKER
Any other comments?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
void CTrackerView::OnMButtonUp( UINT nFlags, CPoint point)
{
PostMessage (WM_LBUTTONUP, nFlags, MAKELONG(point.x, point.y));
}
will be much better, TrackHandle() use the coords.
void CTrackerView::OnMButtonUp(
{
PostMessage (WM_LBUTTONUP, nFlags, MAKELONG(point.x, point.y));
}
will be much better, TrackHandle() use the coords.
ASKER
O, jemax, thanks for your comments, your options is right, but I have solved this problem with own idea. My idea is following:
1)Modify MFC source in "Program Files\Microsoft Visual Studio\VC98\MFC\SRC\TRCKRE CT.CPP", add a WM_MButtonDown message in CRectTracker's internal message loop.(Maybe it's not necessary)
2)Add one line code in CTrackerView::OnMButtonUp:
void CTrackerView::OnMButtonUp( UINT nFlags, CPoint point)
{
ReleaseCapture();
}
I have inspected MFC class CRectTracker source, Because CRectTracker's internal message loop can not escape from SetCapture(), so add the line to release the capture,
It'll be OK. you can have a try.
Thanks for your comments again.
1)Modify MFC source in "Program Files\Microsoft Visual Studio\VC98\MFC\SRC\TRCKRE
2)Add one line code in CTrackerView::OnMButtonUp:
void CTrackerView::OnMButtonUp(
{
ReleaseCapture();
}
I have inspected MFC class CRectTracker source, Because CRectTracker's internal message loop can not escape from SetCapture(), so add the line to release the capture,
It'll be OK. you can have a try.
Thanks for your comments again.
you have the CRectTracker source in your "Program Files\Microsoft Visual Studio\VC98\MFC\SRC\TRCKRE
TrackRubberBand() calls TrackHandle (), that has its own message loop, and there is no handling for WM_MBUTTONUP :(
HTH,
jemax