Article ID: 106079
Article Last Modified on 7/11/2005
int FAR PASCAL CBTProc (int nCode, WPARAM wParam, LPARAM lParam)
{
LPCBT_CREATEWND CreateWndParam;
if (nCode >= 0)
{
switch (nCode)
{
case HCBT_CREATWND:
CreateWndParam = (LPCBT_CREATEWND)lParam;
OutputDebugString ("ClassName = ");
OutputDebugString (lParam->lpcs->lpszClass);
OutputDebugString ("\r\n");
break;
:
:
}
}
return (int)CallNextHookEx (hHook, nCode, wParam, lParam);
}
However, this code may or may not output the correct class name,
depending on what the call to CreateWindow() (for the window about to
be created) looks like.
The CBT_CREATEWND structure contains information passed to a WH_CBT
hook callback function before a window is created in the system. The
lpszClass field of this CBT_CREATEWND structure may return an invalid
class name, particularly for windows created internally by the system.
typedef struct tagCBT_CREATEWND {
CREATESTRUCT FAR* lpcs;
HWND hwndInsertAfter;
} CBT_CREATEWND;
with the CREATESTRUCT structure defined in the same file as:
typedef struct tagCREATESTRUCT {
void FAR* lpCreateParams;
:
LPCSTR lpszClass; // Null-terminated string specifying window
// class name
DWORD dwExStyle;
} CREATESTRUCT;
When Windows internally creates windows (such as predefined controls
in a dialog box, for example), it uses atoms for lpszClass instead of
the actual string to minimize overhead. This makes it a little less
straightforward (sometimes impossible) to get to the actual class name
directly from the lpszClass field of the CREATESTRUCT structure.
(LPSTR)MAKEINTATOM (ICONTITLECLASS == 0x8004)where MAKEINTATOM() is defined in WINDOWS.H as:
#define MAKEINTATOM (i) ((LPCSTR) MAKELP (NULL, i))Given this, to get to the actual class name, GetAtomName() must be called in this manner:
char szBuf [10]; GetAtomName (LOWORD (lpszClass), szBuf, 10); OutputDebugString (szBuf);This outputs a class name of #32772 for the IconTitleClass.
atoms
Keywords: kbhook kbwndwclass kbprb KB106079