Registriert seit: 6. Mai 2003
804 Beiträge
Delphi 6 Enterprise
|
Re: Form schließen wenn Mauszeiger d.Form verläßt ?
28. Jun 2004, 12:20
hallo,
hier mein ganzer code:
Code:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
uses Unit2,
{$R *.dfm}
procedure TForm1.Button8MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
form2.Show;
end;
end.
Code:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm2 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Timer1Timer(Sender: TObject);
var
mouseCoords: TPoint;
begin
GetCursorPos(mouseCoords);
if (mouseCoords.x < Form2.Left) or
(mouseCoords.y < Form2.Top) or
(mouseCoords.x > Form2.Left+Form2.Width) or
(mouseCoords.y > Form2.Top+Form2.Height) then
Form2.Close;
end;
end.
mfg vader
|
|
Zitat
|