This article describes the following:
Questions about GUI Programming
Creating a Window Object
Handling Events and Notifications
Forms and controls
This article uses the following techniques:
Win32 API, C + +
Directory
Both native and portable
No windows.h
Working with each window
Intuitive code
Controls and forms
Form programming
Working with Forms
Detach from the old ID
Events and Notifications
menus, shortcuts, and similar items
tab controls and Forms
Adjust size
Set with Visual Studio 2005
Implementation behavior
The problem with GUI programming using C + + is that the level of most libraries is too low to put too much burden on programmers. These libraries rely on structures similar to the C language, or their wrapper classes cannot hide enough complexity. Also, they don't make event programming simple enough, forcing you to understand the basics of WM_ messages.
In this article, I'll introduce you to egui++, a C + + library I wrote to provide you (client programmers) with a high-level interface for handling GUI applications. It can hide complexity, making event programming fairly straightforward by completely hiding the knowledge of WM_ messages. You don't have to deal with any original structure like C, and you always just need to work with classes. In summary, egui++ client code is easy to read and easy to write.
egui++ only runs in Windows®. I really don't trust cross-platform GUI applications unless they are not important (just simpler test frameworks, prototypes) or just for teaching purposes. More importantly, I really think we should make good use of all the features provided by the underlying operating system. Windows XP and Windows vista® do offer a number of features.
Both native and portable
For those who expect to use CLR code, you have mastered C + +. That's a good platform, so there's no need to improve it. The rest of you are eager to use a good library for Windows 2000 and the updated operating system to raw machine Windows code, please continue reading. You will be satisfied with the results; The library leverages your target operating system and is intuitive to use. And you don't need to use the Microsoft®.net Framework at all. The code you write is used like C + + code. In addition, you will write code that is not specific to the Visual C + + compiler. If you prefer, you can use g++ (GNU C + + compiler) 4.1 to compile your own code. Basically, if you encapsulate Win32®api, there's nothing to prevent you from writing portable code.
That is, for important GUIs, you need a good IDE, such as visual studio®2005 or Visual Studio 2008 Express Edition. I've tuned my library to integrate with the Visual Studio Express and newer versions to provide you with a better GUI experience. What I really value is code completion to ensure that the IDE tries to help when you create a new GUI class or extend an existing GUI class.
I want to enjoy the process of writing GUI applications. Therefore, I created the egui++ to make GUI code easy to read and write. For example, I have implemented code completion in all possible places. This way, GUI programming is safe (if there is an error, I will catch it at compile time whenever possible; otherwise, a Run-time exception will be thrown). egui++ is appropriate for the resource editor (which is integrated with the updated version of Visual Studio 2005 and the Resource Editor).