Open
Description
Possible new tip from extra/Topelina Tips.odt
FormENTERSIZEMOVE
How to Detect the Start Move/Resize, Move and Stop Move/Resize events of a Form.
If you want to detect when a user starts resizing and moving a Delphi form, and when the move (or resize) operation is finished, you need to handle a few Windows messages.
The WM_ENTERSIZEMOVE
message is sent once to a window when it enters the moving or sizing mode. The WM_EXITSIZEMOVE
message is sent once to a window after it has exited the moving or sizing mode. While a form is being moved, the WM_MOVE
message is sent to a window.
Here's an example (move this form and watch its title):
type
TForm1 = class(TForm)
private
procedure WMEnterSizeMove(var Message: TMessage) ; message WM_ENTERSIZEMOVE;
procedure WMMove(var Message: TMessage) ; message WM_MOVE;
procedure WMExitSizeMove(var Message: TMessage) ; message WM_EXITSIZEMOVE;
// ...
procedure TForm1.WMEnterSizeMove(var Message: TMessage) ;
begin
Caption := 'Move / resize started';
end; (*WMEnterSizeMove*)
procedure TForm1.WMMove(var Message: TMessage) ;
begin
Caption := Format('Form is being moved. Client area x: %d, y:%d', [TWMMove(Message).XPos,TWMMove(Message).YPos]) ;
end; (*WMMove*)
procedure TForm1.WMExitSizeMove(var Message: TMessage) ;
begin
ShowMessage('Move / resize complete!') ;
end; (*WMExitSizeMove*)
Contributed by: topellina [email protected]
Metadata
Metadata
Assignees
Projects
Status
Considering