CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2021

    MFC CRectTracker


    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.
    CRect rect2;
    CPoint p;
    CWnd* pWnd = GetDlgItem(IDC_PICTURE_CALIBRATION); //This is the ID of CStatic that is the photo displayed 
    CRectTracker ROI = CRectTracker(rect2, CRectTracker::resizeOutside);
    pScreenDC = GetDC();
    ROI.Track(pWnd, GetCursorPos(&p), FALSE, NULL);

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Hanover Germany

    Re: MFC CRectTracker

    I never user this class and have no idea how and why should it be used.
    however, you could start with the Microsoft sample Tracker
    Victor Nijegorodov

  3. #3
    Join Date
    Oct 2021

    Re: MFC CRectTracker

    Thanks for the example.
    I have now managed to get a resizable rectangle on my application but I am facing another problem which is that the rectangle is behind the image so it can't be seen. Is there any way of moving the CRectTracker object to the front?

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

Click Here to Expand Forum to Full Width