Jump to content

WinQueryClassName: Difference between revisions

From EDM2
Created page with " This function copies the window class name, as a null-terminated string, into a buffer. ==Syntax== WinQueryClassName(hwnd, lLength, PCHBuffer); ==Parameters== ; hwnd (HW..."
 
Ak120 (talk | contribs)
mNo edit summary
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
This function copies the window class name, as a null-terminated string, into a buffer.


This function copies the window class name, as a null-terminated string, into a buffer.
==Syntax==  
==Syntax==  
  WinQueryClassName(hwnd, lLength, PCHBuffer);
  WinQueryClassName(hwnd, lLength, PCHBuffer)
 


==Parameters==
==Parameters==
; hwnd (HWND) - input
; hwnd (HWND) - input:Window handle.
: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.
: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.
;lLength (LONG) - input
;PCHBuffer (PCH) - output:Class name.
: 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.
:If the class name is longer than (lLength-1) only the first (lLength-1) characters of class name are copied.


==Returns==
==Returns==
; lRetLen (LONG) - returns
; lRetLen (LONG) - returns:Returned class name length.
:Returned class name length.
:This is the length, excluding the null-termination character.
:This is the length, excluding the null-termination character.


==Errors==
==Errors==
Possible returns from WinGetLastError
Possible returns from WinGetLastError
;PMERR_INVALID_HWND (0x1001)
;PMERR_INVALID_HWND (0x1001):An invalid window handle was specified.
:An invalid window handle was specified.  
;PMERR_INVALID_STRING_PARM (0x100B):The specified string parameter is invalid.
;PMERR_INVALID_STRING_PARM (0x100B)
:The specified string parameter is invalid.
 
==Remarks==


==Example Code==
==Example Code==
Line 54: Line 43:


pWindowProc = classinfo.pfnWindowProc;
pWindowProc = classinfo.pfnWindowProc;
</pre>
</pre>


Line 79: Line 66:
* [[WinDestroyWindow]]
* [[WinDestroyWindow]]
* [[WinQueryClassInfo]]
* [[WinQueryClassInfo]]
* [[WinQueryClassName]]
* [[WinRegisterClass]]
* [[WinRegisterClass]]
* [[WinSubclassWindow]]
* [[WinSubclassWindow]]
[[Category:Win]]
[[Category:Win]]

Latest revision as of 14:18, 4 October 2023

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.

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);

Related Functions