如何在Delphi中制作类似网络蚂蚁的悬浮窗体(100分)

  • 主题发起人 主题发起人 toli
  • 开始时间 开始时间
T

toli

Unregistered / Unconfirmed
GUEST, unregistred user!
类似网络蚂蚁的悬浮窗体,十万火急
 
用api SetWindowPos可以让窗口在所有窗口的上面
至于拖动好象以前有个简单方法,你找找论坛吧
 
拖动也好办:1法:直接在事件MOUSEMOVE和MOUSEDOWN、MOUSEUP中写代码
2法:拖动窗体时利用消息的方式告诉WINDOWS正在拖动标题栏,交给WINDOWS自己处理。
 
问题已解决。拿来大家看看:
(还是给分)(太容易了吧)

unit U_FormFloat;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;

type
TFormFloat = class(TForm)
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
procedure FormDragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
procedure CreateParams(var Params:TCreateParams);override;
end;

var
FormFloat: TFormFloat;

implementation

{$R *.DFM}

procedure TFormFloat.FormCreate(Sender: TObject);
begin
Width := 72;
Height := 36;
SetWindowLong(Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
end;

procedure TFormFloat.CreateParams(var Params:TCreateParams);
begin
inherited;
with Params do
begin
Style := Params.Style xor WS_DLGFRAME;
WndParent := 0;
end;
end;


procedure TFormFloat.FormDragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept:=True;
end;

procedure TFormFloat.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
const
SC_DragMove = $F012; { a magic number }
begin
ReleaseCapture;
FormFloat.Perform(WM_SysCommand, SC_DragMove, 0);
end;

end.
 
多人接受答案了。
 

Similar threads

回复
0
查看
978
不得闲
S
回复
0
查看
896
SUNSTONE的Delphi笔记
S
S
回复
0
查看
873
SUNSTONE的Delphi笔记
S
后退
顶部