Game Development Reference
In-Depth Information
Note: To avoid confusion, we use a capital W to refer to Windows
the OS, and we use a lowercase w to refer to a particular window run-
ning in Windows.
Overview
As the name suggests, one of the primary themes of Windows pro-
gramming is programming windows. Many of the components of a
Windows application are windows, such as the main application window,
menus, toolbars, scroll bars, buttons, and other dialog controls. There-
fore, a Windows application typically consists of several windows.
These next few subsections provide a concise overview of Windows
programming concepts that we should be familiar with before beginning
a more complete discussion.
Resources
In Windows, several applications can run concurrently. Therefore, hard-
ware resources such as CPU cycles, memory, and even the monitor
screen must be shared among multiple applications. In order to prevent
chaos from ensuing due to several applications accessing/modifying
resources without any organization, Windows applications do not have
direct access to hardware. One of the main jobs of Windows is to man-
age the presently instantiated applications and handle the distribution
of resources among them. Thus, in order for our application to do
something that might affect another running application, it must go
through Windows. For example, to display a window, you must call
ShowWindow ; you cannot write to video memory directly.
Events, the Message Queue, Messages, and the
Message Loop
A Windows application follows an event-driven programming model .
Typically, a Windows application sits and waits (an application can per-
form idle processing—that is, perform a certain task when no events
are occurring) for something to happen—an event . An event can be gen-
erated in a number of ways; some common examples are keypresses,
mouse clicks, and when a window is created, resized, moved, closed,
minimized, maximized, or becomes visible.
When an event occurs, Windows sends a message to the application
for which the event occurred and adds the message to the application's
message queue , which is simply a priority queue that stores messages
Search WWH ::




Custom Search