• Delphi 悬浮窗口、浮动窗口的实现


    源:Delphi 悬浮窗口、浮动窗口的实现

    浮动窗体的实现


    http://blog.tianya.cn/blogger/post_show.asp?BlogID=68097&PostID=806089

    需要一个这样的窗体:
    a:没有标题栏;
    b:可以改变大小; c:不在任务栏上显示图标; d:如果不是主窗体,它的最小化不受主窗体的限制;
    e:在最顶端显示

    处理:
    a:不在任务栏出现的,只要设置窗体的属性为ToolWindow就可以了.
    b:要想使窗体脱离主窗体的限制,必须修改它的ParentWnd,使用SetParent显然有些问题.可以通过重载CreateParams方法来实现.
    如下:
    procedure
    TForm2.CreateParams(var Params: TCreateParams);
    begin
    inherited
    CreateParams(Params);
    Params.WndParent := GetDesktopWindow;
    //Params.Style
    := (Params.Style or ws_Popup) and (not ws_Caption);
    Params.Style :=
    Params.Style and (not WS_CAPTION) and (not WS_BORDER);
    Params.Style :=
    Params.Style or WS_POPUP or WS_THICKFRAME or
    WS_CLIPCHILDREN;
    end;




    在DELPHI中如何开发类似《网络蚂蚁》中悬浮窗口?

    http://topic.csdn.net/t/20010802/11/220206.html


    unit
    Unit2;

    interface

    uses
    Windows, Messages, SysUtils, Variants,
    Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls;

    type

    TfrmPop = class(TForm)
    procedure FormMouseDown(Sender: TObject; Button:
    TMouseButton;
    Shift: TShiftState; X, Y: Integer);
    private
    { Private
    declarations }
    public
    { Public declarations }
    procedure
    CreateParams(var Params: TCreateParams); override;
    end;

    var

    frmPop: TfrmPop;

    implementation

    {$R *.dfm}



    procedure TfrmPop.CreateParams(var Params: TCreateParams);
    begin

    inherited CreateParams(Params);
    with Params do
    begin
    ExStyle :=
    ExStyle or WS_EX_TOPMOST or WS_EX_TOOLWINDOW;
    WndParent := 0;
    end

    end;

    procedure TfrmPop.FormMouseDown(Sender: TObject; Button:
    TMouseButton;
    Shift: TShiftState; X, Y: Integer);
    begin

    ReleaseCapture;
    Perform(WM_SYSCOMMAND,$F012,0);
    end;

    end.

    =======================================================================

    我试成功了。

    以下为主窗体的代码:
    uses unit2;

    procedure TForm1.Show(Sender:TObject);

    begin
    Form2.Show;
    end;

    //Form2的代码
    protected

    procedure CreateParams(var Params:TCreateParams);override;

    procedure
    TForm2.CreateParams(var Params:TCreateParams);
    begin
    inherited
    CreateParams(Params);
    Params.WndParent:=0;

    Params.ExStyle:=Params.ExStyle or WS_EX_TOOLWINDOW;
    end;


    procedure TForm2.FormCreate(Sender: TObject);
    begin
    Width:=40;

    Height:=40;
    end;

    procedure TForm2.FormMouseDown(Sender: TObject;
    Button: TMouseButton;
    Shift: TShiftState; X, Y: Integer);
    begin

    ReleaseCapture;
    Perform(WM_SYSCOMMAND,$F012,0);
    end;


    //将FORM2的STYLE属性设为bsNone;还要将Form2的FormStyle属性设为fsStayOnTop,使佗总在最前。

  • 相关阅读:
    poj3252(组合数)
    cf-Global Round2-E. Pavel and Triangles
    cf-Global Round2-D. Frets On Fire(二分)
    cf-Global Round2-C. Ramesses and Corner Inversion(思维)
    trick
    2019ICPC南京网络赛B super_log(a的b塔次方)
    欧拉定理,欧拉降幂
    F. Moving On
    Codeforces Round #200 (Div. 1)D. Water Tree
    hdu5452
  • 原文地址:https://www.cnblogs.com/LittleTiger/p/4949339.html
Copyright © 2020-2023  润新知