MSDN Community

Win32 UI Control API Reference

This section provides comprehensive documentation for the Win32 API functions, structures, messages, and common controls used for building graphical user interfaces in Windows applications. Understanding these elements is fundamental to developing robust and interactive Windows desktop applications.

The Win32 API offers a rich set of tools for creating windows, dialog boxes, menus, buttons, edit fields, and other standard UI elements. It allows for detailed control over the appearance, behavior, and interaction of these components.

Key UI Control Functions

The following are some of the most commonly used Win32 API functions for managing UI controls:

Function Name Description
CreateWindowEx Creates an overlapping, top-level window or a child window.
DestroyWindow Destroys the specified window.
GetDlgItem Retrieves a handle to a specified control in a dialog box.
SendMessage Sends the specified message to a window or windows.
PostMessage Places a message in the message queue of the specified thread and returns without waiting for the thread to process the message.
SetWindowText Changes the text of the specified window's title bar (if it has one) and its class‐name entry in the window list.
GetWindowText Copies the text of the specified window's title bar (if it has one) to the specified buffer.

Important UI Structures

These structures are often used in conjunction with UI functions to pass or receive information:

Structure Name Description
RECT Defines a rectangle.
POINT Defines a point.
MSG Contains message information from a thread's message queue.
WNDCLASS Defines the window class attributes that are registered by the RegisterClass function.

Common UI Control Messages

Applications use Windows messages to communicate with controls and to receive notifications from them. Some common messages include:

Message Name Control Type Description
WM_COMMAND All Sent when a control is activated or when a menu item is selected.
WM_GETTEXT Edit, Static, Button, Combobox, Listbox Requests the text associated with a control.
WM_SETTEXT Edit, Static, Button, Combobox, Listbox Sets the text of a control.
WM_CLICK Button Sent when a button is clicked (often via WM_COMMAND).
WM_CHAR Edit, Combobox, Listbox Sent when a character key is pressed.

Commonly Used Controls

The Win32 API provides a set of standard controls that can be used to build user interfaces:

  • Buttons: Standard buttons, checkbox buttons, radio buttons.
  • Edit Controls: Single-line and multi-line text input fields.
  • Static Controls: Labels, bitmaps, and group boxes.
  • List Boxes: Display a list of strings from which the user can select one or more items.
  • Combo Boxes: A combination of a list box and an edit control, allowing the user to either type an item or select one from the list.
  • Scroll Bars: Provide a means for navigating through information that is too large to be displayed entirely.
  • Menus: Provide commands to the user.
  • Dialog Boxes: Independent windows that typically contain controls for specific tasks.

For more advanced UI elements, consider exploring the Common Controls Library (ComCtl32.dll), which offers features like tree views, list views, progress bars, and tab controls.