troubleshooting Question

I need a help to transfer a text to a scrollbox creating edits and labes

Avatar of hidrau
hidrauFlag for Brazil asked on
Delphi
15 Comments4 Solutions465 ViewsLast Modified:
Hello guys,

I have a text in a memoedit and I have scrollbox. I would like to transfer my text to scrollbox where
each word will turn into in a label or edit inside of my scrollbox.  

For exemple

Well, to create all words as label or edit in a scrollbox it is ok for me, I developed the code as you can see over here but I am having  a problem, if I change the scrollbox font size, some labels is over to another.

I don't know how to workaround with it, that is, how to consider the font size of my scrollbox and to give
the right space between labels and edits. Esq is a variable where is passed the value of left space.

Take a look at part of my code where my function create the labels and edits

  Function CriaObj(Obj: TWinControl; Esq, Topo, idx :Integer; Word, Tipo: String):Integer;
  var
    L   : TsLabel;
    Tam :Integer;
  begin

    if Tipo = 'Label' then
    begin
      L:=TsLabel.Create(Self);
      L.Parent  := Obj;
      L.Caption := UpperCase(Word);
      If ckDica.Checked Then
      Begin
        L.Hint := BuscaPalavraDicionario(IdiomaAtivo, Word);
      End;

      L.Tag := 1;
      L.Name := 'L' + IntToStr(idx);
      // L.Font.Style := [fsBold];
      L.SetBounds(Esq,Topo,100,15);
      // L.OnDblClick := TraduzPalavra;
      // L.OnMouseDown := LabelExpressao;
      Result:=Esq+Canvas.TextWidth(L.Caption)+10;
    end
    else
    begin
      SetLength(Edits,ContEdits+1);
      Edits[ContEdits]:=TsEdit.Create(Obj);
      Edits[ContEdits].Parent:=Obj;
      Edits[ContEdits].BorderStyle:=bsSingle;
      Edits[ContEdits].Text:='';
      // Edits[ContEdits].Font.Style := [fsBold];
      Edits[ContEdits].OnEnter := OnEnter;

      If ckDica.Checked Then
      Begin
        Edits[ContEdits].Hint := BuscaPalavraDicionario(IdiomaAtivo, Palavra);
        Edits[ContEdits].ShowHint := false;
      End;

      Edits[ContEdits].Ctl3D := False;
      Edits[ContEdits].Tag   := ContEdits;
      Edits[ContEdits].MaxLength:=Length(Palavra);
      Tam:=Canvas.TextWidth(Palavra)+10;
      Edits[ContEdits].SetBounds(Esq+3,Topo,Tam,15);
      Inc(ContEdits);
      Result:=Esq+Tam+10;
    End
  End;

I'd like a help on this
Thanks
Alex
ASKER CERTIFIED SOLUTION
Geert G
Oracle dba
Join our community to see this answer!
Unlock 4 Answers and 15 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 4 Answers and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros