Delphi开发中子窗口不能置顶的问题


本文整理自网络,侵删。

 

在Delphi开发中,如果我们想让一个窗口始终置顶显示,则我们只需要把窗口FormStyle属性设置为fsStayOnTop就可以了,但是如果这个窗口不是主窗口,而是子窗口,那就有些麻烦了,设置FormStyle为fsStayOnTop后也无效。解决办法就是在子窗口中重载CreateParams函数,并将WndParent设置为0即可,具体代码如下:

 

 unit Unit2;

 

interface

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls, ExtCtrls;

 

type

  TForm2 = class(TForm)

    Button1: TButton;

    Timer1: TTimer;

  private

    { Private declarations }

  public

    { Public declarations }

  protected

    procedure CreateParams(var Params: TCreateParams); override;

  end;

 

var

  Form2: TForm2;

 

implementation

 

{$R *.dfm}

 

{ TForm2 }

 

 

 

procedure TForm2.CreateParams(var Params: TCreateParams);

begin

  inherited;

  Params.WndParent := 0;

//  Params.ExStyle := Params.ExStyle or WS_EX_TOOLWINDOW; //如果不想在任务栏显示窗口图标

end;

end.

 

来源:http://bcoder.com/delphi/sub-window-can-not-set-to-topmost-in-delphi-development

相关阅读 >>

Delphi 取文件目录下所有文件名和文件目录名

Delphi的获取某坐标的颜色值

Delphi 子界判断的举例

Delphi tstringlist删除重复项

Delphi xe android 使用system.zip单元释放资源文件

Delphi dbexpress的upwherekeyonly的使用注意事项

Delphi获得某个磁盘或是文件夹的所有子目录

Delphi unigui确认对话框

Delphi win32_networkadapter 网卡 参数说明

Delphi 获取系统日期时间

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...