delphi开发中子窗口不能置顶的问题  
官方Delphi 学习QQ群: 682628230(三千人)
频道

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


推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.042754888534546 seconds