Examples Delphi

unit DimDefs;
{Richard Ebbs for SSI/Honeywood...}
{October 1999...}
{'Default dimension' form code...}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, ComCtrls, GenUtils, Types, WireFrm;
const
EditBoxNames: array [0..31] of String = (
'DPCEdit',
'DWallEdit',
'TransomDropEdit',
'PHeightEdit',
'BayPoleEditW',
'BoxGutterEditW',
'EavesBeamEditW',
'EdgeRafterEditW',
'DrainPipeEditW',
'HippRafterEditW',
'MullionEditW',
'PurlinEditW',
'RidgeEditW',
'RoofRafterEditW',
'TransomProfEditW',
'ValleyRafterEditW',
'WallPlateEditW',
'WallRafterEditW',
'BayPoleEditH',
'BoxGutterEditH',
'EavesBeamEditH',
'EdgeRafterEditH',
'DrainPipeEditH',
'HippRafterEditH',
'MullionEditH',
'PurlinEditH',
'RidgeEditH',
'RoofRafterEditH',
'TransomEditH',
'ValleyRafterEditH',
'WallPlateEditH',
'WallRafterEditH');
type
TDimDefaultsForm = class(TForm)
FoxImage: TImage;
DefDimsPageControl: TPageControl;
OverallDimsSheet: TTabSheet;
ProfDimsSheet: TTabSheet;
ExtraSheet: TTabSheet;
DPCLabel: TLabel;
DPCEdit: TEdit;
DWallLabel: TLabel;
DWallEdit: TEdit;
TransomLabel: TLabel;
TransomDropEdit: TEdit;
PHeightLabel: TLabel;
PHeightEdit: TEdit;
ExitButton: TButton;
Label1: TLabel;
BayPoleLabel: TLabel;
BoxGutterLabel: TLabel;
EavesBeamLabel: TLabel;
HippRafterLabel: TLabel;
MullionLabel: TLabel;
PurlinLabel: TLabel;
RidgeLabel: TLabel;
RoofRafterLabel: TLabel;
TransomProfLabel: TLabel;
ValleyRafterLabel: TLabel;
WallPlateLabel: TLabel;
WallRafterLabel: TLabel;
BayPoleEditW: TEdit;
BoxGutterEditW: TEdit;
EavesBeamEditW: TEdit;
EdgeRafterEditW: TEdit;
DrainPipeEditW: TEdit;
HippRafterEditW: TEdit;
MullionEditW: TEdit;
PurlinEditW: TEdit;
RidgeEditW: TEdit;
RoofRafterEditW: TEdit;
TransomEditW: TEdit;
ValleyRafterEditW: TEdit;
WallPlateEditW: TEdit;
WallRafterEditW: TEdit;
EdgeRafterLabel: TLabel;
DrainPipeLabel: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
BayPoleEditH: TEdit;
BoxGutterEditH: TEdit;
EavesBeamEditH: TEdit;
EdgeRafterEditH: TEdit;
DrainPipeEditH: TEdit;
HippRafterEditH: TEdit;
MullionEditH: TEdit;
PurlinEditH: TEdit;
RidgeEditH: TEdit;
RoofRafterEditH: TEdit;
TransomProfEditH: TEdit;
ValleyRafterEditH: TEdit;
WallPlateEditH: TEdit;
WallRafterEditH: TEdit;
SetNewValuesButton: TButton;
procedure ExitButtonClick(Sender: TObject);
procedure SetNewValuesButtonClick(Sender: TObject);
procedure ProcessAllEditBoxText;
procedure SetADefDimsValue(boxName: String; dimValue: Real);
private
{private declarations}
dDims: TDefaultDimensions;
public
{public declarations}
end;
var
DimDefaultsForm: TDimDefaultsForm;
implementation
{$R *.DFM}
procedure TDimDefaultsForm.ExitButtonClick(Sender: TObject);
begin
ProcessAllEditBoxText;
wireFrame.SetDimensionDefaults(dDims);
Close;
end;
procedure TDimDefaultsForm.SetNewValuesButtonClick(Sender: TObject);
begin
ProcessAllEditBoxText;
wireFrame.SetDimensionDefaults(dDims);
end;
procedure TDimDefaultsForm.ProcessAllEditBoxText;
var
count: Integer;
idx : Integer;
temp : TComponent;
arrayPos: Integer;
tempReal: Real;
begin
for idx := 0 to (ComponentCount - 1) do
begin
temp := Components[idx];
if (temp is TEdit) then
begin
arrayPos := -1;
for count := Low(EditBoxNames) to High(EditBoxNames) do
begin
if UpperCase(TEdit(Temp).Name) = UpperCase(EditBoxNames[count]) then
begin
arrayPos := count;
break;
end;
//DeBugging
{ShowMessage('Component name: ' + TEdit(Temp).Name +
'Text: ' + TEdit(Temp).Text +
'Array position: ' + IntToStr(arrayPos));}
if (GenUtils.IsConvertibleToFloat(TEdit(Temp).Text)) then
begin
tempReal := StrToFloat(TEdit(Temp).Text);
SetADefDimsValue(TEdit(Temp).Text, tempReal);
end;
end;
end;
end;
end;
procedure TDimDefaultsForm.SetADefDimsValue(boxName: String; dimValue: Real);
begin
if (boxName = 'DPCEdit') then
dDims.DPCHeight := dimValue;
if (boxName = 'DWallEdit') then
dDims.dwarfWallHeight := dimValue;
if (boxName = 'TransomDropEdit') then
dDims.transomDrop := dimValue;
if (boxName = 'PHeightEdit') then
dDims.panelHeight := dimValue;
if (boxName = 'BayPoleEditW') then
dDims.bayPoleW := dimValue;
if (boxName = 'BoxGutterEditW') then
dDims.boxGutterW := dimValue;
if (boxName = 'EavesBeamEditW') then
dDims.eavesBeamW := dimValue;
if (boxName = 'EdgeRafterEditW') then
dDims.edgeRafterW := dimValue;
if (boxName = 'DrainPipeEditW') then
dDims.drainPipeW := dimValue;
if (boxName = 'HippRafterEditW') then
dDims.hippRafterW := dimValue;
if (boxName = 'MullionEditW') then
dDims.mullionW := dimValue;
if (boxName = 'PurlinEditW') then
dDims.purlinW := dimValue;
if (boxName = 'RidgeEditW') then
dDims.ridgeW := dimValue;
if (boxName = 'RoofRafterEditW') then
dDims.roofRafterW := dimValue;
if (boxName = 'TransomProfEditW') then
dDims.transomW := dimValue;
if (boxName = 'ValleyRafterEditW') then
dDims.valleyRafterW := dimValue;
if (boxName = 'WallPlateEditW') then
dDims.wallPlateW := dimValue;
if (boxName = 'WallRafterEditW') then
dDims.wallRafterW := dimValue;
if (boxName = 'BayPoleEditH') then
dDims.bayPoleH := dimValue;
if (boxName = 'BoxGutterEditH') then
dDims.boxGutterH := dimValue;
if (boxName = 'EavesBeamEditH') then
dDims.eavesBeamH := dimValue;
if (boxName = 'EdgeRafterEditH') then
dDims.edgeRafterH := dimValue;
if (boxName = 'DrainPipeEditH') then
dDims.drainPipeH := dimValue;
if (boxName = 'HippRafterEditH') then
dDims.hippRafterH := dimValue;
if (boxName = 'MullionEditH') then
dDims.mullionH := dimValue;
if (boxName = 'PurlinEditH') then
dDims.purlinH := dimValue;
if (boxName = 'RidgeEditH') then
dDims.ridgeH := dimValue;
if (boxName = 'RoofRafterEditH') then
dDims.roofRafterH := dimValue;
if (boxName = 'TransomEditH') then
dDims.transomH := dimValue;
if (boxName = 'ValleyRafterEditH') then
dDims.valleyRafterH := dimValue;
if (boxName = 'WallPlateEditH') then
dDims.wallPlateH := dimValue;
if (boxName = 'WallRafterEditH') then
dDims.wallRafterH := dimValue;
end;
end.