Marco's Web Center

Menu for Development

Site Menu
Object Pascal Handbook
Delphi Handbooks Collection
Mastering Borland Delphi 2005
(Old) White Papers
(Old)Tools
(Old) Conferences

My Other Sites
Italian Site (www.marcocantu.it)
the delphi search

Spirit of delphi

Advertising
Home My Blog Books Object Pascal Marco

Home: Code Repository: Mastering Delphi 6

Chapter 09 - Project ColorKeyHole

Project Structure

ColorKeyHole.dpr
program ColorKeyHole;

uses
  Forms,
  CkForm in 'CkForm.pas' {Form1},
  AlphaForm in 'AlphaForm.pas' {Form2},
  PlainForm in 'PlainForm.pas' {Form3};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TForm2, Form2);
  Application.CreateForm(TForm3, Form3);
  Application.Run;
end.
CkForm.pas
unit CkForm;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses
  AlphaForm, PlainForm;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2.Show;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  i: integer;
begin
  Form2.AlphaBlendValue := 100;
  Form2.Show;
  for i := 100 to 255 do
  begin
    Form2.AlphaBlendValue := i;
    Application.ProcessMessages;
  end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  Form3.Hide;
  AnimateWindow (Form3.Handle, 2000, AW_BLEND);
  Form3.Show;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  Form3.Hide;
  AnimateWindow (Form3.Handle, 3000, AW_CENTER);
  // you can also use AW_HOR_POSITIVE, AW_HOR_NEGATIVE,
  // AW_VER_POSITIVE, or AW_VER_NEGATIVE
  Form3.Show;
end;

end.
AlphaForm.pas
unit AlphaForm;

interface

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

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

var
  Form2: TForm2;

implementation

{$R *.DFM}

end.
PlainForm.pas
unit PlainForm;

interface

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

type
  TForm3 = class(TForm)
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form3: TForm3;

implementation

{$R *.DFM}

end.
CkForm.dfm
object Form1: TForm1
  Left = 215
  Top = 148
  Width = 405
  Height = 239
  AlphaBlendValue = 200
  Caption = 'Color Key Hole'
  Color = clBtnFace
  TransparentColor = True
  TransparentColorValue = clGreen
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Shape1: TShape
    Left = 195
    Top = 16
    Width = 181
    Height = 177
    Anchors = [akLeft, akTop, akRight, akBottom]
    Brush.Color = clGreen
    Pen.Style = psClear
    Pen.Width = 0
    Shape = stCircle
  end
  object Button1: TButton
    Left = 32
    Top = 32
    Width = 105
    Height = 25
    Caption = 'Alpha'
    TabOrder = 0
    OnClick = Button1Click
  end
  object Button2: TButton
    Left = 32
    Top = 72
    Width = 105
    Height = 25
    Caption = 'Fade In Alpha'
    TabOrder = 1
    OnClick = Button2Click
  end
  object Button3: TButton
    Left = 32
    Top = 112
    Width = 105
    Height = 25
    Caption = 'Fade In Plain'
    TabOrder = 2
    OnClick = Button3Click
  end
  object Button4: TButton
    Left = 32
    Top = 152
    Width = 105
    Height = 25
    Caption = 'Slide From Center'
    TabOrder = 3
    OnClick = Button4Click
  end
end
AlphaForm.dfm
object Form2: TForm2
  Left = 562
  Top = 214
  Width = 310
  Height = 228
  AlphaBlend = True
  AlphaBlendValue = 188
  Caption = 'AlphaTest'
  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 = 64
    Top = 96
    Width = 32
    Height = 13
    Caption = 'Label1'
  end
  object Button1: TButton
    Left = 64
    Top = 32
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 0
  end
  object Edit1: TEdit
    Left = 64
    Top = 112
    Width = 121
    Height = 21
    TabOrder = 1
    Text = 'Edit1'
  end
end
PlainForm.dfm
object Form3: TForm3
  Left = 504
  Top = 356
  Width = 354
  Height = 237
  Caption = 'PlainForm'
  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
end