602 views
in GUI Development by
Hi There,

In my application unit, my main class is AppClass which is of type Core::Root. (This is standard with a new project)

I also have a class defined in the application unit and an auto-instance of it. (I call it DeviceClass)

In my application, any interaction between my DeviceClass auto object and the AppClass seems to have to be limited to events, which I find to be a real pain. I don't have a way to access the members of AppClass directly. There must surely be a way of doing this?

Kind Regards,

Rob

1 Answer

0 votes
by

Hello Rob,

in fact there is no method to obtain access to the application instance except GetRoot(). GetRoot(), however, is limited to GUI components belonging to the application (components belonging to the view tree). In your case you intend to access the the application instance from some object which is not part of this view tree. What can you do?

Step 1: In your device class add a new variable to store there a reference to the application instance. Name it e.g. RootObject.

Step 2: I the application class add also a new variable to store there a reference to the DeviceClass autoobject. You can name it e.g. DeviceObject.

Step 3: In the application class override the Init method and implement following code to assign the autoobject to the DeviceObject variable and in the device object store the application instance in its own RootObject variable.

DeviceObject = YourUnit::Device;

DeviceObject.RootObject = this;

Step 4: In the DeviceObject you can access the application instance directly by using the RootObject variable.

Please note, the variable RootObject may remain initialized with null if you test some GUI component individually in the Prototyper without the application class or you edit a GUI component in Composer. In this case the application instance does not exist.

Does it help you further?

Best regards

Paul Banach

by
Hi Paul,

As always, your response is quick and concise. Thank you, it works fine :-)

Kind Regards,

Rob

Ask Embedded Wizard - Archive

Welcome to the Ask Embedded Wizard archive. This community forum served us well for many years, but we've evolved our support approach!

Your resources:

The Embedded Wizard Online Documentation provides comprehensive documentation, tutorials, examples and ready-to-use software packages.

For dedicated assistance, explore our Embedded Wizard Product Support.

You can still browse the valuable discussions from our community history here.

Embedded Wizard Website | Privacy Policy | Imprint

...