Delphi and Kylix

Moderators: pritaeas
Number of threads: 7264
Number of posts: 19073

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
visiblize() Posted by lajevardi on 21 Jun 2005 at 3:13 PM
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 ;)
Report
Re: visiblize() Posted by zibadian on 21 Jun 2005 at 5:11 PM
: 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.
Report
Re: visiblize() Posted by lajevardi on 21 Jun 2005 at 10:04 PM
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 ;)





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.