检测所有形式最小化的情况 [英] Detect all situations where form is minimized

查看:64
本文介绍了检测所有形式最小化的情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检测何时最小化表单(以隐藏覆盖表单)。我拦截了 WM_SYSCOMMAND 消息,如果我单击表单的最小化按钮,它会正常运行,但是如果我使用[Windows] + [M],似乎不会触发此事件。此外,在这种情况下不会触发 WM_ACTIVATE WM_ACTIVATEAPP

I need to detect when a form is minimized (to hide overlay form). I intercept WM_SYSCOMMAND message and it works fine if I click the form's minimize button, but this event seems not to be fired if I use [Windows] + [M]. Also, WM_ACTIVATE and WM_ACTIVATEAPP are not triggered in this case.

我可以使用什么事件,还有什么其他情况需要检测?

What event could I use and are there any other situations that I would have to detect?

推荐答案

如此处所述, 如何检测何时最大化表单? ,听 WM_SIZE 消息。

As explained here, How to detect when the form is being maximized?, listen to the WM_SIZE messages.

以您的形式声明:

procedure WMSize(var Msg: TMessage); message WM_SIZE;

执行:

procedure TForm1.WMSize(var Msg: TMessage);
begin
  Inherited;
  if Msg.WParam  = SIZE_MINIMIZED then
    ShowMessage('Minimized');
end;

更新

另请参阅 @bummi 的答案,其中有一个 Application.MainFormOnTaskbar = false 时的解决方案。

See also the answer by @bummi where there is a solution when Application.MainFormOnTaskbar = false.

这篇关于检测所有形式最小化的情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆