Delphi:MDI应用程序中的最大子窗体 [英] Delphi: Maximized Child Form in MDI Application

查看:223
本文介绍了Delphi:MDI应用程序中的最大子窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何最大化仅适合客户区域而不适合整个父窗口的子窗口?我不希望子窗口在主菜单或父窗口的其他控件下消失.

How can I maximize a child window that fits only the client area but not an entire parent window? I don't want that the child window disappears under a main menu or other controls of the parent window.

我有这个代码

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

procedure TForm2.WMSIZE(var Msg: TMessage);
begin
  inherited;
  if Msg.WParam = SIZE_MAXIMIZED then
  begin
    ShowWindow(Handle, SW_RESTORE);
    Left := 0;
    Top := 0;
    Width := Form1.ClientWidth - 4; // The BORDER
    Height := Form1.ClientHeight - 4;
  end;
end;

但这还不够好.该窗口实际上没有最大化.如果将SW_RESTORE更改为SW_MAXIMIZE,则子窗口看起来有问题.

But it's not good enough. The window is actually not maximized. If to change SW_RESTORE to SW_MAXIMIZE then the child window looks buggy.

推荐答案

通常,MDI主窗体的客户空间应自动计算为不包含菜单或栏的空间,只要这些栏与窗体的边缘对齐即可.

Normally, the MDI main form's client space should be calculated automatically to the space without menu or bars, provided that those bars are aligned to an edge of the form.

如果条形图或其他控件未对齐,则确实需要调整自己.处理WM_NCCALCSIZE告诉Windows您的表单的客户矩形尺寸有偏差.

When a bar or other controls are not aligned, then you indeed have to adjust yourself. Handle WM_NCCALCSIZE to tell windows your form has deviating client rect dimensions.

或者看看我在其中捕获WM_SYSCOMMAND,当WParam and $FFF0 = SC_MAXIMIZE调整MDI子窗口的大小时.该组件提供了一些额外的属性,例如:BackgroundPicture,CleverMaximizing,ShowClientEdge和ShowScrollBars.

Or take a look at NLDExtraMDIProps in which I catch WM_SYSCOMMAND when WParam and $FFF0 = SC_MAXIMIZE to adjust the size of a MDI child window. The component provides in a few extra properties like: BackgroundPicture, CleverMaximizing, ShowClientEdge and ShowScrollBars.

这篇关于Delphi:MDI应用程序中的最大子窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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