Salve

Sto sviluppando applicativi in Delphi con embarcadero RAD studio XE a scopo didattico personale (voglio imparare a programmare in delphi)

ho fatto un piccolo convertitore banale solo che non mi funziona la scelta radio per il tipo di dato da convertire. cioè in base alla scelta del radiogrup dovrebbero cambiare i valori di conversione e i label delle TEdit dove si inserisce il numero da convertire ma non va

ecco il codice :

codice:
unit Convertitore;

interface

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

type
  TForm1 = class(TForm)
    Miglia: TEdit;
    Chilometri: TEdit;
    miglialbl: TLabel;
    chilometrilbl: TLabel;
    arrotonda: TCheckBox;
    gruppomisure: TRadioGroup;
    pollicitocentimetri: TRadioButton;
    pieditometri: TRadioButton;
    iardetometri: TRadioButton;
    migliatochilometri: TRadioButton;
    procedure ChilometriChange(Sender: TObject);
    procedure MigliaChange(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure gruppomisureClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Conv: Extended;
implementation

{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
    Conv := 2.54 ; // Inizio a dichiarare la variabile dai pollici
    // Inizializzo campi di testo
    Chilometri.Text := '0' ;
    Miglia.Text := '0' ;
end;

procedure TForm1.gruppomisureClick(Sender: TObject);
begin
  case gruppomisure.ItemIndex of // Effettuo dei cambiamentri al convertitore in base alla scelta della radio
      0: begin
          Conv := 2.54 ; // Pollici
          miglialbl.Caption := 'Pollici' ;
          chilometrilbl.Caption := 'Centimetri' ;
          end;
      1: begin
          Conv := 0.30 ; // Piedi
          miglialbl.Caption := 'Piedi' ;
          chilometrilbl.Caption := 'Metri' ;
          end;
      2: begin
          Conv := 0.9 ; // Iarde
          miglialbl.Caption := 'Iarde' ;
          chilometrilbl.Caption := 'Metri' ;
          end;
  end;
  miglia.Text := '0' ;
  chilometri.Text := '0' ;
end;

procedure TForm1.ChilometriChange(Sender: TObject);
var
  val: extended ;
begin
    if Chilometri.focused then  // Evitiamo Cambiamenti a Cascata
    begin
    // 0.39 = 1/ 2.54
    val := StrtoFloat(Chilometri.Text) / Conv ;
    if  arrotonda.Checked then
        val := Round(val) ; // Arrotondamento se necessario
    miglia.Text := FloattoStr(val) ;
    end;
end;

procedure TForm1.MigliaChange(Sender: TObject);
var
  val: extended ;
begin
  if Miglia.focused then // Eviatiamo cambiamenti a cascata
  begin
  val := Conv * StrtoFloat(Miglia.Text) ;
  if arrotonda.Checked then
        val := Round(val) ;
  chilometri.Text := FloattoStr(val) ;
  end;
end;
end.
Questo è il codice per disegnare la form

codice:
object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 213
  ClientWidth = 276
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object miglialbl: TLabel
    Left = 8
    Top = 169
    Width = 36
    Height = 13
    Caption = 'Miglia : '
  end
  object chilometrilbl: TLabel
    Left = 152
    Top = 169
    Width = 57
    Height = 13
    Caption = 'Chilometri : '
  end
  object Miglia: TEdit
    Left = 8
    Top = 188
    Width = 121
    Height = 21
    TabOrder = 4
    OnChange = MigliaChange
  end
  object Chilometri: TEdit
    Left = 152
    Top = 188
    Width = 121
    Height = 21
    TabOrder = 5
    OnChange = ChilometriChange
  end
  object arrotonda: TCheckBox
    Left = 8
    Top = 146
    Width = 97
    Height = 17
    Caption = 'Arrotonda'
    TabOrder = 6
  end
  object gruppomisure: TRadioGroup
    Left = 8
    Top = 8
    Width = 265
    Height = 132
    Caption = 'Opzioni di conversione: '
    TabOrder = 7
    OnClick = gruppomisureClick
  end
  object pollicitocentimetri: TRadioButton
    Left = 24
    Top = 32
    Width = 113
    Height = 17
    Caption = 'Pollici/Centimetri'
    TabOrder = 0
  end
  object pieditometri: TRadioButton
    Tag = 1
    Left = 24
    Top = 55
    Width = 113
    Height = 17
    Caption = 'Piedi/Metri'
    TabOrder = 1
  end
  object iardetometri: TRadioButton
    Tag = 2
    Left = 24
    Top = 78
    Width = 113
    Height = 17
    Caption = 'Iarde/Metri'
    TabOrder = 2
  end
  object migliatochilometri: TRadioButton
    Tag = 3
    Left = 24
    Top = 101
    Width = 113
    Height = 17
    Caption = 'Miglia/Chilometri'
    TabOrder = 3
    OnClick = gruppomisureClick
  end
end