fbpx
Welcome, Guest
Username: Password: Remember me
Visual Objects

Please use this forum to post questions about Visual Objects and Vulcan.NET

TOPIC:

Transferring large VO project to X# 05 May 2021 02:24 #18312

  • GlenT
  • GlenT's Avatar
  • Topic Author


  • Posts: 27
  • I am inspired by Chris's videos on migrating VO projects to X# and have tentatively dipped my toe in the X# world. At this stage, I am trying to prove that it can be done and done in a reasonable time frame ( < 6 months).

    I admit to being .net novice and that I have much to learn. I've tried a few times but have always found something that needs to be done in VO and lost any knowledge that I gained.

    So, I exported the application and imported the aefs into Xide. I think that will be easier than added the Visual Studio's learning curve to that of .net.

    Apart from VO, I have used a number of external libraries over the years (the application is 20+ years old) such as:
    SEmenuXP
    ReportPro 2
    RightSLE
    PPP (a copy protection library) - already compiling
    MDI Taskbar from James-Donald Carslaw
    Funcky - already compiling
    Fab Zip
    Fab Tools
    Fab Thread
    Fab Paint
    bBrowser
    G2antt (from Excontrol) - an ocx
    Flipper Graph - an ocx

    So the question is, do I need X# versions of these libraries or do I just plough through them correcting errors as I find them?

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

    Transferring large VO project to X# 05 May 2021 10:35 #18316

    • Chris
    • Chris's Avatar


  • Posts: 2566
  • Hi Glen,

    Very glad to hear that those sessions were helpful for that!

    About 3rd party libraries, fortunately most of them have been ported already to X#. You can find them:

    - bBrowser: www.bbrowser.net/index.php/en/
    - Fab libraries: www.fabtoys.net/
    - ReportPro2: www.xsharp.eu/store/shop/
    - SEmenuXP and RightSLE: Those should not be very difficult to compile in X#, but I am pretty sure others have already done it, so no point reinventing the wheel. So can somebody step in please about that?
    - OCX controls: If those have equivalent .Net libraries available, it's best to use those. If not, it's not a problem either, please read the complete topic "Migrating apps from VO to X#" to see what you need to do about them (among much other very helpful information).
    - I am not familiar with the rest, need to try them and see if it's easy to port them to X#. Remember that compiling them is one step, but there's another one, making sure they work correctly at runtime, and doing that might require more work, if they are doing low lever tricks and stuff like that.

    In any case, please do ask here about any issues you are getting or for suggestions on what to do with any aspect of the porting process. Here's also a list of tips Wolfgang has collected over the last few years: docs.xsharp.it/doku.php
    XSharp Development Team
    chris(at)xsharp.eu

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

    Transferring large VO project to X# 05 May 2021 11:49 #18323

    • jonhn


  • Posts: 27
  • Hi Glen,
    Welcome! I am also working slowly on a 20+ year old VO app to bring to .NET and you'll find a lot of extremely helpful and knowledgeable people here to help.

    Attached you will find Willies' RightSLE for X#. (thank you Willie)

    I have made a couple of false starts and for me a lot of the problem is errors and warnings in my VO program that the compiler ignored pretty much and tolerated in the final .exe.

    My tip is to go into the VO compiler properties, and under Clipper compatibility untick the "Undeclared Variables" option and start fixing as many errors as possible.
    The VO compiler is very forgiving with that option ticked, and since fixing most of the errors in the list my app has a lot less "undocumented features". The DBServer errors (I have a lot) can be ignored as the XIDE will take care of them in the conversion.
    hopefully that helps - I'm nearly ready to try converting again.

    Good luck,
    Jonathan
    Attachments:

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

    Transferring large VO project to X# 05 May 2021 12:23 #18326

    • Chris
    • Chris's Avatar


  • Posts: 2566
  • Thanks for stepping in Jonathan!

    Just a comment though, even though I agree it is a very good idea to untick "Undeclared Variables", this is not mandatory for porting to X# anymore. Since some builds ago, MEMVARs should be working in X# more or less the same way as in VO, so you should not need to change your code anymore if you do not want to.

    As I said, I agree it's better to do it anyway and use normal vars instead of publics and privates so that the compiler generates better and type checked code, but if you do not want to do it, in order to avoid modifying too much existing code, you should be able to leave it as it is, too. If you are still getting problems with compiling existing code that uses memvars, then this is porbably a bug in X# or something we have overlooked.
    XSharp Development Team
    chris(at)xsharp.eu

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

    Transferring large VO project to X# 05 May 2021 19:15 #18331

    • diobrando


  • Posts: 20
  • Chris,

    FabTools is not complete. I've downloaded source from GitHub (only FabTools, not the other libs) with relative .xsproj file and this gives error when importing in VS2019.

    I'm missing something?

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

    Last edit: by diobrando.

    Transferring large VO project to X# 05 May 2021 21:55 #18332

    • jonhn


  • Posts: 27
  • Try this version of FAB tools attached.

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

    Transferring large VO project to X# 05 May 2021 21:58 #18333

    • jonhn


  • Posts: 27
  • Yes, you are quite right. I was, however, surprised by the dozens of relatively serious other errors the VO compiler let through to my .exe that X# will not. All kinds of warnings I had ignored for years, sorry to say, but they are all listed there.

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

    Transferring large VO project to X# 05 May 2021 22:48 #18335

    • ic2


  • Posts: 995
  • Hello John,

    jonhn wrote: I was, however, surprised by the dozens of relatively serious other errors the VO compiler let through to my .exe that X# will not. All kinds of warnings I had ignored for years, sorry to say, but they are all listed there.


    I think that is one of the advantages of X#. IT can even be used to make your VO code better. I have done a couple of Transporter sessions and try to solve the errors in VO. That makes a full transitions (if ever...) to X# a lot less time consuming, but in the meantime the VO code is also better.

    Dick

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

    Transferring large VO project to X# 06 May 2021 02:22 #18338

    • GlenT
    • GlenT's Avatar
    • Topic Author


  • Posts: 27
  • Thanks Chris. I'll have a look at the links for the 3rd party stuff. No doubt I'll have many questions over the next few months.

    Cheers

    Glen

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

    Transferring large VO project to X# 06 May 2021 02:27 #18339

    • GlenT
    • GlenT's Avatar
    • Topic Author


  • Posts: 27
  • Jonathan,

    Thanks for the copy of RightSLE.

    I already have "Undeclared Variables" unticked so maybe I will have few less problems.

    Cheers

    Glen

    jonhn wrote: Hi Glen,
    Welcome! I am also working slowly on a 20+ year old VO app to bring to .NET and you'll find a lot of extremely helpful and knowledgeable people here to help.

    Attached you will find Willies' RightSLE for X#. (thank you Willie)

    I have made a couple of false starts and for me a lot of the problem is errors and warnings in my VO program that the compiler ignored pretty much and tolerated in the final .exe.

    My tip is to go into the VO compiler properties, and under Clipper compatibility untick the "Undeclared Variables" option and start fixing as many errors as possible.
    The VO compiler is very forgiving with that option ticked, and since fixing most of the errors in the list my app has a lot less "undocumented features". The DBServer errors (I have a lot) can be ignored as the XIDE will take care of them in the conversion.
    hopefully that helps - I'm nearly ready to try converting again.

    Good luck,
    Jonathan

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

    Transferring large VO project to X# 06 May 2021 02:28 #18340

    • GlenT
    • GlenT's Avatar
    • Topic Author


  • Posts: 27
  • That's one of the compelling reason for doing this trial.

    Glen

    jonhn wrote: Yes, you are quite right. I was, however, surprised by the dozens of relatively serious other errors the VO compiler let through to my .exe that X# will not. All kinds of warnings I had ignored for years, sorry to say, but they are all listed there.

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

    Transferring large VO project to X# 06 May 2021 04:03 #18341

    • GlenT
    • GlenT's Avatar
    • Topic Author


  • Posts: 27
  • OK. I've got RightSLE compiling successfully with one warning that I can't understand. The warning is:

    warning XS9068: The compiler generated an automatic conversion to PSZ. This may create a memory leak in your application. Please use String2Psz() to let the compiler manage the lifetime of the PSZ or use StringAlloc() and manage the lifetime of the PSZ yourself.

    and the offending line is line is

    AppendMenu( hMenu, MF_STRING, ID_MONTH1 + (DWORD)(i-1), SELF:aMonthsbyName)

    in the EditMonth() method of PECalendar.prg

    The parameters being passed are OK as far as I can see.

    Cheers

    Glen

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

    Transferring large VO project to X# 06 May 2021 06:03 #18342

    • diobrando


  • Posts: 20
  • jonhn wrote: Try this version of FAB tools attached.


    Thanks jonhn
    these are the dll that I already have.

    I was trying to compile the FabTools source code I've downloaded from GitHub but this gives me error when importing FabTools.xsproj or FabTools.sln in VS19 (and in XIDE too)

    maybe this needs to be updated from Fabrice or I'm doing something wrong

    ciao
    Stefano

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

    Last edit: by diobrando.

    Transferring large VO project to X# 06 May 2021 07:54 #18343

    • robert
    • robert's Avatar


  • Posts: 2222
  • Glen,
    AppendMenu is a windows API function in the VOWin32ApiLibrary.
    This function expects a PSZ as last parameter.
    You are (Willie is) passing in an array element.
    To "satisfy" the compiler this Array element needs to be converted from a USUAL (array elements are untyped) to a PSZ. Of course that will only work when the array contains strings.

    The compiler does not know what AppendMenu is doing with the PSZ. It could be making a copy of it, but it could also store the address of the PSZ and hold on to it. For that reason it cannot compile this into a call of String2Psz() since the PSZs allocated by that function will be automatically freed when the calling function ends.
    For that reason the compiler creates an instance of the PSZ type and simply does not free that type.
    Something like:
    AppendMenu( hMenu, MF_STRING, ID_MONTH1 + (DWORD)(i-1), PSZ{ (STRING) SELF:aMonthsbyName})
    The PSZ type allocates a block of static memory and converts the string from Unicode to Ansi and stores this Ansi string in the static memory.
    If you know that AppendMenu does not hold on to the PSZ but makes a copy (which it does) then you should change the code to:
    AppendMenu( hMenu, MF_STRING, ID_MONTH1 + (DWORD)(i-1), String2Psz(SELF:aMonthsbyName))

    Robert
    XSharp Development Team
    The Netherlands

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

    Transferring large VO project to X# 06 May 2021 08:50 #18345

    • GlenT
    • GlenT's Avatar
    • Topic Author


  • Posts: 27
  • Robert,

    Thank you for the solution and particularly the detailed explanation. I have much to learn I think.

    Cheers

    Glen

    robert wrote: Glen,
    AppendMenu is a windows API function in the VOWin32ApiLibrary.
    This function expects a PSZ as last parameter.
    You are (Willie is) passing in an array element.
    To "satisfy" the compiler this Array element needs to be converted from a USUAL (array elements are untyped) to a PSZ. Of course that will only work when the array contains strings.

    The compiler does not know what AppendMenu is doing with the PSZ. It could be making a copy of it, but it could also store the address of the PSZ and hold on to it. For that reason it cannot compile this into a call of String2Psz() since the PSZs allocated by that function will be automatically freed when the calling function ends.
    For that reason the compiler creates an instance of the PSZ type and simply does not free that type.
    Something like:

    AppendMenu( hMenu, MF_STRING, ID_MONTH1 + (DWORD)(i-1), PSZ{ (STRING) SELF:aMonthsbyName})
    The PSZ type allocates a block of static memory and converts the string from Unicode to Ansi and stores this Ansi string in the static memory.
    If you know that AppendMenu does not hold on to the PSZ but makes a copy (which it does) then you should change the code to:
    AppendMenu( hMenu, MF_STRING, ID_MONTH1 + (DWORD)(i-1), String2Psz(SELF:aMonthsbyName))

    Robert

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

    Transferring large VO project to X# 06 May 2021 10:06 #18347

    • Chris
    • Chris's Avatar


  • Posts: 2566
  • diobrando wrote:

    jonhn wrote: Try this version of FAB tools attached.


    Thanks jonhn
    these are the dll that I already have.

    I was trying to compile the FabTools source code I've downloaded from GitHub but this gives me error when importing FabTools.xsproj or FabTools.sln in VS19 (and in XIDE too)

    maybe this needs to be updated from Fabrice or I'm doing something wrong

    ciao
    Stefano


    Thanks, Stefano, I see some problems, too, will tell Fabrice about it.

    If you download the binaries only, do those work OK for you?
    XSharp Development Team
    chris(at)xsharp.eu

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

    Transferring large VO project to X# 07 May 2021 01:49 #18362

    • GlenT
    • GlenT's Avatar
    • Topic Author


  • Posts: 27
  • I now have FabTools and FabPaint compiling and have moved on to my WebBrowser class

    In the WebBrowser, I have the line

    CLASS WebBrowser INHERIT OleControl

    and the compiler gives an error

    error XS0246: The type or namespace name 'OleControl' could not be found (are you missing a using directive or an assembly reference?)

    Is OleControl in the X# VO Classes?

    Cheers

    Glen

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

    Transferring large VO project to X# 07 May 2021 02:05 #18363

    • GlenT
    • GlenT's Avatar
    • Topic Author


  • Posts: 27
  • Working on my function library now and I have two issues. Firstly, I have the function:

    FUNCTION PCE_Is64BitOS() AS LOGIC
    LOCAL hModule AS PTR
    LOCAL hFunc AS PTR
    LOCAL lIsWow64 AS LOGIC

    hModule := GetModuleHandle( PSZ( "kernel32" ) )
    hFunc := GetProcAddress( hModule, PSZ( "IsWow64Process" ) )

    IF ! hFunc == NULL_PTR
    PCALL( hFunc, GetCurrentProcess(), @lIsWow64 ) // <--error
    ENDIF
    RETURN lIsWow64

    the error returned is

    error XS9035: The first argument to PCALL must be a 'typed function pointer'.

    I can't work out what I've got to declare hFunc as.

    The 2nd issue is a dialogue that I expand in the show method to ensure that the text passed is fully displayed. The show method is

    METHOD show( kShowState )
    LOCAL strRect IS _WinRect
    LOCAL hDC AS PTR
    LOCAL nHeight AS LONGINT
    LOCAL cStr AS STRING
    LOCAL oSize AS dimension
    LOCAL oPnt AS Point

    // calculate the height of the message
    cStr := SELF:oDCFTxtMessage:value
    hDC := GetDC( SELF:Handle() )
    SelectObject( hDC, SELF:oDCFTxtMessage:Font:Handle() )
    strRect.bottom := SELF:Size:Height - SELF:oDCFTxtMessage:Origin:Y
    strRect.top := SELF:Size:Height - ( SELF:oDCFTxtMessage:Origin:Y + SELF:oDCFTxtMessage:Size:Height )
    strRect.left := SELF:oDCFTxtMessage:Origin:X
    strRect.right := SELF:oDCFTxtMessage:Origin:X + SELF:oDCFTxtMessage:Size:Width
    DrawText( hDC, String2Psz( cStr ), -1, @strRect, DT_CALCRECT + DT_WORDBREAK + DT_LEFT + DT_NOPREFIX )
    nHeight := strRect.bottom - strRect.top
    IF nHeight > SELF:oDCFTxtMessage:Size:Height
    oSize := SELF:oDCFTxtMessage:Size
    oSize:Height := nHeight
    SELF:oDCFTxtMessage:Size := oSize
    nHeight -= 111
    oPnt := SELF:oDCFTxtMessage:Origin
    oPnt:Y -= nHeight
    SELF:oDCFTxtMessage:Origin := oPnt
    oSize := SELF:Size
    oSize:Height += nHeight
    SELF:Size := oSize
    ENDIF
    SUPER:show( kShowState )
    RETURN NIL

    The compiler is detecting an error on the SelectObject line. The error message being

    error XS0119: 'VO.TextControl.Font(params XSharp.__Usual[])' is a method, which is not valid in the given context

    and I just can't understand that one.

    Can anyone help please?

    Cheers

    Glen

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

    Transferring large VO project to X# 07 May 2021 05:17 #18364

    • wriedmann
    • wriedmann's Avatar


  • Posts: 2633
  • Hi Glen,
    OLE/COM as it worked in VO does not works anymore in X#.
    Please see the X# help, "Migrating apps from VO to X#", "Example 5 - The Email Client Example".
    That works (I have done it myself).
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

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

    Transferring large VO project to X# 07 May 2021 07:02 #18366

    • diobrando


  • Posts: 20
  • Chris wrote:

    diobrando wrote:

    jonhn wrote: Try this version of FAB tools attached.


    Thanks jonhn
    these are the dll that I already have.

    I was trying to compile the FabTools source code I've downloaded from GitHub but this gives me error when importing FabTools.xsproj or FabTools.sln in VS19 (and in XIDE too)

    maybe this needs to be updated from Fabrice or I'm doing something wrong

    ciao
    Stefano


    Thanks, Stefano, I see some problems, too, will tell Fabrice about it.

    If you download the binaries only, do those work OK for you?


    Hi Chris,
    I've already added reference of FabTools.dll to the project, but it would be nice to have the FabTools source code compiling and running as we do in VO

    thanks
    Stefano

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