PyCCmdTarget.HookCommand

object = HookCommand(obHandler, id )

Hook a windows command handler.

Parameters

obHandler : object

The handler for the command message. This must be a callable object.

id : int

The ID of the command to be handled, or zero to handle all command messages.

Comments

obHandler will be called as the application receives command notification messages with the specified ID. Command notification messages are usually sent in response to menu or toolbar commands.
When updating a user interface element, Pythonwin will first check if a handler has been installed via PyCCmdTarget::HookCommandUpdate. If so, this alone determines the state of the interface object. If no Update handler exists, PythonWin will automatically enable a menu/toolbar item if a command handler exists The handler will be called with 2 arguments
* The command id being handled.
* The command notification code.
If the handler returns TRUE, then the command will be passed on to the default handler, otherwise the message will be consumed.
This method is best suited to handling messages from user interface elements, such as menus, toolbars, etc. To handle notification messages from a control, you should use PyCCmdTarget::HookNotify

Return Value

The return value is the previous handler, or None.