Dal's Programming Course - Lesson 02 | ||||||||||||||||||||||||||||||||||||
Learn how to draw in a window. | ||||||||||||||||||||||||||||||||||||
|
In the old days of Windows, a programmer would draw into a window by using the "GDI". GDI stands
for the "Graphical Device Interface". It is still necessary to know a little bit about the GDI,
especially what a "DC" is. A DC is an abbreviation for "Device Context". The "context" in which
you draw is maintained by Windows. A context remembers stuff like what color you are drawing with,
how you want your lined joined (butted, rounded), what font you are using, and way more complicated
drawing attributes.
As you should be aware by now, almost all "things" that Windows manages for the programmer is done with "Handles". Handles are somewhat like C-pointers, except that you cannot "see" what they point to. Handles are really a token (actually an integer number) to hand back and forth to Windows so that Windows knows what item or construct that you are referring to. DCs are no different. A handle to a DC is called a "HDC". You must obtain an "HDC" from windows to do any drawing. In the new days of windows programming, the best way to draw directly in a window is to use the "Gdiplus" library. Gdiplus is a library that uses Object Oriented ("OO") methods. Before you can work with the library (after your program starts up) you must initialize it. Then, before you can do any drawing in a window, you must obtain a HDC, and pass it to an object of the Gdiplus library. Once these two tasks are accomplished, you can concentrate on using the objects from Gdiplus to do all your drawing. | ||||||||||||||||||||||||||||||||||||
| Materials for this Lesson: Download. | ||||||||||||||||||||||||||||||||||||
| Homework | ||||||||||||||||||||||||||||||||||||
|