你在鼠标的移动事件中,求得form的位置,当计算出是在四周时,就form.visible:=false;
当form已隐藏时,在鼠标移动中,又计算,自己定义使form可见的鼠标位置。就行了。
当form已隐藏时,在鼠标移动中,又计算,自己定义使form可见的鼠标位置。就行了。
解决方案 »
- Delphi 的dll不能使用DataModule窗体吗。怎么我的会报错access violation
- 获取类属性的问题
- 初学delphi的几个问题!
- 请问汉字的二进制怎么得到?
- >>>> 批处理方式下,调用UpdateBatch怎么跟踪每一条记录?
- 请问我有C的.h文件,怎样才能变成delphi的.pas文件
- 哪里有DELPHIE最新版下载? 请笑纳 20 分
- 人穷的时候,http://www.zsgt.8u8.com/gushi.htm,别进来,因为只有标题。
- 找一个随机数生成算法吧,急用!!!谢谢各位大侠了先!!!!最好delphi的呀!
- 请教高手们:在DELPHI5中用Tnmftp开发文件上传,怎么实现整个目录下的文件上传???
- 用NMFTP做下载的问题
- 如何在字符串中用单引号?
你曾经实现过吗?有现成代码吗?如有 mail:[email protected]谢谢
我放了一个timer在form上,interval 用的100.
在ontimer事件中,用如下代码,只写了在最左上角的实现,要实现四周的,你可以自己仿照完成。
procedure TForm1.Timer1Timer(Sender: TObject);
var va1,va2:variant;
vs1,vs2:string;
begin
va1:= mouse.CursorPos.x;
vs1:=string(va1);
va2:= mouse.CursorPos.y;
vs2:=string(va2);
if ((form1.left<=0) and (form1.top<=0) and (strtoint(vs2)>27)) then
begin
form1.Visible:=false;
exit;
end; if form1.Visible=false and (vs1='0' )
then
form1.Visible:=true;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var va1,va2:variant;
vs1,vs2:string;
begin
va1:= mouse.CursorPos.x;
vs1:=string(va1);
va2:= mouse.CursorPos.y;
vs2:=string(va2);
if ((form1.left<=0) and (form1.top<=0) and (strtoint(vs2)>27)) then
begin
borderstyle:=bsnone;
form1.Height:=15;
exit;
end; if (form1.height<20) and (vs2='0' )
then
begin
borderstyle:=bssizeable;
form1.height:=375;
end;
end;procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin if key=13 then //按回车键
showmessage('it is ok');
end;procedure TForm1.FormMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
showmessage('it is ok');
end;procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
showmessage('it is ok');
end;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
FAnchors: TAnchors;
procedure WMMOVING(var Msg: TMessage); message WM_MOVING;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses Math;
{ TForm1 }
procedure TForm1.WMMOVING(var Msg: TMessage);
begin
inherited;
with PRect(Msg.LParam)^ do begin
Left := Min(Max(0, Left), Screen.Width - Width);
Top := Min(Max(0, Top), Screen.Height - Height);
Right := Min(Max(Width, Right), Screen.Width);
Bottom := Min(Max(Height, Bottom), Screen.Height);
FAnchors := [];
if Left = 0 then Include(FAnchors, akLeft);
if Right = Screen.Width then Include(FAnchors, akRight);
if Top = 0 then Include(FAnchors, akTop);
if Bottom = Screen.Height then Include(FAnchors, akBottom);
Timer1.Enabled := FAnchors <> [];
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Timer1.Enabled := False;
Timer1.Interval := 200;
FormStyle := fsStayOnTop;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
const
cOffset = 2;
begin
if WindowFromPoint(Mouse.CursorPos) = Handle then begin
if akLeft in FAnchors then Left := 0;
if akTop in FAnchors then Top := 0;
if akRight in FAnchors then Left := Screen.Width - Width;
if akBottom in FAnchors then Top := Screen.Height - Height;
end else begin
if akLeft in FAnchors then Left := -Width + cOffset;
if akTop in FAnchors then Top := -Height + cOffset;
if akRight in FAnchors then Left := Screen.Width - cOffset;
if akBottom in FAnchors then Top := Screen.Height - cOffset;
end;
end;
end.
当桌面工具栏在屏幕左边时,你如果将QQ也放到左边,那么就会有冲突提示,所以我判断,似乎利用了系统的api,没有仔细研究过,
但觉得,用计算来实现固然可以做的形似但毕竟不是神似,而且显得方法太土太硬,不聪明,有“暴力”的痕迹。
调试通过,谢谢!
你说的从边上拖不回来是不可能的,我做了测试的,不可能拖不回来。
你自己试试,绝对不可能,除非你故意不拖。
还有,你把和QQ不一样的地方说出来,不要只是说不一样,你说出不同来,我就改得相同。说吧。
但对于QQ技术,还是非常感兴趣继续关注
可以看看zswang(伴水)的代码,基本上就是我想要的。分会给你的:) 我现在发个帖子,你赶紧来回哦
procedure TForm1.Timer1Timer(Sender: TObject);
var va1,va2:variant;
vs1,vs2:string;
begin
va1:= mouse.CursorPos.x;
vs1:=string(va1);
va2:= mouse.CursorPos.y;
vs2:=string(va2);
if (((form1.left<=0) or
(form1.top<=0) or
(form1.left+form1.Width >screen.Width )) and
((strtoint(vs2)>form1.Height+form1.top)) or
(strtoint(vs1)>form1.width+form1.left) or
(strtoint(vs1)<form1.left)) then
begin
borderstyle:=bsnone;
form1.top:=0;
form1.Height:=3;
exit;
end; if (form1.height<20) and (vs2='0' )
then
begin
borderstyle:=bssizeable;
form1.height:=375;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var va1,va2:variant;
vs1,vs2:string;
begin
va1:= mouse.CursorPos.x;
vs1:=string(va1);
va2:= mouse.CursorPos.y;
vs2:=string(va2);
if (((form1.left<=0) or
(form1.top<=0) or
(form1.left+form1.Width >screen.Width )) and
((strtoint(vs2)>form1.Height+form1.top) or
(strtoint(vs1)>form1.width+form1.left) or
(strtoint(vs1)<form1.left)) and
(form1.top<=0)) then
begin
borderstyle:=bsnone;
form1.top:=0;
form1.Height:=3;
exit;
end; if (form1.height<20) and (vs2='0' )
then
begin
borderstyle:=bssizeable;
form1.height:=375;
end;
end;
在FormCreate的时候赋过去