GUIdelphi, delphi3000, article, borland, vcl, code-snippet, , Mouse-Move-Auto-HideGUI">
 
Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
500 Users Online NOW
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi







Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (0)


Auto Hide for FormFormat this article printer-friendly!Bookmark function is only available for registered users!
Product:
Delphi 5.x (or higher)
Category:
GUI
Skill Level:
Scoring:
Last Update:
06/07/2002
Search Keys:
delphi delphi3000 article borland vcl code-snippet Mouse-Move-Auto-Hide
Times Scored:
2
Visits:
3144
Uploader: zswang wangjihu
Company:
Reference: kingron.myetang.com
 
Question/Problem/Abstract:

Answer:





unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Memo1: TMemo;
    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;

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;
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.







Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment













 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
R. Lefter
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)