Calling a Control's Message Handler Directly
Go Up to Handling messages Index
Sometimes there is only a single control that needs to respond to your message. If you know the control that should receive your message, the simplest and most straightforward way to send the message is to call the control's Perform method.
There are two main reasons why you call a control's Perform method:
- You want to trigger the same response that the control makes to a standard Windows (or other) message. For example, when a grid control receives a keystroke message, it creates an inline edit control and then sends the keystroke message on to the edit control.
- You may know what control you want to notify, but not know what type of control it is. Because you don't know the type of the target control, you cannot use any of its specialized methods, but all controls have message-handling capabilities so you can always send a message. If the control has a message handler for the message you send, it will respond appropriately. Otherwise, it will ignore the message you send and return 0.
To call the Perform method, you do not need to create a message record. You need only pass the message identifier, WParam, and LParam as parameters. Perform returns the message result.