如何使我的表单总是在我的主窗体上? [英] How to make my Forms always to be on top my main form?

查看:151
本文介绍了如何使我的表单总是在我的主窗体上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我尝试过:


$ b如何使我的非模态表单永远在我的主窗体之上? $ b

  procedure TForm3.CreateParams(var Params:TCreateParams); 
begin
继承CreateParams(Params);
Params.WndParent:= Application.MainForm.Handle;
结束

这似乎工作正常。这是正确的方式吗?

解决方案

这是窗口所有权。拥有的窗口始终显示在其所有者的顶部。所有者在CreateWindow的调用中指定,然后可以不被修改。



在VCL中,您可以通过在CreateParams中设置WndParent来指定所有者,然后框架将其传递到CreateWindow。 VCL为您提供此功能,但在旧版本中,所有者处理方式很好,有点薄弱。现代版本更好,并允许通过PopupMode和PopupParent属性进行更多控制。



因此,您的代码将具有您希望的效果。


How to make my non-modal forms to always be on top of my main form?

I have tried:

procedure TForm3.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  Params.WndParent := Application.MainForm.Handle;
end;

Which seems to work fine. Is that correct way?

解决方案

This is the Win32 concept of window ownership. An owned window always appears on top of its owner. The owner is specified in the call to CreateWindow and can then not be modified.

In the VCL you specify the owner by setting WndParent in CreateParams, and the framework then passes that on to CreateWindow. The VCL does this for you but in older versions the owner handling is, well, somewhat flaky. Modern versions are better and allow more control through the PopupMode and PopupParent properties.

Your code will therefore have the effect that you desire.

这篇关于如何使我的表单总是在我的主窗体上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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