Interview Questions

How is message handling handled in Delphi?

Delphi Interview Questions


(Continued from previous question...)

How is message handling handled in Delphi?

Through event handlers. You can also define your own messages using the WMUSER constant.

Define custom message
const
WM_MY_MESSAGE = WM_USER + 0;


Define handler for message
type
TMyForm = class(TForm)
private
procedure OnMyMessage(var Msg: TMessage); message WM_MY_MESSAGE;

Send or Post message
PostMessage(self.Handle,WM_MY_MESSAGE,0,0)

(Continued on next question...)

Other Interview Questions