Delphi and Win95
Borland Delphi (aka Borland Developer Studio, Turbo Delphi, etc.) cannot generate native Windows executables compatible with Windows 95 any more, since Borland has stopped support for those. Completely unnecessarily in my opinion, since it seems to be only about two statically linked functions that are not available in Windows 95. Now if Borland would support smart-linking like FreePascal does, applications that do not make use of the code that uses this functions would still run under Windows 95 - but Delphi doesn't support this.
While looking for workarounds, I came across Wine, the Open Source implementation of the Windows APIs to allow Windows applications to run under Linux and other OS, and ReactOS, the Operating System based on Wine and aiming to be compatible with Windows XP. ReactOS included the libraries missing in Windows 95 (we can't just take some from another Microsoft Windows version for licensing issues), but sadly, just taking two or three libraries out there and putting them into Windows 95 didn't work completely.
So if we can't get Windows 95 compatibility back using newer libraries, we need to get inside the Borland units. It was soon clear that the problematic functions were MsgWaitForMultipleObjectsEx and GradientFill. GradientFill is using only for gradients in some modern controls; if we just create those gradients on newer OS versions, no harm will be done, but the code will still run on Windows 95. For that, I went ahead and patched Windows.pas to dynamically load GradientFill instead. Next, the units using GradientFill, or better GradientFillCanvas which is the only place that uses GradientFill, need to be updated. A quick patch for me was to use GetVersionEx in the constructor of TToolbar in ComCtrls.pas to set a boolean, which would then be included in the conditions used to determine whether GradientFillCanvas should be used. An even better method would probably be to implement a Win95-compatible drawing routine inside GradientFillCanvas, because that would automatically support the other controls as well, but this was a quick fix near a release, there's time for improvements in future updates.
Two patches that do the described changes are available as
Delphi2006-WindowsPas-Win95compat.patch and
Delphi2006-ComCtrlsPas-Win95compat.patch. Please note that you need to remove the compiled versions of these two units, otherwise Delphi will never notice they have been changed! Making a copy of the original is also recommended of course.

5 Comments:
Hi..
No more posts?
I really find you blog intresting.
By the way why dont you help us on windows ce LCL.i am pretty sure you can really do much.
I am in real lack of time,and when i saw your mini gui i was really impressed.
hope to read from you again.
Also wy you havent include RSS or other things....
regards,
roozbeh
23:13
I found it intresting too...
... i'm developing a wince application with lazarus, but there are still some limits in lcl and the networking.
I'm sure that youre help to Roozbeh could be really significative in order to make lazarus work good on Wince.
I saw for example that you're able to use images on wince compiled application (we still can't) and that you use a windows dll for networking.
Come on our irc channel or mailing list if you want to do something with us...
irc: chat.freenode.net
channels: #fpc or #lazarus-ide
list: http://lists.freepascal.org/mailman/listinfo/fpc-devel/
We all got great project upon Lazarus.
14:04
Actually there is a RSS feed, but this blogger.com stuff doesn't work well with my own domain... try http://ccrdu.de/rss.xml, that should be up-to-date.
Didn't do much work on Lazarus/FPC+WinCE recently since I was reinstalled Lazarus and couldn't get even my old full archive to compile successfully any more. I recently saw that nice setup for cross-compiling and will try that as soon as time permits (currently doing a bunch of adjustments for Vista) :) And I really need to spend time on this again, since I've got two projects that need to be continued (one only a small shopping list app for myself :D) ;)
13:16
Hello,
Nice article about Delphi and Win95. I wanted to check the links to
Delphi2006-WindowsPas-Win95compat.patch and
Delphi2006-ComCtrlsPas-Win95compat.patch . But these links are not working anymore. Is there a possibility to get the correct link to these files.
Thank you very much.
Regards,
Jeffrey
21:12
Sorry, did update the links, and two more patches might follow at some point (ExtCtrls and SyncObjs, not as often used).
23:02
Post a Comment
<< Home