Rubber Band crecttracker usage experience

Source: Internet
Author: User

The crecttracker is called a "rubber band". It is the basis for further operations by selecting an object in the window editing. There are two ways to use rubber bands: 1. Hand-written rubber bands, which are well controlled in the program. 2. Use the crecttracker system class. Here I will introduce the use of crecttracker. For detailed parameters and usage of crecttracker, refer to csdn. I mainly introduce the usage of basic programs.

First, create a new member variable in the xxxview class:

CRectTracker m_tracker;

Second, set the attribute of the rubber band in the constructor of the xxxview class.

m_tracker.m_nStyle =CRectTracker::resizeInside|CRectTracker::dottedLine;  m_tracker.m_rect = CRect(-1, -1, -1, -1);

M_nstyle is the rubber band type. The specific types include:

Crecttracker: solidlineUse a solid line for the rectangle border.

Crecttracker: dottedlineUse a dotted line for the rectangle border.

Crecttracker: hatchedborderUse a hatched pattern for the rectangle border.

Crecttracker: resizeinsideResize handles located inside the rectangle.

Crecttracker: resizeoutsideResize handles located outside the rectangle.

Crecttracker: hatchinsideHatched pattern covers the entire rectangle.

M_rect sets the size of the initial rubber band (rectangle). Because I need to select an object based on the mouse in the program, the initial value is (-1,-1,-1,-1) invisible.

After the initial work last night, to get a rubber band in the program, you just need to respond to the left-click event onlbuttondown (uint nflags, cpoint point ). The Code is as follows:

// For this code, refer to int nin = m_tracker.hittest (point) written by a high-end user. // you can find out where the IF (nin <0) is located. // It is not in the quadrilateral area; {m_tracker.m_rect.setrectempty (); invalidate ();} else // In the quadrilateral area: {cclientdc DC (this); m_tracker.draw (& DC); m_tracker.track (this, point, true ); // track () is the most attractive function in crecttracker. It always changes the caller's m_rect; onpreparedc (& DC); cpoint pt_end; // The following Code considers scrollview and records the logical location of coordinates getcursorpos (& pt_end); rect. right = pt_end.x; rect. bottom = pt_end.y; screentoclient (& rect); pt_end.x = rect. right; pt_end.y = rect. bottom; If (pt_end! = M_pt) // manually call lbuttonup; in fact, you can also complete the rubber band movement without calling. However, my program needs to continue to process sendmessage (wm_lbuttonup); invalidate ();}

In response to the wm_lbuttonup mouse release event, you can add the code you want to process. In this way, the crecttracker class can be fully used.

 

 

We recommend a more detailed example here.

Http://www.vckbase.com/vckbase/vckbase10/vc/nonctrls/misc_21/1021002.htm

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.