Results 1 to 2 of 2

Thread: TLabels in Forms

  1. #1
    Join Date
    Dec 2009
    Location
    Newcastle, Australia
    Posts
    888
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default TLabels in Forms

    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...)
    SCAR Code:
    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.

    Current Script Project
    Pot of flour gatherer - 95% done

    Can't get Simba to work? Click here for a tutorial

  2. #2
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    SCAR Code:
    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.
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •