Logo New book: Delphi 2007 Handbook
My blog in online
Delphi tech support service: support.marcocantu.com
Google
  Web www.marcocantu.com

Menu for Development

Site Menu
Delphi 2007 Handbook
Mastering Borland Delphi 2005
Essential Pascal
Essential Delphi
Buy Books Online
Code Repository
Newsgroups
White Papers
Tools
Conferences
Training
Delphi Links
Contact Marco

My Other Sites
Italian Site (www.marcocantu.it)
Developers Newsgroups Browser (dev.newswhat.com)
My town (www.piazzacavalli.net)
the delphi search
Wintech Italia (my company)

Breaking News
Buy Mastering Borland Delphi 2005 from Amazon
Free ebook: Mastering Delphi Update for Delphi 2006

Advertising
Home My Blog Books My Bookstore Development Links 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