Recent

Author Topic: Question on porting Windows Delphi 7 application  (Read 13209 times)

kdtop

  • New Member
  • *
  • Posts: 16
  • Long live pascal :-)
Question on porting Windows Delphi 7 application
« on: December 23, 2012, 04:19:00 pm »
The US Department of Veteran's Affairs (the "VA") has an extensive electronic medical record (EMR) system called VistA that is widely used.  At one point it was the #1 EMR worldwide.  The client for this, called CPRS, is written in Delphi, and the entire system is in the public domain.  I have been active in a community called WorldVista for years which has a mission for making the EMR available outside the VA. 

There has been interest in getting CPRS working on other platforms.  I am one of WorldVistA's few Delphi programmers, and they have asked me about the viability of porting CPRS onto Lazarus.  I think that most of it would be fine, but there may be some key sticking points.

Question: some of the custom controls used by CPRS involve windows messaging.  I'm not sure why they were developed this way, but parts of the controls will send messages to other parts.  How would this be handled on other OS's?  Do all OS's have a messaging system and lazarus makes them all look the same?  Or would the messages have to be tailored to the target OS?

Question: the key network part of CPRS ultimately depends on Windows wsock code to establish the connection.  How would this be handled on an alternative OS?  Is there a lazarus abstraction layer (i.e. in the LCL) that would take care of this?

Question: One of the components used is TWebBrowser.  On windows, this is a wrapper for Internet Explorer (IE).  I am assuming that there is an equivalent in Lazarus?  One modification to CPRS makes use of the WYSIWYG editing feature provided by IE (I think it is called DHTML) via it's ActiveX interface  Would I be correct that none of that would work with Lazarus?

In summary, I am trying to tease out the difference between the Delphi platform (and it's level of implementation in Lazarus) vs Windows dependencies.

Thanks in advance for feedback.

Kevin

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Question on porting Windows Delphi 7 application
« Reply #1 on: December 23, 2012, 05:45:59 pm »
Quote
Question: some of the custom controls used by CPRS involve windows messaging.  I'm not sure why they were developed this way, but parts of the controls will send messages to other parts.  How would this be handled on other OS's?  Do all OS's have a messaging system and lazarus makes them all look the same?  Or would the messages have to be tailored to the target OS?
Other interfaces (not OS) don't use message passing mechanism actually, but AFAIK LCL emulates this. To make it work cross platform, you have to change the Windows messaging into LCL one. Note that not all Windows messages are implemented in LCL (yet). Better solution is to change the code to use the corresponding events.
Quote
Question: the key network part of CPRS ultimately depends on Windows wsock code to establish the connection.  How would this be handled on an alternative OS?  Is there a lazarus abstraction layer (i.e. in the LCL) that would take care of this?
http://wiki.lazarus.freepascal.org/Networking
Synapse and lNet is the most popular, Indy is somewhere behind a little, and with its improvements over the years, fcl-net (and probably fcl-web) can also provide this functionality.
Quote
Question: One of the components used is TWebBrowser.  On windows, this is a wrapper for Internet Explorer (IE).  I am assuming that there is an equivalent in Lazarus?  One modification to CPRS makes use of the WYSIWYG editing feature provided by IE (I think it is called DHTML) via it's ActiveX interface  Would I be correct that none of that would work with Lazarus?
Not really the same. This is the best one ever created. It's built on top of XPCom library and should provide functionalities provided by that library (perhaps including DOM tree manipulation).

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927
Re: Question on porting Windows Delphi 7 application
« Reply #2 on: December 23, 2012, 06:14:11 pm »
Webbbrowser :

There is also QT Webkit:
http://wiki.freepascal.org/Webbrowser#QT_Webkit

On Windows, you can try to import 'C:\WINDOWS\system32\ieframe.dll' -> SHDocVw_1_1_TLB.
http://wiki.freepascal.org/LazActiveX#TActiveXContainer_early_binding

kdtop

  • New Member
  • *
  • Posts: 16
  • Long live pascal :-)
Re: Question on porting Windows Delphi 7 application
« Reply #3 on: December 23, 2012, 08:28:31 pm »
Thanks greatly for the replies.

snorkel

  • Hero Member
  • *****
  • Posts: 817
Re: Question on porting Windows Delphi 7 application
« Reply #4 on: January 04, 2013, 06:52:33 pm »
For the socket part you could use Synapse instead which is fully cross platform and has lots of examples and decent docs.
There is stuff in FCL-Net but it's largely undocumented.

As long as this app does not use extensive 3rd party controls like dev express etc porting it to Lazarus should not be super difficult, won't be easy either but should be doable.

What I have done is use the Lazarus Delphi Unit conversion tool to convert the forms one at a time.  Converting the whole app does not seem to work that great at least for me, but I had really good success converting one form at a time.
***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

snorkel

  • Hero Member
  • *****
  • Posts: 817
Re: Question on porting Windows Delphi 7 application
« Reply #5 on: January 04, 2013, 06:57:13 pm »
There is also a port of David Baldwins HTML viewer component that might work, depending on the
complexity of the HTML the app is pulling in.

http://wiki.freepascal.org/THtmlPort

If the app is using the windows messaging for it's own internal use from like threads the LCL messaging will work fine.

I converted a bunch of apps that used windows messaging to send messages from threads to the main form and it worked perfectly.

With a bit of research you could have this baby running on a bunch of different platforms.
***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

snorkel

  • Hero Member
  • *****
  • Posts: 817
Re: Question on porting Windows Delphi 7 application
« Reply #6 on: January 04, 2013, 07:00:54 pm »
See this blog post for info on LCL messaging.

http://lazarus-dev.blogspot.com/2008/01/new-0926-features-part-1-sendmessage.html

Apparently GTK2 and QT have their own similar message handling systems which the LCL uses, so it's not really emulating it in at least those two cases.
***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: Question on porting Windows Delphi 7 application
« Reply #7 on: January 04, 2013, 10:15:49 pm »
What I have done is use the Lazarus Delphi Unit conversion tool to convert the forms one at a time.  Converting the whole app does not seem to work that great at least for me, but I had really good success converting one form at a time.

Are you using Lazarus trunk? The whole project should convert if the individual units convert. I recently experimented with converting the Deled 3-D design app, and improved the converter at the same go. It now converts the whole thing automatically without errors. The code still needed some manual changes before it compiled though ... and OpenGL will need many more changes before it works.

Anyway, I would like to see your project which can't be converted as a whole. Can it be shared?

kdtop, about the original issue: old DB applications made with Delphi 7 at my job extensively use QuickReport and 3rd party components like Quantum Grid and TMS pack etc.
They would be very hard to port to Lazarus. If your app does not use those components, you have hope.


Regards,
Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

snorkel

  • Hero Member
  • *****
  • Posts: 817
Re: Question on porting Windows Delphi 7 application
« Reply #8 on: January 07, 2013, 04:55:51 pm »
Hi,
no not using trunk, using the latest stable version.
I can't share the app, it's a internal corporate thing.

It worked out well the way I did it anyway as I updated a bunch of things that where festering on the old delphi version.
***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

snorkel

  • Hero Member
  • *****
  • Posts: 817
Re: Question on porting Windows Delphi 7 application
« Reply #9 on: January 07, 2013, 05:00:08 pm »
Those high end Delphi components like Dev Express and TMS are a pain in the rear.
A couple of years ago I decided to not use that stuff any more and make due with the the stock controls and VirtualStringTree which I knew worked on Lazarus.   That made porting of my newer delphi apps a breeze.
***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: Question on porting Windows Delphi 7 application
« Reply #10 on: January 07, 2013, 08:31:01 pm »
no not using trunk, using the latest stable version. I can't share the app, it's a internal corporate thing.
It worked out well the way I did it anyway as I updated a bunch of things that where festering on the old delphi version.

Ok, it sounds like many manual changes were required in any case.

The Delphi converter in Lazarus now identifies units belonging to a known and already ported library. It omits them from the project and adds the library package dependency to the project instead.
Many projects have included common libraries in their source trees. My test case DeleD is a good example. It has FastMM which is not needed and just omitted from the project. Then is has SynEdit, PascalScript and Graphics32 which are all ported to Lazarus already!
I actually have high hopes to port that application for Lazarus soon.
OpenGL is ported, too, but the cross-platform support requires many manual changes.

Hint: New converter settings are always welcome. The converter can also replace used unit names, function calls and properties etc. Although the code analysis is rather primitive, it could be improved a lot by simply adding more configuration settings.

This all does not help with the high end components and other hard-to-convert code. Those would require some neural network artificial intelligence solution.

Juha
« Last Edit: January 08, 2013, 06:14:28 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

snorkel

  • Hero Member
  • *****
  • Posts: 817
Re: Question on porting Windows Delphi 7 application
« Reply #11 on: January 08, 2013, 09:58:39 pm »
Apparently you can use the IE activeX control

http://www.lazarus.freepascal.org/index.php/topic,9762.0.html

Obviously wont work on other platforms, but at least you could get rid of Delphi 7.

Once you have it running on Lazarus win32 it should be easier to get running on the other platforms.
« Last Edit: January 08, 2013, 10:00:31 pm by snorkel »
***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

 

TinyPortal © 2005-2018