[00016]-[2015-09-05]-[00]-[window GDI Programming---device environment]

Source: Internet
Author: User

"Equipment Environment" DC (device context)
Here we need to understand a little bit of the difference between the Windows SDK and the MFC class wrapper drawing programming
Window SDK is purely using WINDOWAPI to implement programming with its own application-based framework
MFC combines C + + object-oriented programming with Windows's messaging mechanism in a way that uses a class encapsulation mechanism.

Window SDK drawing pays attention to handle operation so HDC hbrush Hbitmap and other types of variables are more commonly used
The variables of CDC Cbursh CBitmap in MFC are more common, but because MFC is encapsulated in the Windows API,
Only in the implementation of different forms, of course, the idea of programming also has a lot of advanced progress, in MFC can also be used WINDOWSSDK
In the form of GDI drawing operations.


This article focuses on the drawing operations and knowledge of the Windows SDK for the MFC class encapsulated drawing operations, which may later have the opportunity to write
"Get device Environment handle"
"1" uses the BeginPaint function and the EndPaint function when processing WM_PAINT messages
HDC = BeginPaint (hWnd, &ps);
.........
EndPaint (HWND, HDC);

"2" GetDC function ReleaseDC function
HDC = GetDC (HWND); The HWND device context is retrieved by the handle of the window, and if the value is NULL,GETDC, retrieves the entire screen of the device context.
........
ReleaseDC (HWND, HDC);

"3" GETWINDOWDC function ReleaseDC function
HDC = GETWINDOWDC (HWND);
.......
ReleaseDC (HWND, HDC);

"4" CreateDC function DeleteDC function
HDC = CreateDC (TEXT ("DISPLAY"), NULL, NULL, NULL),//can get the device environment handle for the current entire screen
.......
DELETEDC (HDC);

"5" CreateCompatibleDC (HDC) creates a memory device environment
Hdcmem = CreateCompatibleDC (HDC);
......
DeleteDC (HDCMEM)

"Get information about your device environment"
Ivalue = GetDeviceCaps (hdc, iIndex);//IIndex 29 identifiers

[00016]-[2015-09-05]-[00]-[window GDI Programming---device environment]

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.