Hello, world! — Win32
This program demonstrates the basics of programming for Microsoft Windows, simply creating a new window and displaying the text "Hello, world!" inside it. Compare this with the standard C "Hello, world!" program to see how much more code we need for a basic Windows application.
Programming Issues
A Win32 program has two important functions:
- A WinMain() function, our entry point. Windows
programs do not have a main() function like
standard C programs do. WinMain() is reponsible for the following
things:
- Creating a new window class, a template for our application's main window.
- Registering that class with Windows, so we can create a new window based on it.
- Creating our main window based on our new window class.
- Displaying that window on the screen
- Retrieving messages from our application's message queue, and passing them to our window procedure.
- Exiting when we receive a WM_QUIT message.
- A WndProc() function. This is where our application actually does things. A Windows program is event-driven, so our WndProc() function responds only when a message is received, and it's actions will depend upon what type of message that is. Any messages we do not explicitly handle are passed to a default window procedure function, saving us a lot of effort.