Uppercase Identifiers
You'llnotice the use of quite a few uppercase identifiers in HELLOWIN.C. Theseidentifiers are defined in the
Windowsheader files. Several of these identifiers contain a two-letter or three-letterprefix followed by an
underscore:
CS_HREDRAW
DT_VCENTER
SND_FILENAME
CS_VREDRAW
IDC_ARROW
WM_CREATE
CW_USEDEFAULT
IDI_APPLICATION
WM_DESTROY
DT_CENTER
MB_ICONERROR
WM_PAINT
DT_SINGLELINE
SND_ASYNC
WS_OVERLAPPEDWINDOW
These aresimply numeric constants. The prefix indicates a general category to which theconstant belongs, as
indicated inthis table:
Prefix
Constant
CS
Class styleoption
CW
Createwindow option
DT
Draw textoption
IDI
ID numberfor an icon
IDC
ID numberfor a cursor
MB
Message boxoptions
SND
Sound option
WM
Windowmessage
WS
Window style
New Data Types
For example,the third and fourth parameters to WndProcare defined as WPARAM and LPARAM,respectively. The origin of these names requires a bit of history. When Windows was a 16-bit system, the third parameter toWndProcwas defined as a WORD, which was a 16-bit unsigned shortinteger, and thefourth parameter was defined as a LONG, which was a 32-bit signed long integer.That's the reason for the "W" and "L" prefixes on the word"PARAM." In the 32-bit versions of Windows, however, WPARAM isdefined as a UINT and LPARAM is defined as a LONG (which is still the C longdata type), so both parameters to the window procedure are 32-bit values. Thismay be a little confusing because the WORD data type is still defined as a16-bit unsigned shortinteger in Windows 98, so the "W" prefix to"PARAM" creates somewhat of a misnomer.
TheWndProcfunction returns a value of type LRESULT. That's simply defined as aLONG. The WinMainfunction is given atype of WINAPI (as is every Windows function call defined in the header files),and the WndProc function is given a type ofCALLBACK. Both these identifiers are defined as __stdcall, which refers to aspecial calling sequence for function calls that occur between Windows itselfand your application.
HELLOWINalso uses four data structures (which I'll discuss later in this chapter)defined in the Windows header files. These data structures are shown in thetable below.
Structure
Meaning
MSG
Messagestructure
WNDCLASS
Window classstructure
PAINTSTRUCT
Paintstructure
RECT
Rectanglestructure
Getting aHandle on Handles
Finally,there are three uppercase identifiers for various types of "handles":
Identifier
Meaning
HINSTANCE
Handle to an"instance"—the program itself
HWND
Handle to awindow
HDC
Handle to adevice context