Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.