The Simplest Windows Program |
| Before you can even begin thinking about programming in Windows, you have to be able to understand how this simple program works.
|
The Generic Win32 Program |
This program usesthe basic set of classes that encapsulate the Windows API. - Controller: The bridge between Window Procedure and Object Oriented world.
- View: Encapsulates the output of a Windows program.
- Canvas: Encapsulated various Device Contexts and things you can do with them.
- Model: The worker and the brain of your program. Doesn't deal with Windows at all.
|
Windows Controls |
| Controls can be added to the main Window or to any dialog box in your program. Controls are best picked and positioned using a graphical resource editor. Such an editor will also let you pick names or symbolic id's for your controls. You will then use these id's to identify the controls in your program.
|
Dialog Box Application |
| The main window of a program doesn't have to be a resizable general purpose window. Many small applications work better in a dialog box format. The obvious advantage of such an approach is that you can use a resource editor to arrange all your controls on the surface of the box.
|
Dialog Boxes |
| Dialog box is for a Windows program what a function call is for a C program. First, a Windows programs passes some data to the dialog box in order to initialize it. Next, the dialog box solicits information from the user. When the user decides that the program's curiosity has been satisfied, he or she clicks the OK button. The new data is then returned back to the program.
|
Device Context |
| To paint, draw or print in a window you need a device context, DC for short. A DC is a resource that you borrow from Windows and you're supposed to return it immediately after you're done.
|
Pens and Brushes |
| Like a painter, you will need pens and brushes to create artwork on your canvas. When you call Canvas::Line or Canvas::Rectangle, Windows uses the currently attached pen to draw the lines and the currently attached brush to fill the insides of the shapes.
|
Threads and Active Objects |
| Multitasking is one of the most difficult aspects of programming. It makes it even more important to provide a simple set of abstractions and to encapsulate it in a nice object-oriented shell.
|
File Watcher |
| Have you ever wondered how the Explorer knows that it should update its display because a file has been added or removed from a folder by some external application? Wonder no more because, with the use of our Active Object, we can do the same and more.
|
COM and Shell |
| COM programming is so difficult that you shouldn't even try it without MFC. Right or wrong? Absolutely wrong! Granted, OLE and its successor COM have the elegance of a figure-skating hippopotamus. But putting MFC on top of COM is like dressing the hippo in an oversized clown suit.
|
OLE's Fatal Flaw |
| You might have heard or read critical opinions about OLE. Programmers mostly complain about the complex system of reference counting and the lack of support for inheritance.
|
Smart OLE |
| First of all, you have to tell the worldthat you're going to use OLE. Here's a little class that will do it for you. Just embed an object of this class in some high-level object that's constructed before you do anything with OLE and destroyed after you're done with OLE.
|
OLE Automation |
|
|
Splitter |
| A splitter bar is a useful control that is not part of the Windows' common bag of controls. How difficult is it to implement it? Not so difficult, as it turns out, once you know the basics of Windows API.
|