Marco Web Center |
Home: Code Repository: Mastering Delphi 5Project ODSDEMO
Project StructureODSDEMO.DPRprogram OdsDemo; uses Forms, OdsForm in 'OdsForm.pas' {Form1}; {$R *.RES} begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; end. ODSFORM.PASunit OdsForm; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure FormCreate(Sender: TObject); public Total: Integer; end; var Form1: TForm1; implementation uses Math; {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); var X, Y: extended; begin X := 14.3; Y := 1 / GetTickCount; X := LogN (1/X, Y); Button1.Caption := IntToStr (Round (X)); end; procedure TForm1.Button2Click(Sender: TObject); var I, J: Integer; begin // J := 0; // omit this to get an error for I := 1 to 10000 do J := J + I; {$IFDEF DEBUG} OutputDebugString ( PChar ('Button2Click - I=' + IntToStr (I))); {$ENDIF} Button1.Caption := 'J = ' + IntToStr (J); Inc (Total, J); end; procedure TForm1.Button3Click(Sender: TObject); var s1, s2: string; begin s1 := Caption; s2 := s1; s2 [3] := 'X'; Caption := s2; {$IFDEF DEBUG} OutputDebugString ( PChar (s2)); {$ENDIF} end; procedure TForm1.FormCreate(Sender: TObject); begin Total := 0; end; end. ODSFORM.DFMobject Form1: TForm1 Left = 192 Top = 107 Width = 289 Height = 220 Caption = 'OdsDemo' Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = False OnCreate = FormCreate PixelsPerInch = 96 TextHeight = 13 object Button1: TButton Left = 96 Top = 32 Width = 75 Height = 25 Caption = 'Button1' TabOrder = 0 OnClick = Button1Click end object Button2: TButton Left = 96 Top = 72 Width = 75 Height = 25 Caption = 'Button2' TabOrder = 1 OnClick = Button2Click end object Button3: TButton Left = 96 Top = 112 Width = 75 Height = 25 Caption = 'Button3' TabOrder = 2 OnClick = Button3Click end end
|
||
© Copyright Marco Cantù, 1995-2020, All rights reserved |