Im trying rearrange some buttons and im using this new iterator from the LR:
For Each c As DesktopControl In Self.Controls
If c IsA mySubClass Then
// do my thing
End If
Next
and its throwing an illegal cast exception on a pagePanel. The LR is pretty short and clear this should return DesktopControls so Im a bit stumped. I tried just ‘Control’ as the cast but also a no go. Can anyone spot my problem?
A PagePanel cannot be cast to a DesktopControl, it can however be cast to a Control, you’ll need to change the type after the As or change the panel to a DesktopPagePanel or change the type after the As to Variant
Julian - Variant works of course but I still dont believe whats in the LR doesnt work. The panel is a DesktopPagePanel. I cant quite figure out what was coming in as nil
In my local LR, “DesktopWindow.Controls” method. I am running 2021r3.1. The “Notes” section says all controls on the window are returned as DesktopControls but not the panel and then the nil? I’ll see if I can just unwind what im doing here into a binary…it works with variant but thats kind of bodge it seems to me.
Ok, both As ‘DesktopControl’ or ‘Control’ work in a blank project with roughly the same setup as in my app so its something to do with my meddling I guess. I wont bore you with the working binary and Im not going to spend any more time on it since it somehow seems to be self inflicted.