Introduction to Windows Client Development (III)

Source: Internet
Author: User

In a previous article, I briefly outlined the knowledge of the interface library. Since it is related to the interface, there must be a lot of content about drawing. For Windows development, the class of APIs used by interface drawing is called "GDI".

GDI this thing can have history, but we will not go to traced source. First of all, I can not mundane to introduce its full name: "Graphic device Interface", that is, "graphics Device Interface", from this name we can roughly absorb the information is: GDI is a graphics-related interface, right, that's it!

Let's take a look at what the GDI functions roughly include, which categories, because my series of articles are practical and I want to provide some shortcuts to the developers who want to enter windows, so I don't make too many theoretical statements, It is intended to focus on how the API is used and how some of the basic features should be implemented, including, of course, the pits that may be encountered during the actual development process, how to avoid them, how to improve drawing efficiency, and how to make the various behaviors of the interface smoother.

First of all, to introduce: "DC", DC is "device context", beginners do not go to hard key the literal meaning of the word to explain, you need to know that the so-called device context is actually an abstraction, then what does it abstract? The answer is: The device context abstracts out the drawing device, including the printer, the monitor and so on, for our Windows developers, we do not need to pay attention to the specific drawing device how to communicate, how to call the lowest interface to complex on the device to draw, with the device context, everything becomes transparent, efficient, Simple. Of course, there's a higher level of abstraction on top of GDI, and it's easier to draw, but for our Windows C + + developers, that's not something we need to know right away. All of our drawing behavior on the drawing device is done through the device context.

The representation of a DC in a Windows program is something called a "device context handle", which means that HDC,HDC is a data type in code, which is a 32-bit value. We can get an abstraction of the drawing device by creating a device context handle, or an object of the HDC type, after which all the drawing operations are applied to the HDC, which is the corresponding device. In other words, if your HDC represents your current display area, then call a GDI function to draw a line that will appear on your screen. And if HDC represents a printer, this line will be drawn to the printer, so is it understood? I use two paragraphs to explain DC and HDC because this is the basis for GDI drawing, and it is impossible to do anything without DCs and Hdc,gdi.

After introducing the basics of device context, I want to talk about GDI objects, that is, what are GDI objects? What types of GDI objects are there about? What is the purpose of each type of GDI object?

I do not want to write this article chatty, so I only list the common GDI objects, such as:

Bitmap

A Bitmap object that represents a pair of bitmaps, in-memory organization is actually a binary matrix that identifies the location of each point of the bitmap and the corresponding color. The bitmap in the code is represented by the HBITMAP, the accession graph handle.

Font

The Font object that represents the font properties in the device context, what font? How big is the font? Is it underlined? Is bold ". The code is represented by a hfont, font handle.

Brush

The Brush object, which represents the fill color of the drawing, is represented in the code with Hbrush.

Pen

A Brush object that represents the color of the line drawing and the color of the font, expressed in Hpen.

We can see that the so-called GDI objects, which are actually some of the properties or parameters of the device context, determine the final drawing effect.

After introducing these basic concepts, the next article I will introduce the basic GDI functions of the use of a simple introduction, of course, or those commonly used, I would also say a cut with these functions common problems, how to cope with and avoid these problems.

Ok!

Introduction to Windows Client Development (III)

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.