问题描述
目前我正在使用:
当表单大小更改....
MainForm.Height:= 761;
MainForm.Width:= 777;
但是,当用户尝试更改表单大小时,它看起来很可怕,
修改大小很容易,您有两个选择:
-
Delphi表单具有一个
BorderStyle
属性和一个BorderIcons
属性。如果将BorderStyle
设置为bsDialog
和BorderIcons
code> biSystemMenu ,用户无法调整表单大小。 -
您可以将值指定为
限制
属性。如果您将相同的编号写入MinWidth
和MaxWidth
,则宽度将被修改。
防止移动更棘手。现在我只能想出这些解决方案:
-
设置
BorderStyle
到bsNone
。如果需要,您将需要自己绘制表格标题。 -
将消息处理程序写入
WM_NCHITTEST
,先调用继承,然后检查Message.Result
为HTCAPTION
。如果是HTCAPTION
,请将其设置为HTCLIENT
。这样,你愚弄Windows,认为用户没有点击标题,所以他将无法拖动。请尝试,如果用户仍然可以移动窗口打开系统菜单,并选择移动。如果是这样,你也必须隐藏系统菜单(BorderIcons
)。
答案发现。
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:
Delphi forms have a
BorderStyle
property and aBorderIcons
property. If you setBorderStyle
tobsDialog
, andBorderIcons
tobiSystemMenu
only, user can not resize the form.You can specify value to
Constraints
property. If you write the same number toMinWidth
andMaxWidth
, the width will be fixed.
Preventing move is more tricky. I can come up with only these solutions now:
Set
BorderStyle
tobsNone
. You will need to draw the form caption yourself, if needed.Write a message handler to
WM_NCHITTEST
, call inherited first, then check theMessage.Result
forHTCAPTION
. If it isHTCAPTION
, set it toHTCLIENT
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中的表单调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!