2007. március 19., hétfő

Respond to Windows messages


Problem/Question/Abstract:

Respond to Windows messages

Answer:

Using WM_WININICHANGED as an example:

Declaring a method in a TForm will allow you to handle WM_WININICHANGED messages:


procedure WMWinIniChange(var message: TMessage);
  message WM_WININICHANGE;

procedure TForm1.WMWinIniChange(var message: TMessage);
begin
  inherited;
  {.. react to someone mucking with control panel ..}
end;


The call to "inherited" is important. Note also that message handlers are special when calling their inherited since you don't refer to the name of the inherited.
This is because the inherited is referring to the inherited message handler for this message number, which might not have a visible name or or even the same name as you have given it, or in some cases, might not even exist (in which case you are really calling DefaultHandler).

Nincsenek megjegyzések:

Megjegyzés küldése