如何实现类似于QQ的主窗体自动隐藏在屏幕上边啊?高手进,急等

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls,Math;type
      TForm1 = class(TForm)
        timerFormMgr: TTimer;
        procedure timerFormMgrTimer(Sender: TObject);
      private
        { Private declarations }
        FAnchors: TAnchors;
      public
        procedure WMMOVING(var Msg: TMessage); message WM_MOVING;
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}{ TForm1 }procedure TForm1.WMMOVING(var Msg: TMessage);
    begin
      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) and (top=0) then
          Include(FAnchors, akLeft)
        else if (top=0) and (Right = Screen.Width) then
          Include(FAnchors, aktop)
        else
          begin
            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);
          end;
        timerFormMgr.Enabled := FAnchors<>[];
        setwindowpos(application.handle,HWND_TOPMOST,0,0,0,0,swp_hidewindow);
      end;
    end;procedure TForm1.timerFormMgrTimer(Sender: TObject);
    function FindPopupControl(const Pos: TPoint): TControl;
      var
        Window: TWinControl;
      begin
        Result := nil;
        Window := FindVCLWindow(Pos);
        if Window <> nil then
        begin
          Result := Window.ControlAtPos(Pos, False);
          if Result = nil then Result := Window;
        end;
      end;
    const
      cOffset = 2;
    var
      vHandle: THandle;
    begin
      vHandle := WindowFromPoint(Mouse.CursorPos);
      while (vHandle<>0) and (vHandle<>Handle) do
        vHandle := GetParent(vHandle);
      if ( vHandle = 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.
      

  2.   

    楼主以上就可以,不过我有一个源代码,如果要的话,则留下Email
      

  3.   

    好的,多谢大家了,我的e-mail:[email protected]
      

  4.   

    我已经按2楼的朋友给的方法实现了,但是它不是像QQ和msn那样渐渐的出来和隐藏的,而一很突勿的出来和隐藏的,请问如何实现渐渐的那种感觉?