visiblize() - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

visiblize()

lajevardilajevardi Posts: 42Member
[b][red]This message was edited by lajevardi at 2005-6-21 15:25:59[/red][/b][hr]
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:
[grey]
visiblize(sendBtn,TButton,'Send',300,150); [italic][green]{Calling}[/green][/italic]
[hr]
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;
[/grey]
But i donn know how i must set the TYPE of sent component(?);

tnx alot;
be happy ;)

Comments

  • zibadianzibadian Posts: 6,349Member
    : [b][red]This message was edited by lajevardi at 2005-6-21 15:25:59[/red][/b][hr]
    : 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:
    : [grey]
    : visiblize(sendBtn,TButton,'Send',300,150); [italic][green]{Calling}[/green][/italic]
    : [hr]
    : 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;
    : [/grey]
    : 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.
    [code]
    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;
    [/code]
    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.
  • lajevardilajevardi Posts: 42Member
    [b][red]This message was edited by lajevardi at 2005-6-21 22:5:12[/red][/b][hr]
    : : [b][red]This message was edited by lajevardi at 2005-6-21 15:25:59[/red][/b][hr]
    : : 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:
    : : [grey]
    : : visiblize(sendBtn,TButton,'Send',300,150); [italic][green]{Calling}[/green][/italic]
    : : [hr]
    : : 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;
    : : [/grey]
    : : 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.
    : [code]
    : 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;
    : [/code]
    : 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.
    :
    [hr]
    Bingo!
    that's wonderfull,
    thanks alot for ur help ;)


Sign In or Register to comment.