This material has been collected from previous terms. Most code was compiled using Microsoft Visual Studio 6 (or even 5), so there may be some porting issues to Visual Studio 2005/2008.
A Win32 Skeleton
Naming Conventions
Looked at *all* the messages generated by Windows and delivered to your program.
Various simple data types define the size and meaning of parameters, return values, and members associated with the functions, messages, and structures of Microsoft Windows. The following table contains character, integer, and Boolean types; pointer types; and handles. The character, integer, and Boolean types are common to most C compilers. Many of the pointer-type names begin with a prefix of P or LP. A Windows-based application uses a handle to refer to a resource that has been loaded into memory. Windows provides access to these resources through internally maintained tables that contain individual entries for each handle.
| Typedef | Description |
|---|---|
| BOOL | Boolean variable (should be TRUE or FALSE). |
| BYTE | Byte (8 bits). |
| CHAR | Windows character. |
| COLORREF | Red, green, blue (RGB) color value (32 bits). |
| CONST | Variable whose value is to remain constant during execution. |
| DLGPROC | Pointer to an application-defined dialog box callback procedure. |
| DWORD | Doubleword (32 bits). |
| FLOAT | Floating-point variable. |
| HACCEL | Handle of an accelerator table. |
| HANDLE | Handle of an object. |
| HBITMAP | Handle of a bitmap. |
| HBRUSH | Handle of a brush. |
| HCURSOR | Handle of a cursor. |
| HDC | Handle of a device context (DC). |
| HFILE | Handle of a file. |
| HICON | Handle of an icon. |
| HINSTANCE | Handle of an instance. |
| HMENU | Handle of a menu. |
| HPEN | Handle of a pen. |
| HWND | Handle of a window. |
| LONG | 32-bit signed value. |
| LPARAM | 32-bit message parameter. |
| LPSTR | Pointer to a null-terminated Windows character string. |
| LPVOID | Pointer to any type. |
| PROC | Pointer to a callback function. |
| SHORT | Short integer. |
| UCHAR | Unsigned Windows character. |
| UINT | Unsigned integer. |
| ULONG | Unsigned long integer (32 bits). |
| USHORT | Unsigned short integer (16 bits). |
| VOID | Any type. |
| WNDPROC | Pointer to an application-defined window procedure. |
| WORD | Unsigned word (16 bits). |
| WPARAM | 32-bit message parameter. |
The following table summarizes the new standard types defined in WINDOWS.H. These types are polymorphic (they can contain different kinds of data) and are generally useful throughout applications. Other new types, handles, and function pointers also are introduced in other topics (listed in New Types and Macros). Also see Simple Types in the Win32 documentation.
| Typedef | Description |
|---|---|
| WINAPI | Use in place of FAR PASCAL in API declarations. If you are writing a DLL with exported API entry points, you can use this for your own APIs. |
| CALLBACK | Use in place of FAR PASCAL in application callback routines such as window procedures and dialog procedures. |
| LPCSTR | Same as LPSTR, except used for read-only string pointers. Defined as (const char FAR*). |
| UINT | Portable unsigned integer type whose size is determined by host environment (32 bits for Windows 95/NT/98/ME/2000/XP/2003). Synonym for unsigned int. Used in place of WORD except in the rare cases where a 16-bit unsigned quantity is desired even on 32-bit platforms. |
| LRESULT | Type used for return value of window procedures. |
| LPARAM | Type used for declaration of lParam, the fourth parameter of a windows procedure. |
| WPARAM | Type used for declaration of wParam, the third parameter of a windows procedure (a polymorphic data type). |
| LPVOID | Generic pointer type, equivalent to (void *). Should be used instead of LPSTR. |
Week 1 -- "Hello, Cruel World" in C, C++, and Win32. Win32 skeletons in C and C++. [810K, zipped]
Week 2 -- Message boxes, improved "Hello, Cruel World", menus and accelerators, Tic Tac Toe skeleton. [240K, zipped]
Week 3 -- Painting bitmaps. Using library functions. [945K, zipped]
Week 4 -- Painting
bitmaps. Handling WM_PAINT. Using
a virtual window. [580K, zipped]
globals.zip [16,071 bytes] — "The Art and Science of Using Global Variables Without Using Global Variables"TM — Notes
week05.zip [47,953 bytes] — Painting bitmaps; DLLs
week06.zip [39,968 bytes] — Dialog boxes, part 1
week07.zip [143,279 bytes] — Dialog boxes, part 2
week67.zip [59,205 bytes] — Dialog box essentials (parts 1 and 2)
week08.zip [3,157 bytes] — Preventing window resizing
week08a.zip [6,418 bytes] — Options dialog box
ttt2-dialog.zip [23,467 bytes] — Old Lab #2 dialog boxes
threads.zip [36,398 bytes] — Threads and synchronization — Notes
mtvwexample.zip [18,606 bytes] — Multithreaded, virtual window example
lab2parta.zip [16,685 bytes] — Old Lab #2 (first iteration)
lab2parta_dlg.zip [19,058 bytes] — Old Lab #2 (second iteration)
lab2parta_dlg_thread.zip [20,596 bytes] — Old Lab #2 (third iteration)