WinSetWindowULong
Appearance
This function sets an unsigned, long integer value into the memory of the reserved window words.
Syntax
WinSetWindowULong(hwnd, index, ul)
Parameters
- hwnd (HWND) - Input
- Window handle.
- index (LONG) - Input
- Zero-based index of the value to be set.
- The units of index are bytes. Valid values are zero through (cbWindowData - 4), where cbWindowData is the parameter in WinRegisterClass that specifies the number of bytes available for application-defined storage. Any of the QWL_* values are also valid.
- Note
- QWS_* values cannot be used.
- QWL_DEFBUTTON The default push button for a dialog. The default push button is the one that sends its WM_COMMAND message when the enter key is pressed.
- QWL_HMQ Handle of message queue of window. Note that the leading 16 bits of this value are zero.
- QWL_HWNDFOCUSSAVE Window handle of the child windows of this window that last possessed the focus when this frame window was last deactivated.
- QWL_PENDATA Reserved for use by operating system extensions. It allows an operating system extension to store data on a per window basis.
- QWL_STYLE Window style.
- QWL_USER A ULONG value for applications to use is present at offset QWL_USER in windows of the following preregistered window classes:
- WC_BUTTON
- WC_COMBOBOX
- WC_CONTAINER
- WC_ENTRYFIELD
- WC_FRAME (includes dialog windows)
- WC_LISTBOX
- WC_MENU
- WC_MLE
- WC_NOTEBOOK
- WC_SCROLLBAR
- WC_SLIDER
- WC_SPINBUTTON
- WC_STATIC
- WC_TITTLEBAR
- WC_VALUESET
- This value can be used to place application-specific data in controls.
- Other Zero-based index.
- ul (ULONG) - Input
- Unsigned, long integer value to store in the window words.
Returns
- rc (BOOL) - returns
- TRUE Successful completion
- FALSE Error occurred.
Remarks
The specified index is valid only if all of the bytes referenced are within the reserved memory.
Errors
Possible returns from WinGetLastError:
- PMERR_INVALID_HWND (0x1001) An invalid window handle was specified.
- PMERR_PARAMETER_OUT_OF_RANGE (0x1003) The value of a parameter was not within the defined valid range for that parameter.
Example Code
#define INCL_WINWINDOWMGR /* Or use INCL_WIN, INCL_PM, */ #include <os2.h> HWND hwnd; /* Window handle. */ LONG index; /* Zero-based index of the value to be set. */ ULONG ul; /* Unsigned, long integer value to store in the window words. */ BOOL rc; /* Success indicator. */ rc = WinSetWindowULong(hwnd, index, ul);
This example transfers a pointer from the application-defined data area of a dialog window to the application-defined data area (window word) of a main window. The pointer is then retrieved.
#define INCL_WINWINDOWMGR
#include <OS2.H>
HWND hwndClient;
ULONG msg;
MPARAM pParm, mp1, mp2;
/* Inside dialog procedure */
switch( msg )
{
case WM_INITDLG:
/* This points to the data area and is passed by */
/* WinLoadDlg, WinCreateDlg, and WinDlgBox */
/* in their pCreateParams parameter. */
pParm = (MPARAM)mp2;
/* Place the pointer in the window word area */
WinSetWindowULong(hwndClient,
QWL_USER,
(ULONG) pParm);
case WM_COMMAND:
switch (SHORT1FROMMP(mp1))
{
case DID_OK:
/* Retrieve the pointer from the window word area */
pParm = (MPARAM)WinQueryWindowULong(hwndClient,
QWL_USER);
}
}