Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi 6 - TApplicationEvents.OnMinimize is not triggered by "Show Desktop"

I have a Delphi 6 Pro application that does certain things when the application is minimized. I do my work in the OnMinimize() event that belongs to a TApplicationEvents component. It works great when the Minimize button on the main window's control box is used, however, when the Windows XP Show Desktop button is used to minimize all active applications the OnMinimize() event is not triggered. Is there a way to fix this or am I going to have to do something messy in the main WndProc()?

-- roschler

like image 657
Robert Oschler Avatar asked Dec 02 '25 08:12

Robert Oschler


1 Answers

Add

protected
  { Private declarations }
  procedure WMSize(var Message: TWMSize); message WM_SIZE;

where

procedure TForm1.WMSize(var Message: TWMSize);
begin
  if Message.SizeType = SIZE_MINIMIZED then
    beep;
end;

Alternatively, of course, you can just do

protected
  { Private declarations }
  procedure WndProc(var Message: TMessage); override;

where

procedure TForm1.WndProc(var Message: TMessage);
begin
  inherited;
  case Message.Msg of
    WM_SIZE:
      if Message.WParam = SIZE_MINIMIZED then
        beep;
  end;
end;
like image 118
Andreas Rejbrand Avatar answered Dec 04 '25 00:12

Andreas Rejbrand



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!