Главная страница | назад





Article #17138: responding when the user minimizes or maximizes a Form

 Question and Answer Database

FAQ2138D.txt   responding when the user minimizes or maximizes a Form
Category   :VCL
Platform    :All
Product    :All 32 bit  

Question:
How can I respond to the user minimizing or maximizing my form
before the resizing actually takes place?


Answer:
The following example demonstrates trapping the Windows
WM_SYSCOMMAND message. If the command specifies to minimize or
maximize the form, we will beep the PC speaker instead;

Example:

type
  TForm1 = class(TForm)
  private
    { Private declarations }
    procedure WMSysCommand(var Msg: TWMSysCommand);
      message WM_SYSCOMMAND;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.WMSysCommand;
begin
  if (Msg.CmdType = SC_MINIMIZE) or
     (Msg.CmdType = SC_MAXIMIZE) then
    MessageBeep(0) else
  inherited;
end;

7/16/98 4:31:28 PM
 

Last Modified: 01-SEP-99