-
October 29th, 2021, 10:43 AM
#1
MFC CRectTracker
Hi,
I am trying to develop a MFC application that lets a user upload a photo and display it, and then the user will select a rectangular region of this photo and get its coordinates in pixel values.
I am quite new to C++ (have mainly done C in the past) but I have managed to load and display the image, however I am a bit stuck on defining the region.
After some research I found that the CRectTracker Class probably will be able to achieve what I need, but I cannot seem to understand how it works from the Microsoft documentation provided.
As far as I can tell I need to use the CRectTracker::Track as the description says "Call this function to display the user interface for resizing the rectangle" but when I call it nothing happens (nothing appears on the application to suggest that I can resize any rectangle).
This is what I got so far, any help would be greatly appreciated.
Code:
CRect rect2;
CPoint p;
CWnd* pWnd = GetDlgItem(IDC_PICTURE_CALIBRATION); //This is the ID of CStatic that is the photo displayed
pWnd->GetWindowRect(&rect2);
ScreenToClient(&rect2);
CRectTracker ROI = CRectTracker(rect2, CRectTracker::resizeOutside);
pScreenDC = GetDC();
//ROI.Draw(pScreenDC);
ROI.Track(pWnd, GetCursorPos(&p), FALSE, NULL);
ReleaseDC(pScreenDC);
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
|