Assigning platform-specific Container

I need to refactor an app that uses a container control for platform-specific operations. Therefore, I’ve created a duplicate of the original ccLTFS1 container that was placed onto the parent window in the IDE, Deleted the ccLTFS1 Container instance, changed the original container to ccLTFSMain and named the new container ccLTFSWindows, and created a global property ccLTFS1 As ContainerControl.

At startup, I use the following code in the parent PagePanel’s Open event:

#If TargetWindows
  ccLTFS1 = New ccLTFSWindows
#Else
  ccLTFS1 = New ccLTFSMain 
#EndIf
ccLTFS1.EmbedWithinPanel(ppTools, 4, (WMain.Width - ccLTFS1.Width)/2, 0)
ccLTFS1.tmCheckLTFSMountStatus.Mode = 0

However, the call to ccLTFS1.tmCheckLTFSMountStatus.Mode = 0 is throwing an error:

Type "ContainerControl" has no member named "tmCheckLTFSMountStatus"

As well as for each control on the original container as I refer to it.

What am I missing about this type of dynamic container assignment?

ccLTFS1 is a ‘ContainerControl’ not a ccLTFSWindows
A basic containercontrol doesn’t have the properties and controls you expect.

if you have

ccLTFSW as ccLTFSWindows
and
ccLTFSM as ccLTFSMain

defined globally, then you can initialise like this in app open

#If TargetWindows
  ccLTFSW = New ccLTFSWindows
#Else
  ccLTFSM = New ccLTFSMain 
#EndIf

and then use access methods, like

Set_tmCheckLTFSMountStatus(0)

which contains

#If TargetWindows
  ccLTFSW.tmCheckLTFSMountStatus = value
#Else
  ccLTFSM.tmCheckLTFSMountStatus = value
#EndIf

========

How do these containercontrols vary?
If their exposed properties are the same, you MIGHT be able to cast one as the other…

#If TargetWindows
dim tmp as New ccLTFSWindows
ccLTFS1 = ccLTFSMain(ccLTFSWindows)
#Else
ccLTFS1 = New ccLTFSMain
#EndIf

I havent tried that…

1 Like

D’oh! Of course. :woozy_face:

They are the same - it’s just the functional logic behind the UI that differs. I’ll look at that further since having to refer to ccLTFSW and ccLTFSM for every referenced call outside of the instance will make for quite a headache.

containercontrol → subclass → ccLTFS → subclass ccLTFSWindows
ccLTFS → subclass ccLTFSMac
and put all the properties like tmCheckLTFSMountStatus and common methods in ccLTFS
and specific methods in ccLTFSWindows and ccLTFSMac

2 Likes

playing with Markdown …

1 Like

Nicely illustrated.

So, I’m still missing something with the Superclassing in this case.

2 Containers exist - ccLTFSWindows, ccLTFSMacLin

Public Properties - ccLTFSW As ccLTFSWindows, ccLTFSM As ccLTFSMacLin

Window property managed by

#if TargetWindows
    ccLTFS1 = New ccLTFSW    
#else
    ccLTFS1 = New ccLTFSM
#endif

However, I getting the same errors when I try to refer to WMain.ccLTFS1.XXXXXXX

I’ve also tried removing the ccLITFS1 global and creating them at WMain open.

#if TargetWindows
    Dim ccLTFS1 As New ccLTFSW    
#else
    Dim ccLTFS1 As New ccLTFSM
#endif

That then results in WMain does not have a property ccLTFS1 …

Well it doesnt… :slight_smile:
It only exists inside the Open event, and dies at the end

Put ccLTFS1 back as a Window property, of type ccLTFS

That done, does

dim tmp as New ccLTFSW 
ccLTFS1 = ccLTFS(tmp)

work?

2 Likes

Even though you are assigning an object of that type to the variable. It is, in fact, declared as an object of type ContainerControl (or desktop equivalent). That declaration (not shown) is the reason you get this issue.

2 Likes