WinQueryClassName
Appearance
This function copies the window class name, as a null-terminated string, into a buffer.
Syntax
WinQueryClassName(hwnd, lLength, PCHBuffer);
Parameters
- hwnd (HWND) - input
- Window handle.
- If this window is of any of the preregistered WC_* classes the class name returned in the PCHBuffer parameter is in the form "#nnnnn", where "nnnnn" is a group of up to five digits that corresponds to the value of the WC_* class name constant.
- lLength (LONG) - input
- Length of PCHBuffer.
- It must be greater than 0.
- PCHBuffer (PCH) - output
- Class name.
- If the class name is longer than (lLength-1) only the first (lLength-1) characters of class name are copied.
Returns
- lRetLen (LONG) - returns
- Returned class name length.
- This is the length, excluding the null-termination character.
Errors
Possible returns from WinGetLastError
- PMERR_INVALID_HWND (0x1001)
- An invalid window handle was specified.
- PMERR_INVALID_STRING_PARM (0x100B)
- The specified string parameter is invalid.
Remarks
Example Code
This example obtains a pointer to the window procedure of the window class, given that we know the window handle.
#define INCL_WINWINDOWMGR #include <OS2.H> HAB hab; HWND hwnd; CLASSINFO classinfo; PFNWP pWindowProc; char *classname; WinQueryClassName(hwnd, sizeof(classname), classname); WinQueryClassInfo(hwnd, classname, &classinfo); pWindowProc = classinfo.pfnWindowProc;
Definition
#define INCL_WINWINDOWMGR /* Or use INCL_WIN, INCL_PM, */ #include <os2.h> HWND hwnd; /* Window handle. */ LONG lLength; /* Length of PCHBuffer. */ PCH PCHBuffer; /* Class name. */ LONG lRetLen; /* Returned class name length. */ lRetLen = WinQueryClassName(hwnd, lLength, PCHBuffer);