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 11 - Project CMNTest

Project Structure

CMNTest.dpr
program CMNTest;

uses
  Forms,
  CMNForm in 'CMNForm.pas' {Form1};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
CMNForm.pas
unit CMNForm;

interface

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

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Bevel1: TBevel;
  private
    { Private declarations }
  public
    procedure CMDialogKey(var Msg: TCMDialogKey); message cm_DialogKey;
    procedure CMDialogChar(var Msg: TCMDialogChar); message cm_DialogChar;
    procedure CmFocusChanged (var Msg: TCmFocusChanged); message cm_FocusChanged;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

{ TForm1 }

procedure TForm1.CMDialogChar(var Msg: TCMDialogChar);
begin
  Label1.Caption := Label1.Caption + Char (Msg.CharCode);
  inherited;
end;

procedure TForm1.CMDialogKey(var Msg: TCMDialogKey);
begin
  if (Msg.CharCode = VK_RETURN) then
  begin
    Perform (CM_DialogKey, VK_TAB, 0);
    Msg.Result := 1;
  end
  else
    inherited;
end;

procedure TForm1.CmFocusChanged(var Msg: TCmFocusChanged);
begin
  Label5.Caption := 'Focus on ' + Msg.Sender.Name;
end;

end.
CMNForm.dfm
object Form1: TForm1
  Left = 192
  Top = 107
  Width = 454
  Height = 282
  Caption = 'CMNTest'
  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 Bevel1: TBevel
    Left = 104
    Top = 136
    Width = 273
    Height = 89
  end
  object Label1: TLabel
    Left = 160
    Top = 152
    Width = 51
    Height = 13
    Caption = 'Shortcuts: '
  end
  object Label2: TLabel
    Left = 104
    Top = 24
    Width = 23
    Height = 13
    Caption = '&One:'
    FocusControl = Edit1
  end
  object Label3: TLabel
    Left = 104
    Top = 64
    Width = 21
    Height = 13
    Caption = '&Two'
    FocusControl = Edit2
  end
  object Label4: TLabel
    Left = 104
    Top = 104
    Width = 28
    Height = 13
    Caption = 'Th&ree'
    FocusControl = Edit3
  end
  object Label5: TLabel
    Left = 160
    Top = 184
    Width = 29
    Height = 13
    Caption = 'Focus'
  end
  object Edit1: TEdit
    Left = 160
    Top = 24
    Width = 121
    Height = 21
    Color = clWindow
    TabOrder = 0
    Text = 'Edit1'
  end
  object Edit2: TEdit
    Left = 160
    Top = 64
    Width = 121
    Height = 21
    Color = clWindow
    TabOrder = 1
    Text = 'Edit2'
  end
  object Edit3: TEdit
    Left = 160
    Top = 104
    Width = 121
    Height = 21
    Color = clWindow
    TabOrder = 2
    Text = 'Edit3'
  end
end