We have a ui renderer that is responsible for creating all (Progress) widgets based on what the ui logic components are telling it to do. I have created a version that does the same for .Net controls, but am missing the dynamicness of vanilla Progress widgets.
For example to set the X of any widget on a Progress widget I just need the handle of the widget. I seem to be unable to do this generically for .Net controls. I am currently having to CAST the class (stored in my temp-table as a Progress.Lang.Object) to a temporary class variable defined as the .Net control that requires adjustment and only then applying the X (via Location). This is resulting in case statements with repeated code (but with a different class variable) for every attribute.
DYNAMIC-CAST works for passing an object into another object (for example clsForm:AddControls:Add( DYNAMIC-CAST( tt.cls, tt.cls_type ) - but I cannot DYNAMIC the left part (clsForm) to for example clsTextBox.
Is there a more efficient way to do this - similar to simply changing X on the widget-handle provided? Or do I need to have lots of repeated code within CASE statements?
The Location property is inherited by all controls from the System.Windows.Forms.Control class. You should be able to cast your object of class Progress.Lang.Object to System.Windows.Forms.Control and set the Location (or any other property of the Control class) generically.
You need to cast the control so you can access the property - in your example "X". The base classes PLO and System.Object do not have this property. There are some base classes for winforms that you can use to limit the number of case statements you will need. Take a look at msdn.microsoft.com/.../system.windows.forms.control(v=vs.110).aspx for example.
Good luck.
-Shelley
The Location property is inherited by all controls from the System.Windows.Forms.Control class. You should be able to cast your object of class Progress.Lang.Object to System.Windows.Forms.Control and set the Location (or any other property of the Control class) generically.
You need to cast the control so you can access the property - in your example "X". The base classes PLO and System.Object do not have this property. There are some base classes for winforms that you can use to limit the number of case statements you will need. Take a look at msdn.microsoft.com/.../system.windows.forms.control(v=vs.110).aspx for example.
Good luck.
-Shelley
Thanks both - that looks interesting for the common subset of properties.
hw:list-items for example will give a run-time error if the widget / object hw is pointing to does not support list-items. Combined with the can-query function (or accepting run-time errors) this keeps it nice and simple.
Thanks both - that looks interesting for the common subset of properties.
hw:list-items for example will give a run-time error if the widget / object hw is pointing to does not support list-items. Combined with the can-query function (or accepting run-time errors) this keeps it nice and simple.
Sorry, PropertyInfo, not TypeDescriptor.
Thanks again - this cleaned up a lot of copy / paste code.
I can live with the cases floating around - so will skip .Net reflection for now - thanks for the pointer though.