Einzelnen Beitrag anzeigen

Benutzerbild von turboPASCAL
turboPASCAL

Registriert seit: 8. Mai 2005
Ort: Sondershausen
4.274 Beiträge
 
Delphi 6 Personal
 
#8

Re: Fenster wackeln lassen

  Alt 14. Dez 2007, 16:48
Delphi-Quellcode:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    procedure ShakeWindow(Value, Delay, Duration: Integer);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ShakeWindow(Value, Delay, Duration: Integer);
var
  OldPos: TPoint;
  i, Start, Stop: Integer;
begin
  OldPos := Point(Self.Top, Self.Left);

  try
    for i := 0 to Duration - 1 do
    begin
      Self.Left := Self.Left + round(sin(i) * Value) * (random(2) -1 );
      Self.Top := Self.Top + round(sin(i) * Value * 0.5);

      Start := gettickcount;
      Stop := 0;
      while (stop - start ) < Delay div 10 do
      begin
        Stop := GettickCount;
        Application.ProcessMessages;
      end;
    end;

  except
    // none
  end;

  Self.Top := OldPos.X;
  Self.Left := OldPos.Y;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form1.Enabled := False;
  ShakeWindow(10, 50, 255);
  Form1.Enabled := True;
end;

end.
Matti
Meine Software-Projekte - Homepage - Grüße vom Rüsselmops -Mops Mopser
  Mit Zitat antworten Zitat