fbpx
× Share your code snippets, screen shots etc. here

VO GUI Classes: subclassed TabControl caveats

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
10 months 2 days ago #1 by Wolfgang Riedmann
VO GUI Classes: subclassed TabControl caveats was created by Wolfgang Riedmann
In my migration of my VO GUI application I have lost a lot of time because of some TabControl issues.
This could be important for everyone porting VO GUI applications with subclassed TabControls to X#.
The source of all problems is the fact that sometimes in the VO 2.8 development the parameters of 3 strong typed methods were changed from int to dword:
__FocusPage()
__GetPageFromIndex()
__GetSymbolFromIndex()
Earlier versions of the VO GUI SDK classes have these parameters typed as int, and the same is true for the Vulcan version.
My subclass of the TabControl, the DynamicTabControl, had overwritten these methods, and that has caused several problems and errors:
  • since the methods of the TabControl class and these of the DynamicTabControl class differed in their parameter list, the .NET runtime accepted them as different ones, and therefore the Send() function was not working anymore and gave a runtime error
  • fixed this issue, the __FocusPage() method called the wrong method because a dword was passed instead of an int, leaving the tabcontrol pages blank
The fix was not too easy at the first moment, but since I'm using my own (X# compiled) version of the VO GUI classes, I opted changing the calls there, so I can keep my VO and X# classes synchronized and xport my code often.

Wolfgang

P.S. fixing all the warnings the X# compiler gave, I found and fixed several errors in my framework library, some of them there for at least 10 or 15 years.

Please Log in or Create an account to join the conversation.

More
10 months 1 day ago - 10 months 1 day ago #2 by Chris Pyrgas
Replied by Chris Pyrgas on topic VO GUI Classes: subclassed TabControl caveats
Hi Wolfgang, all:

Just to explain the situation more to everybody, the code (simplified) in VO was:
CLASS TabControl // in the SDK dll
METHOD __FocusPage(nPage AS DWORD) AS VOID
METHOD SomeOtherCode()
SELF:__FocusPage(1) // this will call __FocusPage() in the child class

CLASS MyTabControl INHERIT TabControl // in user code
METHOD __FocusPage(nPage AS DWORD) AS VOID

Here the method in the child class overrides the one from the parent class, so when the parent code calls this method, it will be your implementation that will be called.

The problem is that in previous VO builds, the nPage param was defined AS INT instead of DWORD, and this is what the SDK dlls that come with vulcan have, too, so after porting the app, the code ended up as:
CLASS TabControl // in the SDK dll
METHOD __FocusPage(nPage AS INT) AS VOID
METHOD SomeOtherCode()
SELF:__FocusPage(1) // this will call __FocusPage() in the this class, instead of the child class

CLASS MyTabControl INHERIT TabControl // in user code
METHOD __FocusPage(nPage AS DWORD) AS VOID

here the methods have different param types, so are considered different by the CLR, so the method in the subclass does not override the parent one. The solution is very easy actually, to simply change the param type in the subclassed method to use also an INT, same as the parent method does. Only problem with this solution is that you couldn't have the exact same code working in both VO and X#, so the even better solution is what you did, to update the code in the SDK that you use in X# and change the parameter type there.

Chris

XSharp Development Team
chris(at)xsharp.eu
Last edit: 10 months 1 day ago by Chris Pyrgas. Reason: typos

Please Log in or Create an account to join the conversation.