Delphi 6 - "Show Desktop"不会触发TApplicationEvents.OnMinimize

Rob*_*ler 3 delphi desktop components minimize show

我有一个Delphi 6 Pro应用程序,可以在应用程序最小化时执行某些操作.我在属于TApplicationEvents组件的OnMinimize()事件中完成我的工作.当使用主窗口控件盒上的"最小化"按钮时,它非常有用,但是,当使用Windows XP"显示桌面"按钮来最小化所有活动应用程序时,不会触发OnMinimize()事件.有没有办法解决这个问题,或者我将不得不在主要的WndProc()中做一些混乱的事情?

- roschler

And*_*and 7

protected
  { Private declarations }
  procedure WMSize(var Message: TWMSize); message WM_SIZE;
Run Code Online (Sandbox Code Playgroud)

哪里

procedure TForm1.WMSize(var Message: TWMSize);
begin
  if Message.SizeType = SIZE_MINIMIZED then
    beep;
end;
Run Code Online (Sandbox Code Playgroud)

或者,当然,你可以这样做

protected
  { Private declarations }
  procedure WndProc(var Message: TMessage); override;
Run Code Online (Sandbox Code Playgroud)

哪里

procedure TForm1.WndProc(var Message: TMessage);
begin
  inherited;
  case Message.Msg of
    WM_SIZE:
      if Message.WParam = SIZE_MINIMIZED then
        beep;
  end;
end;
Run Code Online (Sandbox Code Playgroud)