你在鼠标的移动事件中,求得form的位置,当计算出是在四周时,就form.visible:=false;
当form已隐藏时,在鼠标移动中,又计算,自己定义使form可见的鼠标位置。就行了。

解决方案 »

  1.   

    to ahuige:
    你曾经实现过吗?有现成代码吗?如有 mail:[email protected]谢谢
      

  2.   

    这个问题已解决,
    我放了一个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;
      

  3.   

    很感激你不过好像QQ不是通过visible来实现的吧,因为它还留有一条边的,如是QQ面板是当前激活窗口的话,还是能响应鼠标和键盘时间的。不知你发现没有?能再研究一下吗?分一定给你,说好100吧如何?
      

  4.   

    只要在form的move事件中判断是否到了屏幕四周就可以了
      

  5.   

    好,该问题再次解决,代码如下(留下的边的高度你可自己考虑,我用的15注意不要拖得太上面,以免看不到留下的边)另外,响应键盘事件是没有问题的,鼠标事件我让它响应中间的滚动键,也让它响应了点鼠标事件,不过你眼睛要好,才可以用鼠标点留下的一点form的边。给分吧
    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;
      

  6.   

    //请你调试unit  Unit1;  
     
    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.  
      

  7.   

    好象不是通过计算来实现的,太老土了一点吧,
    当桌面工具栏在屏幕左边时,你如果将QQ也放到左边,那么就会有冲突提示,所以我判断,似乎利用了系统的api,没有仔细研究过,
    但觉得,用计算来实现固然可以做的形似但毕竟不是神似,而且显得方法太土太硬,不聪明,有“暴力”的痕迹。
      

  8.   

    to:zswang(伴水)
    调试通过,谢谢!
      

  9.   

    lemonscar(柠檬刀巴) 
    你说的从边上拖不回来是不可能的,我做了测试的,不可能拖不回来。
    你自己试试,绝对不可能,除非你故意不拖。
    还有,你把和QQ不一样的地方说出来,不要只是说不一样,你说出不同来,我就改得相同。说吧。
      

  10.   

    to: ehao0211(牛粪阿昊)其实我得要求也就这样,可以了。
    但对于QQ技术,还是非常感兴趣继续关注
      

  11.   

    to:ahuige(灰不遛秋) 不是拖不回来,就是要一点点拖,因为鼠标出感应区form就又缩回去了。
    可以看看zswang(伴水)的代码,基本上就是我想要的。分会给你的:) 我现在发个帖子,你赶紧来回哦
      

  12.   

    就是把ontimer事件中的<27改为<form1.height 就行了,我试了,可以的,而且我想我这个东西代码量算是较小的吧。你试一下把ontimer事件中的<27改为<form1.height ,就把感受区扩大了
      

  13.   

    我现在把代码改了,现在左右和上面都可以完成了,已经和qq一样了,除了两边我没定义是否自动把出了屏幕的边收回来。这个就看自己的需要了。大家试试吧,不过窗口宽度要改得小一点才象qq哟。
    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;
      

  14.   

    ahuige(灰不遛秋) 最后代码:在窗口中放一个timer,在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) 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;
      

  15.   

    把窗口的Top和Left写在INI文件里面
    在FormCreate的时候赋过去