Windows API Reference

Comprehensive documentation for the Win32 API

Core Functions

CreateWindowEx

HWND CreateWindowEx(DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam);

Creates an overlapping, pop-up, or child window. It can be used to create the windows that are visible on the client area of the user's screen.

Parameters:
  • dwExStyle: Extended window styles.
  • lpClassName: Registered class name or atom.
  • lpWindowName: Window name.
  • dwStyle: Window styles.
  • x, y, nWidth, nHeight: Window position and dimensions.
  • hWndParent: Handle to the parent window.
  • hMenu: Handle to the menu.
  • hInstance: Handle to the instance.
  • lpParam: Pointer to window-creation data.
Return Value: If the function succeeds, the return value is a handle to the newly created window. If the function fails, the return value is NULL.
Remarks: This function also includes the functionality of the CreateWindow function.

GetMessage

BOOL GetMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax);

Retrieves messages from the calling thread's message queue.

Parameters:
  • lpMsg: Pointer to a MSG structure that receives message information.
  • hWnd: Handle to the window whose messages are to be retrieved.
  • wMsgFilterMin: Minimum message value.
  • wMsgFilterMax: Maximum message value.
Return Value: If the function retrieves a message other than WM_QUIT, the return value is nonzero. If the function retrieves the WM_QUIT message, the return value is zero.
Remarks: This is a fundamental function for the Windows message loop.

GDI Functions

CreateSolidBrush

HBRUSH CreateSolidBrush(COLORREF color);

Creates a logical brush that is solid with the specified color.

Parameters:
  • color: The red, green, blue (RGB) color for the brush.
Return Value: If the function succeeds, the return value is a handle to the newly created logical brush. If the function fails, the return value is NULL.
Remarks: Remember to delete the brush handle using DeleteObject when it is no longer needed.

Memory Management

HeapAlloc

LPVOID HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes);

Allocates a block of memory from a specified heap.

Parameters:
  • hHeap: Handle to the heap from which the memory will be allocated.
  • dwFlags: Flags that control the allocation.
  • dwBytes: The number of bytes to allocate.
Return Value: If the function succeeds, the return value is a pointer to the allocated memory block. If the function fails, the return value is NULL.
Remarks: Use HeapFree to release the allocated memory.