Finding a form name at run time

Forums for specific tips, techniques and example code
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Finding a form name at run time

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:56 pm

by Pam >> Wed, 20 Sep 2006 2:10:27 GMT

I wish I had thought of this ages ago - I regularly need to edit, debug or work on a form but can't remember the name of the form. I have added a menu item to my application mdi frame which copies the name of the active form (non-modal) to the clipboard. The menu item method is simply app.copyStringToClipboard(self.name), or app.copyStringToClipboard(app.activeForm.name). Now press F4 in Class Browser to bring up the Type Browser, press Ctrl-V and the form is selected.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Finding a form name at run time

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:56 pm

by Darrell Duniam >> Wed, 20 Sep 2006 2:46:43 GMT

We take a different approach. We have a base form (which is a superclass of all other forms in our applications), and on the keyDown event of that base form, we call the code in the attached WorkSpace when Ctrl+F12 is pressed while the application is running... it gives you details of the active GUI objects (i.e. the current form and control).

cheers,
darrell.
Attachments
4586_1.wrk
(2.13 KiB) Downloaded 184 times
Last edited by ConvertFromOldNGs on Fri Aug 07, 2009 4:20 pm, edited 1 time in total.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Finding a form name at run time

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:56 pm

by BeeJay >> Fri, 22 Sep 2006 0:31:23 GMT

We do something similar with a key combination on our base form, but have taken it a step further to display a dialog with read only TextBoxes with the following details, so you can copy/paste this information as appropriate or easily inspect the underlying objects.

Form Name
Useful when you want to open the form in painter.

Control Name of the activeControl if applicable
Useful when you want to check properties of the control in painter, particularly in a multi-layered complex form structure where the control in question is not visible when the form is first opened in painter.

Form Current Object **
The underlying persistent data model object that is currently being displayed or edited.

Form Transaction Agent **
The underlying transient transaction agent that will be used to update or create the persistent data model object

Form Object **
The transient instance of the form object itself.

Control Current Object **
If applicable, the object associated with the control.
eg: In the case of a ComboBox the listObject for that ComboBox

** These four items also have Inspect buttons beside them that can be used to launch the Jade object inspector against that object.

Refer the attached screen dump for an example of this as a picture is often easier to understand.

To use a form like this does of course rely on a common superform for all your forms and a compatible persistent data model and transaction agent construct being used in the system in question.

Cheers,
BeeJay.
Attachments
4593.zip
(6.09 KiB) Downloaded 194 times


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 12 guests