Windows Core Functions
CreateWindowEx
Creates an overlapping window. It includes the extended window styles, class name, window name, styles, position and size, parent window, menu, and application-instance handle.
Syntax
LRESULT CreateWindowEx(
[in] DWORD dwExStyle,
[in, optional] LPCSTR lpClassName,
[in, optional] LPCSTR lpWindowName,
[in] DWORD dwStyle,
[in] int X,
[in] int Y,
[in] int nWidth,
[in] int nHeight,
[in, optional] HWND hWndParent,
[in, optional] HMENU hMenu,
[in, optional] HINSTANCE hInstance,
[in, optional] LPVOID lpParam
);
Parameters
- dwExStyle: Extended window styles.
- lpClassName: Pointer to a null-terminated string that specifies the window class name.
- lpWindowName: Pointer to a null-terminated string that specifies the name of the window.
- dwStyle: Window styles.
- X: The integrated X coordinate of the upper-left corner of the window.
- Y: The integrated Y coordinate of the upper-left corner of the window.
- nWidth: The width, in device units, of the window.
- nHeight: The height, in device units, of the window.
- hWndParent: Handle to the parent window or owner window of the class.
- hMenu: Handle to a menu, or specifies a child-window identifier.
- hInstance: Handle to the instance of the module to associate with the newly created window.
- lpParam: Pointer to a value to be passed to the creation function.
Return Value
- If the function succeeds, the return value is the handle to the newly created window.
- If the function fails, the return value is NULL.
Remarks
This is a fundamental function for creating user interface windows in Windows applications.
GetMessage
Retrieves messages from the calling thread's message queue.
Syntax
BOOL GetMessage(
[out] LPMSG lpMsg,
[in] HWND hWnd,
[in] UINT wMsgFilterMin,
[in] UINT wMsgFilterMax
);
Parameters
- lpMsg: Pointer to a MSG structure that receives message information.
- hWnd: Handle to the window whose messages are to be retrieved.
- wMsgFilterMin: Minimumococcal message value.
- wMsgFilterMax: Maximumococcal 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.
- If an error occurs, the return value is -1.
Remarks
Essential for the message loop of a Windows application, processing user input and system events.
DispatchMessage
Sends the message to the appropriate window procedure for processing.
Syntax
LRESULT DispatchMessage(
[in] const MSG *lpmsg
);
Parameters
- lpmsg: Pointer to a MSG structure that contains the message to be dispatched.
Return Value
- The return value is the result of the message processing and depends on the message sent to the window procedure.
Remarks
Part of the core message loop, this function routes messages to the correct handler.
LoadLibrary
Loads a dynamic-link library (DLL) into the address space of the calling process.
Syntax
HMODULE LoadLibrary(
[in] LPCTSTR lpFileName
);
Parameters
- lpFileName: Pointer to a null-terminated string that names the DLL module.
Return Value
- If the function succeeds, the return value is a handle to the loaded module.
- If the function fails, the return value is NULL.
Remarks
Used to dynamically load functionality from DLLs at runtime.
GetProcAddress
Retrieves the address of an exported function or variable from a DLL.
Syntax
FARPROC GetProcAddress(
[in] HMODULE hModule,
[in] LPCSTR lpProcName
);
Parameters
- hModule: Handle to the DLL module that contains the function or variable.
- lpProcName: Pointer to a null-terminated string that is the function or variable name.
Return Value
- If the function succeeds, the return value is the address of the exported function or variable.
- If the function fails, the return value is NULL.
Remarks
Used in conjunction with LoadLibrary
to call functions from loaded DLLs.