Log in

View Full Version : TLabels in Forms



Bad Boy JH
08-14-2010, 12:59 PM
I am having some trouble with TLabels in forms, what it is doing is either going past the edge of the form, or going single word (basically) down the side of the form, and off the bottom...the first way is when the line that has been commented IS commented out, and the other is when its not commented out...If there is a SRL feature that stops this (I am not using SRL for this, its not for autoing...)
var
CrimeForm: TForm;
CFormYesBtn, CFormNoBtn: TButton;
Description: TLabel;

procedure ButtonClicked(Sender: TObject);
begin
case Sender of
CFormYesBtn : CrimeForm.ModalResult:= 1;
CFormNoBtn : CrimeForm.ModalResult:= 2;
end;
end;

procedure InitForm;
begin
CrimeForm := CreateForm;
CrimeForm.Left := 300;
CrimeForm.Top := 260;
CrimeForm.Width := 300;
CrimeForm.Height := 200;
CrimeForm.Caption := 'Option!';
CrimeForm.Color := ClWhite;

CFormYesBtn := TButton.Create(CrimeForm);
CFormYesBtn.Parent := CrimeForm;
CFormYesBtn.Left := 10;
CFormYesBtn.Top := 125;
CFormYesBtn.Height := 30;
CFormYesBtn.Width := 100;
CFormYesBtn.Caption := 'Yes';
CFormYesBtn.OnClick := @ButtonClicked

CFormNoBtn := TButton.Create(CrimeForm);
CFormNoBtn.Parent := CrimeForm;
CFormNoBtn.Left := 145;
CFormNoBtn.Top := 125;
CFormNoBtn.Height := 30;
CFormNoBtn.Width := 100;
CFormNoBtn.Caption := 'No';
CFormNoBtn.OnClick := @ButtonClicked

Description := TLabel.Create(CrimeForm);
Description.Parent := CrimeForm;
Description.Top := 60;
Description.Left := 10;
Description.Height := 100;
Description.Width := 250;
// Description.WordWrap := True;
Description.Caption := 'You got caught, and the judge sentenced you to gaol for 3 Turns.'
Description.Font.Size := 10;
Description.Font.Color := 0;
Description.Font.Name := 'Comic Sans MS';
Writeln('end of InitForm');
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
CrimeForm.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;


Function OpenForm: Boolean;
begin
SafeInitForm;
SafeShowFormModal;
case CrimeForm.ModalResult of
1 : Result := True;
2 : Result := False;
end;
end;

begin
OpenForm;
end.

Sex
08-15-2010, 12:11 AM
var
CrimeForm: TForm;
CFormYesBtn, CFormNoBtn: TButton;
Description: TLabel;

procedure ButtonClicked(Sender: TObject);
begin
case Sender of
CFormYesBtn : CrimeForm.ModalResult:= 1;
CFormNoBtn : CrimeForm.ModalResult:= 2;
end;
end;

procedure InitForm;
begin
CrimeForm := CreateForm;
CrimeForm.Left := 300;
CrimeForm.Top := 260;
CrimeForm.Width := 300;
CrimeForm.Height := 200;
CrimeForm.Caption := 'Option!';
CrimeForm.Color := ClWhite;

CFormYesBtn := TButton.Create(CrimeForm);
CFormYesBtn.Parent := CrimeForm;
CFormYesBtn.Left := 10;
CFormYesBtn.Top := 125;
CFormYesBtn.Height := 30;
CFormYesBtn.Width := 100;
CFormYesBtn.Caption := 'Yes';
CFormYesBtn.OnClick := @ButtonClicked

CFormNoBtn := TButton.Create(CrimeForm);
CFormNoBtn.Parent := CrimeForm;
CFormNoBtn.Left := 145;
CFormNoBtn.Top := 125;
CFormNoBtn.Height := 30;
CFormNoBtn.Width := 100;
CFormNoBtn.Caption := 'No';
CFormNoBtn.OnClick := @ButtonClicked;

Description := TLabel.Create(CrimeForm);
Description.Parent := CrimeForm;
Description.Top := 5;
Description.Left := 10;
Description.WordWrap := True;
Description.Height := 300;
Description.Width := 300;
Description.Caption := 'You got caught, and the judge sentenced you to gaol for 3 Turns.'
Description.Font.Size := 10;
Description.Font.Color := 0;
Description.Font.Name := 'Comic Sans MS';
Writeln('end of InitForm');
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
CrimeForm.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;


Function OpenForm: Boolean;
begin
SafeInitForm;
SafeShowFormModal;
case CrimeForm.ModalResult of
1 : Result := True;
2 : Result := False;
end;
end;

begin
OpenForm;
end.
Move the Width and Height declarations below where you set WordWrap to true.