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.

GUI Programming Lectures

Weeks 1 and 2


Simple Types

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.

General Data Types

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.

Code

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]


Remaining Code Examples


Last modified:  Fri Jan 22 09:06:16 EST 2010

Back to CTEC1638