xsharp.eu • Best way to convert a method of Class Control
Page 1 of 1

Best way to convert a method of Class Control

Posted: Tue Mar 02, 2021 12:13 pm
by ic2
Last week I supervised the first steps to convert a large project from VO to X# which is maintained on site by one of my employees. They often use methods like this:

method ShowControl(lShow) CLASS Control
if lShow
self:Show()
else
self:Hide()
endif

return true

This makes it easy to quickly hide/show all controls in a screen.

In VOPorter this generates CLASS control_external_class INHERIT control which of course is not a solution to the problem.

Is there another way to solve this without creating subclasses for every type of control and changing 1000's of controls in 100's of windows to the inherited classes?

Dick

Best way to convert a method of Class Control

Posted: Tue Mar 02, 2021 12:23 pm
by wriedmann
Hi Dick,
since this method is only using public methods of the class, you can use an extension method:

Code: Select all

static class ControlExtensions
static method ShowControl( self oControl as control, lShow as logic ) as logic
if lShow
  oControl:Show()
else
  oControl:Hide()
endif
return true
end class
HTH

Wolfgang

Best way to convert a method of Class Control

Posted: Tue Mar 02, 2021 2:16 pm
by ic2
Thank you Wolfgang!

I've added your solution in my conversion documentation and my employee will apply it.

Dick