I found some topics but they seem to be API1.
I have a window with a Container. If I loop in the Controls I got a “IllegalCastException”.
Here’s the code:
Var CeCtrl as DesktopControl
Var CeRectCtrl as DesktopUIControl
For Each CeCtrl in Window1.Controls
If CeCtrl isa DesktopUIControl Then
CeRectCtrl = DesktopUIControl(CeCtrl) ’ Et NON RectControl(iNbre)
MessageBox "UI: " + CeCtrl.Name
Else
MessageBox "Not UI: " + CeCtrl.Name
End If ’ RectControl
Next CeCtrl
ControlsLoop.zip (8.4 KB)
How to workarround the crash? And how loop inside the controls of the container?
Note: If I remove the Container then no problem.
Thank you
DesktopContainer is not a subcless of DesktopControl (or DesktopUIControl). Your outer loop variable (CoCtrl) should be of type Object, then compare its value to see what type of object it is. Pseudocode incoming:
for each o as Object in self.Controls
select case o
case isa DesktopButton
'// Do something with a button
case isa DesktopUIControl
'// Do something else with another type
case isa DesktopContainer
var container as DesktopContainer = DesktopContainer( o )
for each co as Object in container.Controls
'// Do something with container contents
next
end select
next
5 Likes
Thank you, I just discovered Object and was trying with it. You gave the answer in the topic in 2001 but you were looping on Controls with currentControl as Control that’s why I wrote I found topic which seem API1.
Thanks again, I will try with objects.
Things were a bit different back in 2021. DesktopContainers actually show up in the Controls now, which was something we had to develop really hacky workarounds to get our hands on for many years as previously all that was included was EmbeddedWindowControl. The code I just supplied should get you what you need.