Marco Cantù 1998, Mastering Delphi 4

Project: WHANDLE.DPR


Project Structure


WHANDLE.DPR

program WHandle;

uses
  Forms,
  WHandleF in 'WHandleF.pas' {FormWHandle};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TFormWHandle, FormWHandle);
  Application.Run;
end.

WHANDLEF.PAS

unit WHandleF;

interface

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

type
  TFormWHandle = class(TForm)
    BtnCallAPI: TButton;
    procedure FormCreate(Sender: TObject);
    procedure BtnCallAPIClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormWHandle: TFormWHandle;

implementation

{$R *.DFM}

procedure TFormWHandle.FormCreate(Sender: TObject);
begin
  Caption := Caption + ' ' + IntToStr (Handle);
end;

procedure TFormWHandle.BtnCallAPIClick(Sender: TObject);
begin
  SetWindowText (Handle, 'Hi');
end;

end.

WHANDLEF.DFM

object FormWHandle: TFormWHandle
  Left = 201
  Top = 124
  Width = 259
  Height = 115
  Caption = 'Window Handle'
  Font.Charset = ANSI_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object BtnCallAPI: TButton
    Left = 72
    Top = 24
    Width = 81
    Height = 33
    Caption = 'Call API'
    TabOrder = 0
    OnClick = BtnCallAPIClick
  end
end


Copyright Marco Cantù 1998