Win32 API Structures
This section details the structures used within the Win32 API. Structures are composite data types that group related data items, often of different types, into a single unit. They are fundamental for passing complex information to and from Win32 functions.
RECT
The RECT
structure defines a rectangle by the coordinates of its upper-left and lower-right corners.
typedef struct _RECT {
LONG left;
LONG top;
LONG right;
LONG bottom;
} RECT;
left
: The x-coordinate of the rectangle's upper-left corner.top
: The y-coordinate of the rectangle's upper-left corner.right
: The x-coordinate of the rectangle's lower-right corner.bottom
: The y-coordinate of the rectangle's lower-right corner.
POINT
The POINT
structure defines a point in two-dimensional space (x-coordinate and y-coordinate).
typedef struct _POINT {
LONG x;
LONG y;
} POINT;
x
: The horizontal coordinate.y
: The vertical coordinate.
SIZE
The SIZE
structure specifies a Win32 application's size, in pixels, of a rectangle or a position, in the order cx
(width) and cy
(height).
typedef struct _SIZE {
LONG cx;
LONG cy;
} SIZE;
cx
: The width.cy
: The height.
MSG
The MSG
structure contains message information available from the application message queue.
typedef struct _MSG {
HWND hwnd;
UINT message;
WPARAM wParam;
LPARAM lParam;
DWORD time;
POINT pt;
} MSG;
hwnd
: Handle to the window that is to receive the message.message
: Type of the message.wParam
: Additional information about the message.lParam
: Additional information about the message.time
: Time at which the message was posted.pt
: Cursor position, in screen coordinates, at the time the message was posted.
See also: WNDCLASS.
WNDCLASS
The WNDCLASS
structure defines the window class characteristics that are registered by the RegisterClass function.
typedef struct _WNDCLASS {
UINT style;
WNDPROC lpfnWndProc;
int cbClsExtra;
int cbWndExtra;
HINSTANCE hInstance;
HICON hIcon;
HCURSOR hCursor;
HBRUSH hbrBackground;
LPCTSTR lpszMenuName;
LPCTSTR lpszClassName;
} WNDCLASS, *LPWNDCLASS;
style
: The storage class and extended styles for the class.lpfnWndProc
: Pointer to the window procedure.cbClsExtra
: Number of extra bytes required by class.cbWndExtra
: Number of extra bytes required per window.hInstance
: Handle to the instance of the application defining the window class.hIcon
: Handle to the class icon.hCursor
: Handle to the class cursor.hbrBackground
: Handle to the class background brush.lpszMenuName
: Pointer to a null-terminated string that specifies the resource name of the class menu.lpszClassName
: Pointer to a null-terminated string that specifies the name of the window class.
See also: MSG, RegisterClass.
CREATESTRUCT
The CREATESTRUCT
structure contains information about the window being created as a result of a CreateWindow or CreateWindowEx function call.
typedef struct _CREATESTRUCT {
LPVOID lpCreateParams;
HINSTANCE hInstance;
HMENU hMenu;
HWND hwndParent;
int cx;
int cy;
int x;
int y;
LONG style;
LPCTSTR lpszName;
LPCTSTR lpszClass;
DWORD dwExStyle;
} CREATESTRUCT, *LPCREATESTRUCT;
lpCreateParams
: Pointer to the value specified in thelpCreateParams
parameter of the CreateWindowEx function.hInstance
: Handle to the module creating the window.hMenu
: Handle to the menu of the window.hwndParent
: Handle to the owner window or creator.cx
: Width of the window.cy
: Height of the window.x
: Horizontal position of the window.y
: Vertical position of the window.style
: Window styles.lpszName
: Pointer to the window name.lpszClass
: Pointer to the window class name.dwExStyle
: Extended window styles.
BITMAP
The BITMAP
structure specifies the bitmap characteristics. It is used by the GetObject function.
typedef struct tagBITMAP {
LONG bmType;
LONG bmWidth;
LONG bmHeight;
LONG bmWidthBytes;
WORD bmPlanes;
WORD bmBitsPixel;
LPVOID bmBits;
} BITMAP, *PBITMAP, NEAR *NBMPTR, FAR *LPBITMAP;
bmType
: Specifies the bitmap type.bmWidth
: Specifies the bitmap width in bits.bmHeight
: Specifies the bitmap height in raster lines.bmWidthBytes
: Specifies the size, in bytes, of each scan line in the bitmap.bmPlanes
: Specifies the number of color planes.bmBitsPixel
: Specifies the number of bits used to define each color index.bmBits
: Pointer to the bitmap memory.
LOGFONT
The LOGFONT
structure contains the characteristics of a logical font—that is, the specification for a font that can be used to create a font with the graphics programming interface (GDI).
typedef struct tagLOGFONT {
LONG lfHeight;
LONG lfWidth;
LONG lfEscapement;
LONG lfOrientation;
LONG lfWeight;
BYTE lfItalic;
BYTE lfUnderline;
BYTE lfStrikeOut;
BYTE lfCharSet;
BYTE lfOutPrecision;
BYTE lfClipPrecision;
BYTE lfQuality;
BYTE lfPitchAndFamily;
TCHAR lfFaceName[LF_FACESIZE];
} LOGFONT;
This structure has many members controlling font properties such as height, width, escapement, orientation, weight, italic, underline, strikeout, character set, precision, quality, and face name.
SECURITY_ATTRIBUTES
The SECURITY_ATTRIBUTES
structure contains security descriptor information that is used when creating certain securable objects.
typedef struct _SECURITY_ATTRIBUTES {
DWORD nLength;
LPVOID lpSecurityDescriptor;
BOOL bInheritHandle;
} SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES;
nLength
: Size of this structure in bytes.lpSecurityDescriptor
: Pointer to a SECURITY_DESCRIPTOR structure that specifies the security of the object.bInheritHandle
: Specifies whether the handle can be inherited by child processes.
FILETIME
The FILETIME
structure is a 64-bit value that represents the number of 100-nanosecond intervals since January 1, 1601 (UTC).
typedef struct _FILETIME {
DWORD dwLowDateTime;
DWORD dwHighDateTime;
} FILETIME, *PFILETIME, *LPFILETIME;
dwLowDateTime
: Specifies the low-order part of the file time.dwHighDateTime
: Specifies the high-order part of the file time.
For a comprehensive list of Win32 API structures, please refer to the main index or use the search functionality.