禁用delphi中的表单调整大小 [英] Disable form resizing in delphi

查看:135
本文介绍了禁用delphi中的表单调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



目前我正在使用:



当表单大小更改....

  MainForm.Height:= 761; 
MainForm.Width:= 777;

但是,当用户尝试更改表单大小时,它看起来很可怕,

解决方案

修改大小很容易,您有两个选择:


  1. Delphi表单具有一个 BorderStyle 属性和一个 BorderIcons 属性。如果将 BorderStyle 设置为 bsDialog BorderIcons code> biSystemMenu ,用户无法调整表单大小。


  2. 您可以将值指定为限制属性。如果您将相同的编号写入 MinWidth MaxWidth ,则宽度将被修改。


防止移动更棘手。现在我只能想出这些解决方案:


  1. 设置 BorderStyle bsNone 。如果需要,您将需要自己绘制表格标题。


  2. 将消息处理程序写入 WM_NCHITTEST ,先调用继承,然后检查 Message.Result HTCAPTION 。如果是 HTCAPTION ,请将其设置为 HTCLIENT 。这样,你愚弄Windows,认为用户没有点击标题,所以他将无法拖动。请尝试,如果用户仍然可以移动窗口打开系统菜单,并选择移动。如果是这样,你也必须隐藏系统菜单( BorderIcons )。


答案发现 here


Is there any way to stop the user resizing the form?

Currently I am using:

When form size changed....

MainForm.Height := 761;
MainForm.Width := 777;

But this looks horrible as it flickers as the user tries to change the form size.

解决方案

Fixing the size is easy, you have two options:

  1. Delphi forms have a BorderStyle property and a BorderIcons property. If you set BorderStyle to bsDialog, and BorderIcons to biSystemMenu only, user can not resize the form.

  2. You can specify value to Constraints property. If you write the same number to MinWidth and MaxWidth, the width will be fixed.

Preventing move is more tricky. I can come up with only these solutions now:

  1. Set BorderStyle to bsNone. You will need to draw the form caption yourself, if needed.

  2. Write a message handler to WM_NCHITTEST, call inherited first, then check the Message.Result for HTCAPTION. If it is HTCAPTION, set it to HTCLIENT instead. This way, you fool Windows to think the user didn't click on caption, so he will not be able to drag. Please try if the user can still move the window opening the system menu, and choosing Move. If so, you have to hide the system menu too (BorderIcons).

Answer found here.

这篇关于禁用delphi中的表单调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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