Mega Code Archive

 
Categories / Delphi / Examples
 

Createcomponentsdynamically

procedure TStepPropertiesForm.OldPutExitDataOnForm(eRecSet: RecordSet); //NOT CALLED: this was an early version that created EDIT BOXES on the fly: //but then we decided that putting container and exit data into LIST BOXES //would be a better idea... //we deal with edit boxes on the Exits page of the PageControl only here... var exitsNum: Integer; //objExit: Exit; //MTSaccessedOK: Boolean; exitName: String; tempString: String; exitID: Integer; idx: Integer; exitIDString: String; exitValue: String; exitOperator: String; totalWidthToPlayWith: Integer; totalHeightToPlayWith: Integer; widthPerGroup: Integer; heightPerGroup: Integer; startHeight: Integer; leftOffset: Integer; midOffset: Integer; topOffset: Integer; editBoxWidth: Integer; begin //SET UP A FEW DIMENSIONING VARIABLES... totalWidthToPlayWith := StepPropsPageControl.Pages[2].ClientWidth; //totalWidthToPlayWith := StepPropsPageControl.ActivePage.ClientWidth; //totalHeightToPlayWith := (StepPropsPageControl.ActivePage.ClientHeight - NumberEdit.Top + NumberEdit.Height); editBoxWidth := (totalWidthToPlayWith div 3); totalHeightToPlayWith := StepPropsPageControl.Pages[2].ClientHeight; exitsNum := eRecSet.RecordCount; heightPerGroup := (totalHeightToPlayWith div exitsNum); leftOffset := (totalWidthToPlayWith div 10); midOffset := (totalWidthToPlayWith div 3); topOffset := (totalHeightToPlayWith div 20); RemoveExistingComponents(StepPropsPageControl.Pages[2]); //GET DATA FROM THE MIDDLE TIER... //MTSaccessedOK := True; try //objExit := CoExit.Create; if (eRecSet.RecordCount > 0) then begin try idx := 0; eRecSet.MoveFirst; while not(eRecSet.EOF) do begin exitID := eRecSet.Fields['exitID'].Value; exitValue := eRecSet.Fields['value'].Value; exitOperator := eRecSet.Fields['operator'].Value; //the next method is NOT WORKING 07.02.02... //exitName := objExit.GetName(exitID); exitIDString := IntToStr(exitID); with TEdit.Create(StepPropsPageControl.Pages[2]) do begin Parent := StepPropsPageControl.Pages[2]; Width := editBoxWidth; Left := midOffset; Top := (topOffset + (heightPerGroup * idx)); //WE MAY NEED MORE DATA HERE //eg exit description[?] or //an image of the entity for this exit[?]... Text := 'ExitID: ' + exitIDString; //currently we can't test getting and using //exitValue and exitOperator because THE //MIDDLE TIER IS DOWN... Color := clBtnFace; end; with TEdit.Create(StepPropsPageControl.Pages[2]) do begin Parent := StepPropsPageControl.Pages[2]; Width := editBoxWidth; Left := leftOffset; Top := (topOffset + editBoxHeightPlusABit + (heightPerGroup * idx)); Text := 'Exit Value: ' + exitValue; Color := clBtnFace; end; with TEdit.Create(StepPropsPageControl.Pages[2]) do begin Parent := StepPropsPageControl.Pages[2]; Width := editBoxWidth; Left := (leftOffset + editBoxWidthPlusABit); Top := (topOffset + editBoxHeightPlusABit + (heightPerGroup * idx)); Text := 'Exit Operator: ' + exitOperator; Color := clBtnFace; end; Inc(idx); eRecSet.MoveNext; Inc(idx); end; except tempString := 'The program is having problems communicating across the network'; Application.MessageBox(PChar(tempString), ' Internal Error', mb_OK); end; end; except //MTSaccessedOK := False; tempString := 'The program is having problems communicating across the network'; Application.MessageBox(PChar(tempString), ' Internal Error', mb_OK); end; //objExit := nil; end;