This message was edited by lajevardi at 2005-6-21 22:5:12
: :
This message was edited by lajevardi at 2005-6-21 15:25:59
: : Hi guys;
: : i wanna write a procedure called "visiblize", that sets "Visible" property of every inVisible component to "True", then positioning it by changing "Top" & "left" properties;
: : See:
: :
: : visiblize(sendBtn,TButton,'Send',300,150); {Calling}
: :
: : viziblize(var componName:???; componType:???; capt:String;
: : topPos,leftPos:integer);
: : begin
: : If componName.Visible<>True Then
: : Begin
: : componName.Top:=topPos;
: : componName.Left:=leftPos;
: : componName.Caption:=capt;
: : componName.Visible:=True;
: : End;
: : end;
: :
: : But i donn know how i must set the TYPE of sent component(?);
: :
: : tnx alot;
: : be happy ;)
: :
: Here is an untested code to do what you want.
:
: procedure viziblize(Component: TComponent; capt:String; topPos,leftPos:integer);
: begin
: if Component is TControl then
: with TControl(Component) do
: Begin
: Top:=topPos;
: Left:=leftPos;
: SetTextBuf(PChar(capt));
: Visible:=True;
: End;
: end;
:
: If you check the help, you will see that the first class, which has a public Visible property is TControl. The best is to use that class as a basis for your procedure.
: The caption is a tricky one, because that is often only made public or published in the lowest descendant. Luckily the SetTextBuf(), which actually sets the Caption, is declared as a public method. This allows you to set the Caption without the need for further type-casting.
:
Bingo!
that's wonderfull,
thanks alot for ur help ;)