Home > Back-end >  Delphi messaging
Delphi messaging

Time:10-19

Why change the window size, will trigger a WM_SIZE message??????
The use of the Delphi keyword message???
How to define their own news??

 unit Form1Unit; 

Interface

USES the
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms, StdCtrls;

Type
TForm1=class (TForm)
For: TButton;
Procedure Button1Click (Sender: TObject);
Private
{Private declarations}
Procedure Refresh (var Msg: TMessage); The message WM_SIZE;
Public
{Public declarations}
end;

Var
Form1: TForm1;

Implementation

{$R *. DFM}

{this method the news of the capture window size was changed}
Procedure TForm1. Refresh (var Msg: TMessage);
The begin
{to the size of the window display in the title bar}
Caption:=IntToStr (Width) + '-' + IntToStr (Height);
{to invoke the default message handler, redrawn window}
Inherited;
end;

{random to resize the window}
Procedure TForm1. Button1Click (Sender: TObject);
Var
Size: Integer;
The begin
{button itself will be moved to the left upper corner of the window first, lest the narrow window after obscured}
(Sender as TButton). Left:=0;
(Sender as TButton). Top:=0;

{get a random number, can be positive or negative}
Randomize.
Size: the Random=(100) - 50;
{new Settings window size}
The Width: the Width=+ Size;
Height: Height=+ Size;
{when change the window size, will trigger a WM_SIZE message, thus invoking we define TForm1. Refresh}
end;

End.

CodePudding user response:

Intercept the message definition method:
Procedure of custom method name (var Msg: TMessage); The message to intercept the message constants;

When you want to intercept a message, simply structure declaration according to the above method can.
Such as mobile message response method named:
Procedure CustMove (var Msg: TMessage); The message WM_MOVE;


Why change the window size, will trigger a WM_SIZE message??????
The use of the Delphi keyword message???
How to define their own news??
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
If I have some questions to continue to post:)

CodePudding user response:

First look at Windows message mechanism, and then look like the VCL structure analysis,

CodePudding user response:

The Refresh OnResize event is that you write

CodePudding user response:

Problem a: this is a Windows system running rules, is not decided by the Delphi,
News is actually an integer, than WM_USER can serve as a custom message,
  • Related