VO GUI Classes: subclassed TabControl caveats

Public forum to share code snippets, screen shorts, experiences, etc.
Post Reply
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

VO GUI Classes: subclassed TabControl caveats

Post by wriedmann »

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.
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

VO GUI Classes: subclassed TabControl caveats

Post by Chris »

Hi Wolfgang, all:

Just to explain the situation more to everybody, the code (simplified) in VO was:

Code: Select all

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:

Code: Select all

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
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Post Reply