One-day training of MFC-Basic Drawing operations

Source: Internet
Author: User
Tags transparent image

Direct Entry focus:

I. Methods and differences for obtaining device context HDC

1. Basic Windows HDC operations

HDC _ HDC =: getdc (m_hwnd); // assume that m_hwnd is valid.

...

: Releasedc (m_hwnd, _ HDC );

2. cview-based HDC operations

HDC _ HDC = getdc ();

...

Releasedc (_ HDC );

3. CDC operations on MFC

CDC * _ CDC = getdc ();

...

Releasedc (_ CDC );

4. cclientdc operations on MFC: the constructor of cclientdc directly obtains the HDC handle; The Destructor is released, so you don't have to worry about HDC.

Cclientdc _ CCDC (m_hwnd );

...

Releasedc (_ CCDC );

5. Obtain the parent window of 4

Cclientdc _ CCDC (getparentdc ());

...

Releasedc (_ CCDC );

6. Window cwindowdc operations

Cwindowdc _ windc (This/m_hwnd/getparentdc ()/getdesktopwindow ());

...

Releasedc (_ windc );

 

Ii. Operations on paint brushes, paint brushes, and bitmap

1. Paint Brush

Cpen pen (Ps_solid, 1, RGB (255, 0, 0));

... Remember to select the device and the last logical brush.

2. Image painter

(1) normal painter

Cbrush brush (RGB (255, 0, 0 ));

....

(2) bitmap painter

Cbitmap bitmap;

Bitmap. loadbitmap (ID );

Cbrush brush (& Bitmap );

....

(3) transparent image brush

Cbrush * Brush = fromhandle (hbrush) getstockobject (null_brush ));

...

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.