Visual C + + PRINT programming Technology-programming basics

Source: Internet
Author: User

Background: Before Windows was generated, the operating system (such as DOS, etc.) did not provide a printer driver that supports image processing, so that programmers can print out images and have to use the printer

Write your own device drivers, resulting in a large number of unnecessary duplication of development.

With the advent of Windows operating system systems, the device environment model provided allows developers to make devices such as displays, printers, and plotters a two-dimensional drawing interface, and

The setup driver has been completed by the manufacturer, and the developer no longer has to write the print driver. The API interface provided by the Windows operating system supports image printing, but for developers to

Speaking, printing is still a difficult programming task. Fortunately, the MFC Library 6.0 version greatly simplifies the printing implementation and adds the ability to print preview, making it easy for developers to develop

A nice print and preview feature comes in.

Two important concepts, "device environment" and "Mapping Mode"

1. Equipment Environment

The device environment itself is a GDI (Graphics device Interface) object. Each C + + device object has a related device environment, which is identified by a 32-bit HDC type handle. GDI is a set of interface functions in a Windows core DLL. These functions are on top of the hardware driver, and when the application calls these functions, they then invoke the interface functions provided by the driver.

The MFC 6.0 release provides a large number of device environment types. The base class CDC encapsulates all the member functions required by the drawing, which provide a large number of drawing, coordinate mapping, cropping functions.

In addition to the CMetaFileDC class, derived classes differ only in their constructors and destructors.

CDC class: With MFC programming, all device environments are not CDC or derive from CDC.

The CDC class has a handle on two underlying GDI objects:

M_HDC: GDI object related to M_HDC handles all output streams of the drawing function;

M_HATTRIBDC: GDI objects related to the M_HATTRIBDC handle handle all operations related to drawing properties, such as color properties, drawing modes.

Each window, control (including universal controls and ActiveX controls) has a device environment variable that overrides a window or control. We can either get the Windows Desktop's window device environment, draw on the desktop, or use the device environment of any one of the controls to draw the control or improve the appearance of the control.

Gets the device environment object pointer call: GetDC () function. After you construct a CDC object and finish processing it, be sure to use the ReleaseDC () function to release the CDC object.

Note: The application framework automatically controls the removal of the CDC object passed through the OnDraw () function.

Visual C + + PRINT programming Technology-programming basics

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.