Creating the Main Window

An application requires a main window to process messages and user input. This window is also the parent for all top-level windows created in the application. WinMain is where the main window is created and the message processing loop resides. A "window class" is first registered with the RegisterClassEx function. After the new class is registered, the main window can be created. Listing 3.1 shows what a basic WinMain function should look like and how the class is registered. Figure 3.1 shows the main window that is created and points out the elements of a window.

Figure 3.1. Elements of a window.

Code Listing 3.1. WinMain ...

Get Microsoft Windows 2000 API SuperBible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.