Getting the class name from an object - Form equivalent of i

Posted by tbergman on 08-Aug-2016 14:55

In a .net form, I could have controls directly on the form or user controls I've created. Is there a way, from a reference to any particular control, to determine the class that instantiated the control?

Basically the .net equivalent of instantiating-procedure.

Thanks,

Tom

All Replies

Posted by Peter Judge on 08-Aug-2016 15:36

No, not really.  Why do you need to know?

Posted by Peter Judge on 08-Aug-2016 15:36

Are you looking for an ABL mechanism or a .NET one?

Posted by tbergman on 09-Aug-2016 11:32

Yes, I’m looking for the ABL class name.
 
It’s useful for developers to be able to determine the name of the class when debugging problems. In our GUI application, a standard piece of code puts a trigger on every frame for the right-mouse double-click action. This allows developers/testers to easily determine where to look in the code if they identify a problem in the interface, want to add an additional choice or field etc. In addition to the program-name, we also go through the Program-Name(n) chain to see how the current object was called.
 
I’d like to be able to do the same with .net forms. The trigger is easy, but I can’t find a way to get to the name of the class.
 
Thanks,
 
Tom
 

Posted by bronco on 09-Aug-2016 12:58

wouldn't the debugger give you a decent call stack?

Posted by tbergman on 09-Aug-2016 14:17

In limited testing, I believe what I've posted below works. This is the trigger method that gets called.

METHOD PRIVATE VOID onMouseDoubleClick(INPUT sender AS System.Object, INPUT e AS System.Windows.Forms.MouseEventArgs):    
    IF e:BUTTON = System.Windows.Forms.MouseButtons:RIGHT THEN 
    DO:
      DEFINE VARIABLE objControl AS System.Windows.Forms.Control.
      objControl = CAST(sender, System.Windows.Forms.Control).
      
      MESSAGE 
        "Clicked on: " objControl:NAME SKIP  
        "Object Type: " sender:ToString() SKIP
        "In Container: " objControl:GetContainerControl():GetClass():TypeName SKIP
        "In form: " objControl:FindForm():GetClass():TypeName
        VIEW-AS ALERT-BOX.
    END.
  END.      

This thread is closed