The CBTProc hook procedure is an application-defined or library-defined callback function that the system calls before activating, creating, destroying, minimizing, maximizing, moving, or sizing a window; before completing a system command; before removing a mouse or keyboard event from the system message queue; before setting the keyboard focus; or before synchronizing with the system message queue. The value returned by the hook procedure determines whether Windows allows or prevents one of these operations. A computer-based training (CBT) application uses this hook procedure to receive useful notifications from the system.
LRESULT CALLBACK CBTProc(
int nCode, |
// hook code |
WPARAM wParam, |
// depends on hook code |
LPARAM lParam |
// depends on hook code |
); |
Value |
Meaning |
HCBT_ACTIVATE |
The system is about to activate a window. |
HCBT_CLICKSKIPPED |
The system has removed a mouse message from the system message queue. Upon receiving this hook code, a CBT application must install a WH_JOURNALPLAYBACK hook procedure in response to the mouse message. |
HCBT_CREATEWND |
A window is about to be created. The system calls the hook procedure before sending the WM_CREATE or WM_NCCREATE message to the window. If the hook procedure returns a nonzero value, the system destroys the window; the CreateWindow function returns NULL, but the WM_DESTROY message is not sent to the window. If the hook procedure returns zero, the window is created normally. |
At the time of the HCBT_CREATEWND notification, the window has been created, but its final size and position may not have been determined and its parent window may not have been established. It is possible to send messages to the newly created window, although it has not yet received WM_NCCREATE or WM_CREATE messages. It is also possible to change the position in the Z order of the newly created window by modifying the hwndInsertAfter member of the CBT_CREATEWND structure. | |
HCBT_DESTROYWND |
A window is about to be destroyed. |
HCBT_KEYSKIPPED |
The system has removed a keyboard message from the system message queue. Upon receiving this hook code, a CBT application must install a WH_JOURNALPLAYBACK_hook hook procedure in response to the keyboard message. |
HCBT_MINMAX |
A window is about to be minimized or maximized. |
HCBT_MOVESIZE |
A window is about to be moved or sized. |
HCBT_QS |
The system has retrieved a WM_QUEUESYNC message from the system message queue. |
HCBT_SETFOCUS |
A window is about to receive the keyboard focus. |
HCBT_SYSCOMMAND |
A system command is about to be carried out. This allows a CBT application to prevent task switching by means of hot keys. |
If nCode is less than zero, the hook procedure must pass the message to
the CallNextHookEx function without
further processing and should return the value returned by CallNextHookEx.
For operations corresponding to the following CBT hook codes, the return value must be 0 to allow the operation, or 1 to prevent it:
HCBT_ACTIVATE
HCBT_CREATEWND
HCBT_DESTROYWND
HCBT_MINMAX
HCBT_MOVESIZE
HCBT_SETFOCUS
HCBT_SYSCOMMAND
For operations corresponding to the following CBT hook codes, the return value is ignored:
HCBT_CLICKSKIPPED
HCBT_KEYSKIPPED
HCBT_QS
The hook procedure should not install a WH_JOURNALPLAYBACK_hook hook procedure except in the situations described in the preceding list of hook codes.
This hook procedure must be in a dynamic-link library (DLL). An application installs the hook procedure by specifying the WH_CBT hook type and the address of the hook procedure in a call to the SetWindowsHookEx function.
The following table describes the wParam and lParam parameters for each HCBT_ hook code:
Value |
wParam |
lParam |
HCBT_ACTIVATE |
Specifies the handle to the window about to be activated. |
Specifies a long pointer to a CBTACTIVATESTRUCT structure containing the handle to the active window and specifies whether the activation is changing because of a mouse click. |
HCBT_CLICKSKIPPED |
Identifies the mouse message removed from the system message queue. |
Specifies a long pointer to a MOUSEHOOKSTRUCT structure containing the hit-test code and the handle to the window for which the mouse message is intended. The HCBT_CLICKSKIPPED value is sent to a CBTProc hook procedure only if a WH_MOUSE hook is installed. For a list of hit-test codes, see WM_NCHITTEST . |
HCBT_CREATEWND |
Specifies the handle to the new window. |
Specifies a long pointer to a CBT_CREATEWND structure containing initialization parameters for the window. The parameters include the coordinates and dimensions of the window. By changing these parameters, a CBTProc hook procedure can set the initial size and position of the window. |
HCBT_DESTROYWND |
Specifies the handle to the window about to be destroyed. |
Is undefined and must be set to zero. |
HCBT_KEYSKIPPED |
Identifies the virtual-key code. |
Specifies the repeat count, scan code, key-transition code, previous key state, and context code. The HCBT_KEYSKIPPED value is sent to a CBTProc hook procedure only if a WH_KEYBOARD hook is installed. For more information, see the WM_KEYUP or WM_KEYDOWN message. |
HCBT_MINMAX |
Specifies the handle to the window being minimized or maximized. |
Specifies, in the low-order word, a show-window value (SW_) specifying the operation. For a list of show-window values, see the ShowWindow. The high-order word is undefined. |
HCBT_MOVESIZE |
Specifies the handle to the window to be moved or sized. |
Specifies a long pointer to a RECT structure containing the coordinates of the window. By changing the values in the structure, a CBTProc hook procedure can set the final coordinates of the window. |
HCBT_QS |
Is undefined and must be zero. |
Is undefined and must be zero. |
HCBT_SETFOCUS |
Specifies the handle to the window gaining the keyboard focus. |
Specifies the handle to the window losing the keyboard focus. |
HCBT_SYSCOMMAND |
Specifies a system-command value (SC_) specifying the system command. For more information about system-command values, see WM_SYSCOMMAND. |
Contains the same data as the lParam value of a WM_SYSCOMMAND message: If a system menu command is chosen with the mouse, the low-order word contains the x-coordinate of the cursor, in screen coordinates, and the high-order word contains the y-coordinate; otherwise, the parameter is not used. |
CBTProc is a placeholder for the application-defined or library-defined function name.
CallNextHookEx, CreateWindow, SetWindowsHookEx, WM_SYSCOMMAND
Comments:
Hai All,+
I want to crate an onscreen keyboard in which I need to keep yhe focus prevented from transfering to the keyboard dialog from the former window.At the same time If any controll in the keyboard dialog is clicked then it should send the respective input to the fromer window(using attachthreadInput).Can I do it by using CBTProc.If so can anybody please help me how to do it or give me some links that gives me a sample code
file: /Techref/os/win/api/win32/func/src/f04_9.htm, 14KB, , updated: 2007/7/22 22:57, local time: 2024/11/9 23:28,
3.144.15.18:LOG IN ©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://linistepper.com/techref/os/win/api/win32/func/src/f04_9.htm"> CBTProc</A> |
Did you find what you needed? |