Forum Discussion

Colin_McCrae's avatar
Colin_McCrae
Community Hero
9 years ago

BUG: Delphi label objects showing incorrectly in object heirarchy?

I'm currently working on a Delphi application.

 

Today, I've just run into some strange behaviour as to how TestComplete is finding label items. I've mapped all other controls (panels, tab containers, tabs, grids, textboxes, tree views, DB grids ... etc etc) and everything slotted into the object heirarchy exactly as I would expect.

 

However, I wanted to include a few static text fields. The application uses "TLabel" objects for these and they are correctly recognised as such and all properties etc are reported correctly. However, they are in completely the wrong place in the structure of the application in the object browser?!?!? I have no idea why. I have checked with the devs and looked at the panel designs in their IDE and they appear where I would expect them to. But they don't in TestComplete.

 

Example:

 

I have a module (a standalone exe). The modules main menu lets you launch various panels. Some of those panels contain tabs. The tabs then contain the controls and data I'm interested in.

 

So, what I would expect is:

 

Module

>Panel

>>Tab Container

>>>Tab 1

>>>Tab 2

>>>Tab 3

>>>>Container Panel

>>>>>TextBox Label 1

>>>>>TextBox 1

>>>>>Label 1 (display text only - no associated control)

>>>>>TextBox Label 2

>>>>>TextBox 2

>>>>Tab 4

>>>>>TextBox Label 3

>>>>>TextBox 3

>>>>>Label 2 (display text only - no associated control)

>>>>Tab 5

>>>>Tab 6

 

etc etc (This is how it looks on screen and also in the devs IDE)

 

Except, what is reported is:

 

Module

>Panel

>>TextBox Label 1

>>Label 1 (display text only - no associated control)

>>TextBox Label 2

>>TextBox Label 3

>>Label 2 (display text only - no associated control)

>>Tab Container

>>>Tab 1

>>>Tab 2

>>>Tab 3

>>>>Container Panel

>>>>>TextBox 1

>>>>>TextBox 2

>>>>Tab 4

>>>>>TextBox 3

>>>>Tab 5

>>>>Tab 6

 

Which is completely wrong!

 

All the labels (like every single one in the entire module) have been taken out of the tab containers and dumped outside the overall tabs container object as children of the top level panel. The controls they live alongside (but are not directly linked to in any way other than visually to the user) are all fine. This only seems to affect label objects?

 

Any ideas?

 

Is this a known probelm? Cos it seems like a dirty great bug in mapping Delphi applications to me ....

 

(Using TC 10.6. Application is written in Borland Delphi 6. Everything else is fine, it's just the labels)

7 Replies

  • m_essaid's avatar
    m_essaid
    Valued Contributor

    Hi Colin,

     

    I don't understand your problem, I usualy work on several Delphi applications (huges ones) and have never faced theses kind of problems.

    Just one thing : could you click on one the Delphi IDE on one of the very-end controls (actually "Label1" for example) and press Escape as many time as you need to select the TForm.

    Doing this you could verify your object hierarchy.

    • Colin_McCrae's avatar
      Colin_McCrae
      Community Hero

      Thanks for the reply.

       

      Just went over and sat with one of the devs for 5 minutes. Starting at a TLabel object in the panel design IDE, and pressing ESC repeatedly, follows the object heirarchy up the tree, exactly as you would expect and as you described. The heirarchy is correct.

       

      No idea why this isn't reflected in the object viewer in TestComplete.

       

      Even moreso if it's not happening to you!

      • m_essaid's avatar
        m_essaid
        Valued Contributor

        It's strange... Could you compile just once with full debug info (as described in Smartbear documentation) and see if it occurs again ?

  • m_essaid's avatar
    m_essaid
    Valued Contributor

    Colin,

     

    I checked out a big delphi app through the TC object browser.

    I think that the objects hierarchy in this browser is not how objects are positioned in the way you built the form.

    I think that the hierarchy is in fact the object model hierarchy.

    I mean :

    If you have a TForm and a several TLabel. The TLabel object is not a part of the TForm object. It is something completly different between putting a label on a form and declare it in the TForm = Class(TCustomForm) .pas.

    The object browser will show you the hierarchy of objects which inherits each from others.

    So sorry on the posts before I didn't understood the problem

     

    Mehdi

    • airsoft's avatar
      airsoft
      New Contributor

      I have the same problem: TLabel components are sorted first in property Controls [Index : integer] : TControl;

      My code is like this:

       

      TabSheet1 : TTabSheet (PageControl's TabSheet)

      for I := 1 to 4 do

      begin

        L := TLabel.Create(Self);

        L.Parent := TabSheet1;

        L.Caption := 'test';

        L.Left := 16;

        L.Top := 16 + (I - 1) * 24;

        L.Name := 'TLabel';

        E := TEdit.Create(Self);

        E.Parent := TabSheet1;

        E.Text := 'Input here';

        E.Left := 64;

        E.Top := 16 + (I - 1) * 24;

        E.Name := 'TEdit';

      end;

       

      and iteration in Controls like for I := 0 to ControlCount do ShowMessage (Controls [I].Name);

      show four TLabel and then four TEdit controls.

      • airsoft's avatar
        airsoft
        New Contributor

        Seems components of TControl are exported via Controls property before those of TWinControl, so I solved my problem when I've replaced TLabel with TStaticText. As far as I remember TWinControl uses more resources instead of TControl but my solved problem takes precedence :)