[Overview][Procedures and functions][Index] Reference for unit 'LCLIntf' (#lcl)

SendMessage

Sends a message directed to a window to the message pool of the application

Declaration

Source position: winapih.inc line 234

function SendMessage(

  HandleWnd: HWND;

  Msg: Cardinal;

  WParam: WPARAM;

  LParam: LPARAM

):LRESULT;

Arguments

HandleWnd

  

The handle of the window to receive the message.

Description

This method is a thread-safe solution to send messages to windows. Those messages will be handled in the message loop of the application and therefore can be sent from any thread. They are not immediate, but they will awake the main thread if it is waiting for messages. These messages can be handled by procedures with the keyword message in the class of a form for example. One would then use the handle of this form as the HandleWnd parameter of this routine. Custom messages should always have an identification number (represented by the parameter Msg) larger then the constant LM_USER. The two parameters WParam and LParam will be passed along to the window together with the Msg identification number.

The difference between SendMessage and PostMessage is the way that they return control to the calling thread. With SendMessage control is not returned until the window that the message was sent to has completed processing the sent message, however with PostMessage control is returned immediately.

See also

LCLIntf.PostMessage

  

Sends a message to a window.

This page is hosted on Get Lazarus Code and Component Repository at SourceForge.net. Fast, secure and Free Open Source software downloads