Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding Components problem

Status
Not open for further replies.

sggaunt

Programmer
Jul 4, 2001
8,620
GB
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:
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
 
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
 
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
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top