下面是程序员大本营2000里的窗体隐藏的例子,供大家参考:(顺便活动一下手指)它的主要思想:利用一个线程来不断判断鼠标的位置是否在窗体的范围之内。简单一点:在窗体上放一个timer来判断//主窗体...
uses
..., TimerThread;procedure TForm1.Formcreate(sender:tObject);
begin
...
MyThread := ThreadMouse.Create(false);
end;
.....end.//线程单元unit TimeThread ;
....
type
ThreadMouse =class(TThread) private
procedure WinPushIn;
procedure WinPushout;
Protected
procedure Execute;override;
end;implementation
uses
Main;procedure ThreadMouse.execute;
var
P:TPoint;
begin
while not Terminated do
begin
P:=mouse.CursorPos; //获得鼠标位置
Px:=P.x;
Py:=P.y;
if (P.x > frmClock.left) and (P.x < frmClock.left + frmClock.width) and
( P.y< FRMcLOCK.TOP + frmclock.height) then
Synchronize(Winpushout)
else
Synchronize(Winpushin);
end;
end;procedure ThreadMouse.winpushin;
begin
.... //窗体平滑缩进代码
end;
procedure Threadmouse.Winpushout;
begin
.....//窗体平滑显示代码
end;
至于 停靠技术我想也是利用了鼠标位置,然后强行显示到屏幕的边界位置。
不知各位有什么高见?
uses
..., TimerThread;procedure TForm1.Formcreate(sender:tObject);
begin
...
MyThread := ThreadMouse.Create(false);
end;
.....end.//线程单元unit TimeThread ;
....
type
ThreadMouse =class(TThread) private
procedure WinPushIn;
procedure WinPushout;
Protected
procedure Execute;override;
end;implementation
uses
Main;procedure ThreadMouse.execute;
var
P:TPoint;
begin
while not Terminated do
begin
P:=mouse.CursorPos; //获得鼠标位置
Px:=P.x;
Py:=P.y;
if (P.x > frmClock.left) and (P.x < frmClock.left + frmClock.width) and
( P.y< FRMcLOCK.TOP + frmclock.height) then
Synchronize(Winpushout)
else
Synchronize(Winpushin);
end;
end;procedure ThreadMouse.winpushin;
begin
.... //窗体平滑缩进代码
end;
procedure Threadmouse.Winpushout;
begin
.....//窗体平滑显示代码
end;
至于 停靠技术我想也是利用了鼠标位置,然后强行显示到屏幕的边界位置。
不知各位有什么高见?
解决方案 »
- PrinterSettings.PaperSize
- 散点分,活跃下人气
- 1、delphi客户端如何调用webservice中的返回一个对象??2、如何调用对象里的(对象数组)
- 小问题,DBGRID的.菜鸟请教了.
- 超难问题!!!! 能不能 实现 修改 一个正在运行中程序 的 窗体的标题??????????
- dephi刚入门,请问高手该看什么书??
- 请教一下文本框的使用
- 在InterWeb中如何创建第二个表单,请高手帮忙。
- 谁能详细说明一下ClientDataSet控件的Filter,MasterSource,MasterFields的用法啊?
- 如何去掉数据库登陆对话框
- with ... do....什么意思?怎么用呢?
- 一个有关取数据库中表,表信息,字段信息的问题,有一定难度哦……
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;type
TForm1 = class(TForm)
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
MPos:TPoint;
implementation{$R *.DFM}procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
MPos.X := X;
MPos.Y := Y;
end;procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var i:integer;
begin
if ssLeft in Shift then
begin
i:=50;
if (Form1.Left - (MPos.X-X))>i then
Form1.Left := Form1.Left - (MPos.X-X)
else Form1.Left :=0; if (Form1.Top - (MPos.Y-Y))>i then
Form1.Top := Form1.Top - (MPos.Y-Y)
else Form1.Top := 0; end;end;end.
[email protected]