INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Finding Components problem

Finding Components problem

(OP)
Here I am attempting to access one of 3 Overlaid Panels, created on each of 4 tabs of a Page control.
The calling combobox change holds the Panel index, The combobox Tag holds the Required Tab number, The component names indicate the correct tab
The first tab is Called Channel1, and the Tabs are not auto created.
The problem is so that the procedure can access any panel on any tab it need to be able to find it . To illustrate the problem here 'C1ConstPan'
If I hard code the Correct tab Findcomponent works correctly (Commented out here) But SetupTabs.Findcomponent returns nil.

I also tried using SetupTabs.Findcomponet(Channel1) to get the Tab and then use Findcomponent on that to find the panel.
But again the first step returns nil, I guess this is because the Tabs are not components but properties?
Is there any way to do this?


CODE --> Delphi

procedure TBattForm.TypeChange(Sender: TObject);
var c: integer;
    Comp, Comp1: TComponent;
begin
   Comp := nil;
   C := (sender as TComboBox).Tag;
   case (sender as TComboBox).itemindex of
   CONSTANT: begin
            //    Comp1 := SetupTabs.FindComponent('Channel' + inttostr(C)); // nope returns nil
            //    Comp := Channel1.FindComponent('C' + inttostr(C)+ 'ConstPan');  // OK
                Comp := Setuptabs.FindComponent('C' + inttostr(C)+ 'ConstPan'); // Returns nil

              end;
   MAINT:    begin 
                // this works but needs the tab name
                Comp := Channel1.FindComponent('C' + inttostr(C)+ 'MaintPan');
             end;
   PULSE:    begin
                Comp := Channel1.FindComponent('C' + inttostr(C)+ 'PulsePan');
              end;
    end;

  if Comp  <> nil then
     (Comp as TPanel).BringToFront;
end; 

Steve: N.M.N.F.
If something is popular, it must be wrong: Mark Twain
That's just perfectly normal Paranoia everyone in the universe has that: Slartibartfast

RE: Finding Components problem

(OP)
Ah Think I got it...

Comp := Setuptabs.Pages[C-1].FindComponent('C' + inttostr(C)+ 'ConstPan');

Steve: N.M.N.F.
If something is popular, it must be wrong: Mark Twain
That's just perfectly normal Paranoia everyone in the universe has that: Slartibartfast

RE: Finding Components problem

(OP)
However that doesn't answer the question as to why the components cannot be found globally, as the Pre designed versions were.

Steve: N.M.N.F.
If something is popular, it must be wrong: Mark Twain
That's just perfectly normal Paranoia everyone in the universe has that: Slartibartfast

RE: Finding Components problem

(OP)
Good grief, should have created as Main form but set Parent to where I wanted them, then it works globally.

Steve: N.M.N.F.
If something is popular, it must be wrong: Mark Twain
That's just perfectly normal Paranoia everyone in the universe has that: Slartibartfast

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close