This example is how to call another window that mean is show window with an animation. we use two form to demontration this windows api function. this funtion is derived from  user32 library .

syntax: function AnimateWindow(hWnd: HWND; dwTime: DWORD; dwFlags: DWORD): BOOL; stdcall;

3 parameters:

  • hWnd is windows handle
  • dwTime is how long the process is running
  • dwFlags is model of animate

delphionderdils

Ok next …

let’s get started..

  • Create new apllication
  • add two button like in picture in form1
  • change the caption show and hide
  • add form2
  • add label1 to form2 and change the caption like the picture
  • write code in button click on each button like this

 

procedure TForm1.Button1Click(Sender: TObject);
begin
 AnimateWindow(form2.handle, 2000, AW_CENTER Or AW_ACTIVATE);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  AnimateWindow(form2.handle, 2000, AW_CENTER Or AW_HIDE);
end;

 

Source

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
 AnimateWindow(form2.handle, 2000, AW_CENTER Or AW_ACTIVATE);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  AnimateWindow(form2.handle, 2000, AW_CENTER Or AW_HIDE);
end;

end.

unit Unit2;

interface

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

type
  TForm2 = class(TForm)
    Label1: TLabel;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

end.

 

 

source DFM

object Form1: TForm1
  Left = 172
  Top = 174
  Width = 195
  Height = 251
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Button1: TButton
    Left = 40
    Top = 32
    Width = 75
    Height = 25
    Caption = 'Show'
    TabOrder = 0
    OnClick = Button1Click
  end
  object Button2: TButton
    Left = 40
    Top = 72
    Width = 75
    Height = 25
    Caption = 'Hide'
    TabOrder = 1
    OnClick = Button2Click
  end
end

object Form2: TForm2
  Left = 380
  Top = 174
  Width = 359
  Height = 250
  Caption = 'Form2'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 16
    Top = 64
    Width = 309
    Height = 37
    Caption = 'ANIMATE WINDOW'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clRed
    Font.Height = -32
    Font.Name = 'MS Sans Serif'
    Font.Style = [fsBold]
    ParentFont = False
  end
end

 

 

Link Download source

http://www.ziddu.com/download/18582686/animasiwindow.rar.html

 

 

 

 

 

Print Friendly