#1 03.08.06 12:36
[Builder] [Delphi] помогите перевести..
Надо код на делфи переделать на билдер. Помогите!!
Вот код:
Код: delphi:
unit WinForml; interface uses System.Drawing, System.Collections, System.ComponentModel, System.Windows.Forms, System.Data, System.Globalization; type TWinForml = class(System.Windows.Forms.Form) {$REGION 'Designer Managed Code1} , strict private Components: System.ComponentModel.Container; Labell: System.Windows.Forms.Label; RadioButtonl: System.Windows.Forms.RadioButton; RadioButton2: System.Windows.Forms.RadioButton; . RadioButton3: System.Windows.Forms.RadioButton; RadioButton4: System.Windows.Forms.RadioButton; TextBoxl: System.Windows.Forms.TextBox; StatusBarl: System.Windows.Forms.StatusBar; GroupBoxl: System.Windows.Forms.GroupBox; procedure InitializeComponent; procedure TextBoxl_KeyPress(sender: System.Object; e: System.Windows.Forms.KeyPressEventArgs) procedure RadioButtonl_CheckedChanged(sender: System.Object; e: System.EventArgs); procedure RadioButton4_CheckedChanged(sender: System.Object; e: System.EventArgs); procedure RadioButton3_CheckedChanged(sender: System.Object; e: System.EventArgs); procedure RadioButton2_CheckedChanged(sender: System.Object; e: System.EventArgs); procedure TextBoxl_TextChanged(sender: System.Object; e: System.EventArgs); {$ENDREGION} strict protected procedure Dispose(Disposing: Boolean); override; private {Private Declarations} input_ch:integer; // Переменная для указания типа данных, II которые можно вводить в TextBoxl. II Обозначим числами следующие типы данных: /10- строка символов; 111- целое число; 112- дробное число; /13- пароль. ds:Char; public constructor Create; end; • [assembly: RuntimeRequiredAttribute(TypeOf(TWinForml))] implement ation {$AUTOBOX ON} procedure TWinForml.Dispose(Disposing: Boolean); begin if Disposing then begin if Components <> nil then Components.Dispose(); end; inherited Dispose(Disposing); end ; // Процедура, выполняемая в момент создания окна приложения. constructor TWinForml.Create; begin inherited Create; InitializeComponent; Компонент TextBox • input_ch:=0; . ds := NumberFormatlnfo.Currentlnfo.NumberDecimalSeparator[1]; StatusBarl.Panels.Add('0'); StatusBarl.Panels[0].AutoSize := StatusBarPanelAutoSize.Spring; end; > // Процедура определения нажатой клавиши (отображаемого символа). procedure TWinForml.TextBoxl_KeyPress(sender: System.Object; e: System.Windows.Forms.KeyPressEventArgs); begin if (e.KeyChar = Chr(8)) then exit; case input_ch of 0:; // Ввод строки текста - ограничений по вводу нет. 1: //Ввод целых чисел. case e.KeyChar of ' 0 ' . . ' 9 ' : ; '-': if TextBoxl.Text.IndexOf('-') о -1 then e.Handled := True; else e.Handled := True; end; 2: // Ввод дробных чисел. case e.KeyChar of '0' .. '9' : ; '-': if TextBoxl.Text.IndexOf('-') <> -1 then e.Handled := True; else if (e.KeyChar = NumberFormatlnfo.Currentlnfo.NumberDecimalSeparator[1]) then begin if (TextBoxl.Text.IndexOf(e.KeyChar) <> -1) then e.Handled : = True; end else e.Handled := True; end; 3: // Ввод пароля (отображается звездочками). case e.KeyChar of 10'..'9','A'..'z','A'..'я': if TextBoxl.Text.Length = 12 then e.Handled := True; else e.Handled := True; end; end; end;
Исправлено XuMiX (03.08.06 14:51)
Offline

