Process Logging Process (arrow implementation, refresh screen)

Source: Internet
Author: User

3. Arrow implementation.

/////////////////////
// Draw arrows to encapsulate and call function implementation
Void cbuttontestdlg: arrowto (
CDC * PDC, // painter
Cpoint point, // The end Coordinate
Int npenstyle, // line style
Int npenwidth, // line width
Colorref color, // color
Int nwidth, // triangle bottom side width
Float ftheta, // triangle top angle
Bool bfill // whether to fill the color
)
{
Cpen * poldpen;
Cpen pen (npenstyle, npenwidth, color );
Poldpen = PDC-> SelectObject (& pen );

Cbrush Br, * pbrold;
BR. createsolidbrush (color );
Pbrold = PDC-> SelectObject (& Br );

// Start plotting
Point pfrom;
Point pbase;
Point aptpoly [3];
Float vecline [2];
Float vecleft [2];
Float flength;
Float th;
Float ta;

// Get from point
Movetoex (* PDC, 0, 0, & pfrom );

// Set to Point
Aptpoly [0]. x = point. X;
Aptpoly [0]. Y = point. Y;

// Build the line vector
Vecline [0] = (float) aptpoly [0]. X-pfrom. X;
Vecline [1] = (float) aptpoly [0]. Y-pfrom. Y;

// Build the arrow base vector-normal to the line
Vecleft [0] =-vecline [1];
Vecleft [1] = vecline [0];

// Setup length parameters
Flength = (float) SQRT (vecline [0] * vecline [0] + vecline [1] * vecline [1]);
If (flength <0.1)
{
Flength = 0.1f;
}
Th = nwidth/(2.0f * flength );
Ta = nwidth/(2.0f * (TANF (ftheta)/2.0f) * flength );

// Find the base of the arrow
Pbase. x = (INT) (aptpoly [0]. x +-TA * vecline [0]);
Pbase. Y = (INT) (aptpoly [0]. Y +-TA * vecline [1]);

// Build the points on the sides of the arrow
Aptpoly [1]. x = (INT) (pbase. x + Th * vecleft [0]);
Aptpoly [1]. Y = (INT) (pbase. Y + Th * vecleft [1]);
Aptpoly [2]. x = (INT) (pbase. x +-th * vecleft [0]);
Aptpoly [2]. Y = (INT) (pbase. Y +-th * vecleft [1]);

Movetoex (* PDC, pfrom. X, pfrom. Y, null );

// Draw we're fillin '...
If (bfill ){
Lineto (* PDC, aptpoly [0]. X, aptpoly [0]. y );
Polygon (* PDC, aptpoly, 3); // draw an entity triangle
}
//... Or even Jes chillin '...
Else
{
Lineto (* PDC, pbase. X, pbase. y );
Lineto (* PDC, aptpoly [1]. X, aptpoly [1]. y );
Lineto (* PDC, aptpoly [0]. X, aptpoly [0]. y );
Lineto (* PDC, aptpoly [2]. X, aptpoly [2]. y );
Lineto (* PDC, pbase. X, pbase. y );
Movetoex (* PDC, aptpoly [0]. X, aptpoly [0]. Y, null );
}
// End the drawing

PDC-> SelectObject (poldpen );
PDC-> SelectObject (pbrold );
}

/// // Call:
DC. moveTo (points [0]. X, points [0]. y );
Arrowto (& DC, points [1], ps_solid, 1, RGB (0, 0), 10, 45, false );

2. Refresh the screen.

Dialog attribute: Set clip children to true. This indicates editing the subwindow when creating a dialog box,
That is, when invalidate (); is called, The Child window is not repainted. It can be ensured that the interface will not flash when invalidate.

Void cbuttontestdlg: onpaint ()
{
If (isiconic ())
{
///....
}
Else
{
Invalidate (); // The value must be invalidate, followed by cpaintdc DC (this );
Cpaintdc DC (this); // device context used for plotting

Cpoint points [2];
Getlinepoints (rfmsstepbutton *) getdlgitem (124), (rfmsstepbutton *) getdlgitem (125), points );

DC. moveTo (points [0]. X, points [0]. y );
Arrowto (& DC, points [1], ps_solid, 1, RGB (0, 0), 10, 45, false );

Getlinepoints (rfmsstepbutton *) getdlgitem (123), (rfmsstepbutton *) getdlgitem (125), points );
DC. moveTo (points [0]. X, points [0]. y );
Arrowto (& DC, points [1], ps_solid, 1, RGB (0, 0), 10, 45, true );

Cdialog: onpaint ();
}
}

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.