(MFC Application series) simple operations on the path layer in the device description table (Lesson 3 ).

Source: Internet
Author: User

(MFC Application series) simple operations on the path layer in the device description table (Lesson 3 ).

There is also a path layer in the device description table. The path layer is to define the line in the customer area, and the line is within their respective territory. In MFC, you can use the CDC inpath of the CDC class to open a path layer in the device description table, and then use the drawing functions provided by the graphic device (GDI) for drawing operations, use EndPath to close the path layer after painting.

Crop area: it can be understood as a drawing area, and the size can be controlled by us. For single-document applications, the customer area is usually considered as a large crop area, but the crop area can also be limited to a small range in the customer area. The CDC class provides a SelectClipPath function to perform interoperability between the currently configured path layer and the existing cropping areas in the device description table in the specified mode. For example, if you want a part of the entire image to be different from other parts, you can place the image in a path layer, and then use SelectClipPath to set a mode, it allows the path layer to interoperate with the cropping area to achieve a special effect.
Void CDrawView: OnDraw (CDC * pDC) {CDrawDoc * pDoc = GetDocument (); ASSERT_VALID (pDoc); if (! PDoc) return; // TODO: add the drawing code CString str = L "path layer of the device description table"; CSize sz; pDC-> SetTextColor (RGB (255, 0, 0); // you can specify the color of the text to be drawn. pDC-> TextOutW (50,50, str); pDC-> TextOutW (10,150, L "Cropping Area in customer zone"); sz = pDC-> GetTextExtent (str ); // obtain the width and height occupied by the specified string displayed in the window pDC-> BeginPath (); // open the path layer // draw a rectangle on the path layer, the position, width, and height of the rectangle overwrite the str string. // The Rectangle function draws a Rectangle and fills the Rectangle with the current default white brush. This overwrites the str string drawn. However, drawing a rectangle in the path layer does not affect the previously drawn text. PDC-> Rectangle (50, 50, 50 + sz. cx, 50 + sz. cy); pDC-> EndPath (); // close the path layer // call SelectClipPath to perform interoperability between the currently set path layer and the existing cropping areas in the device description table in the // specified mode. pDC-> SelectClipPath (RGN_DIFF); // RGN_DIFF style: make the New Cropping Area contain the current cropping area, // exclude the current path layer area. // pDC-> SelectClipPath (RGN_AND ); // RGN_AND style: The New Cropping Area is the intersection of the current cropping area and // The current path layer. // draw the grid for (int I = 0; I <200; I + = 10) {pDC-> MoveTo (CPoint (0, I )); pDC-> LineTo (CPoint (200, I); pDC-> MoveTo (CPoint (I, 0); pDC-> LineTo (CPoint (I, 200 ));}}

......

 

Related Article

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.