Use of crecttracker in cscrollview

Source: Internet
Author: User

Http://topic.csdn.net/u/20080625/13/cf92a220-d2a9-4f05-ae53-7acce4dd84dc.html

O (success _ success) O... Thank you.

At first, I did what you said. If I didn't succeed, you said, "These two sentences are superfluous .." Let me remove all your rect statements.

Okay, let's close the post. Thank you, but I have to clarify the problem solution first:
Step 1: add the Class header file
Crecttracker m_tracker;
Crect m_recttrack; // at that time, only the mxm324 renxiong said that the two sentences can be avoided. The key is "rect is a member variable" ==!

Step 2: Initialize In the constructor
Ctrackerview: ctrackerview ()
{
M_recttracker.setrect (100,100,200,200); // initialization size
M_tracker.m_nstyle = crecttracker: solidline inclucrecttracker: resizeinside; // you can specify a border style.
}

Step 3: draw it in the ondraw Function
Void ctrackerview: ondraw (CDC * PDC)
{
Ctrackerdoc * pdoc = getdocument ();
Assert_valid (pdoc );
If (! Pdoc)
Return;

Cbrush brush (RGB (192,192,192 ));
PDC-> SelectObject (& brush );

/////////// Mxm324 the following two sentences can be commented out, but I found that,
/// // The second sentence is required. Otherwise, the rectangle cannot be drawn.
PDC-> rectangle (m_recttracker );
M_tracker.m_rect = m_recttracker;

PDC-> lptodp (& m_tracker.m_rect );
M_tracker.draw (PDC );
}
 
Step 4: Change the onlbuttondown Function
Void ctrackerview: onlbuttondown (uint nflags, cpoint point)
{
Cclientdc DC (this );
M_tracker.track (this, point );
M_recttracker = m_tracker.m_rect;
Onpreparedc (& DC );
DC. dptolp (& m_recttracker );
This-> invalidate (true );

Cscrollview: onlbuttondown (nflags, point );
}
 
Step 5: Set the cursor
Bool ctrackerview: onsetcursor (cwnd * pwnd, uint nhittest, uint message)
{
If (pwnd = This & m_tracker.setcursor (this, nhittest) // Changes the cursor when the cursor enters the box range.
Return true;
Return cscrollview: onsetcursor (pwnd, nhittest, message );
}

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.