Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to use Class CRectTracker in ON_WM_MBUTTONDOWN?

Posted on 2002-03-28
5
Medium Priority
?
730 Views
Last Modified: 2013-11-20
At first look at the code:
void CTrackerView::OnMButtonDown(UINT nFlags, CPoint point)
{
        ...
        CRectTracker tracker;
     if (tracker.TrackRubberBand(this, 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.
0
Comment
Question by:Gempin
  • 3
  • 2
5 Comments
 
LVL 1

Expert Comment

by:jemax
ID: 6907781
Hi,

you have the CRectTracker source in your "Program Files\Microsoft Visual Studio\VC98\MFC\SRC\TRCKRECT.CPP"

TrackRubberBand() calls TrackHandle (), that has its own message loop, and there is no handling for WM_MBUTTONUP :(

HTH,
jemax


0
 

Author Comment

by:Gempin
ID: 6911758
Any other comments?
0
 
LVL 1

Accepted Solution

by:
jemax earned 300 total points
ID: 6912896
Hi,

I can propose two options:
1)
Derive your own class from CRectTracker override TrackHandle() and add handling for WM_MBUTTONUP
2)
void CTrackerView::OnMButtonUp(UINT nFlags, CPoint point)
{
    PostMessage (WM_LBUTTONUP,0,0);
}
CRectTracker's internal message loop will get & handle it, so no side effects. The only issue could be, if you have already some code in your CTrackerView::OnMButtonUp, you will need to add a flag to determine to send WM_LBUTTONUP or not.

HTH,
jemax
0
 
LVL 1

Expert Comment

by:jemax
ID: 6912930
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.
0
 

Author Comment

by:Gempin
ID: 6914739
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\TRCKRECT.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.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question