如何检测表单何时被最大化? [英] How to detect when the form is being maximized?

查看:187
本文介绍了如何检测表单何时被最大化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检测何时最大化窗体以保存某些设置(与大小和位置无关),并修改大小和位置。有普遍的做法吗?
我试图捕获WM_SYSCOMMAND消息,如这篇文章。它可以很好地从菜单中最大化,最大化按钮,但是当我按下WIN + UP按键时,它不会被触发。有没有人知道如何捕获最大化事件,包括WIN + UP击键的情况?



谢谢

解决方案

您可以使用 WM_GETMINMAXINFO 消息以保存窗口的状态,然后使用 WMSize 消息,以检查窗口是否最大化。 / p>

在你的表单中声明了这样的消息处理程序:

 程序WMSize (var Msg:TMessage);消息WM_SIZE; 

这样处理:

  procedure TForm57.WMSize(var Msg:TMessage); 
begin
if Msg.WParam = SIZE_MAXIMIZED then
ShowMessage('Maximized');
结束


I would like to detect when the form is going to be maximized to save certain settings (not related to the size nor position) and modify the size and position a little bit. Is there an universal way to do it ? I've tried to catch the WM_SYSCOMMAND message like in this article. It works well for maximization from menu, by maximize button, but it's not fired when I press the WIN + UP keystroke. Does anyone know an universal way how to catch the maximization event including the case with WIN + UP keystroke ?

Thanks

解决方案

You can use the WM_GETMINMAXINFO message to save the state of the window and then use the WMSize message to check if the window was maximized.

in you form declare the mesage handler like so :

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

And handle like this :

procedure TForm57.WMSize(var Msg: TMessage);
begin
  if Msg.WParam  = SIZE_MAXIMIZED then
    ShowMessage('Maximized');    
end;

这篇关于如何检测表单何时被最大化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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