[lazarus] Label mystery solved probably...

Shane Miller SMiller1 at stvgb.org
Fri Apr 23 13:30:37 EDT 1999


Here's the code for changing the TLabelButton's label dynamically without creating and re-creating the label or button.


First things first....

Button2 : TLabelButton;


implementation

procedure something;
begin

Button2 := TLabelButton.Create(AOwner);

Button2.Left := 1;
Button2.Top := 70;
Button2.Height := 30;
Button2.Width := 75;
Button2.Caption := 'OLD CAPTION';
Button2.Show;
//Now the caption of the button is "OLD CAPTION".  I am going to change it...

with pgtkButton(Button2.fcomponent)^ do
gtk_label_set(pgtklabel(Child),'New Label');

//Now the label is "New Label"
// Button2.fcomponent is de-referneced so you can then access it's structure.  
//It's structure contains a child pgtkwidget  which I assumed was the label.  Seems to work.  Try it!

Writeln('Shane is cool!');
//  Needs this line to work :-)

end;

end.






More information about the Lazarus mailing list