Wednesday, 22 June 2022
A SET up
Thursday, 14 October 2021
A Taste of WINE
- or how to detect if your Windows application is run under a flavor of WINE
It has been a while since I mentioned what has been going on with Siege Of Avalon - and the short story is that I have been involved in getting the game re-released on GOG and Steam - the long story deserves a longer post another time.
We currently have a bigger update/patch planned - that would be the 4th - since its re-release in April 2021 - but it is not finalized what goes in and what not.
But one of the minor things, is trying to make the game more Steam Play friendly - so that basically just allowing custom ddraw.dll and disabling a few things when run under Wine/Proton - so that the game is playable without the need to jump through hoops like winetricks and protontricks.
Since these compatibility layers are meant to be transparent to the windows application, one would need to actually in some detect if running under Wine, luckily there is an extra bit in the NTDll.dll - the wine_get_version function.
So dynamically loading of the Dll, and try to get the address pointer of the function will reveal if your plain Delphi VCL Windows is run under Wine on Linux (or other Wine supported platforms).
The code for the simple test pictured:
var
dll: HMODULE;
get_WINE_version: function: PAnsiChar;
begin
dll := LoadLibrary('ntdll.dll');
if dll<>0 then
begin
@get_WINE_version := GetProcAddress(dll, 'wine_get_version');
if Assigned(@get_WINE_version) then
Label1.Caption := 'Running under ' + get_WINE_version()
else
Label1.Caption := 'Pure ol'' Windows';
FreeLibrary(dll);
end;
end;
This is by no means the real deal, but if it helps bringing an existing application run on a different platform and making it aware of that - then it might be helpful.
A more "correct" way to migrate existing VCL applications could be https://www.crossvcl.com, but in this case that is not doable - since not a standard Delphi VCL application.
But as you can see below this detection short-cut can help create an experimental build of Siege Of Avalon that is running on Steam Play out of the box. AS-IS.
Please support the nice publisher of this re-released classic old game, and their willingness to keep releasing the Delphi code of the GOG/Steam releases.
/Enjoy
Thursday, 9 September 2021
My favorite %11 new things in Delphi 11 Alexandria
- or all things "eleven", watch out for dialects.
With the public release of Delphi 11 (and RADStudio and C++Builder) today, I would like to share my %11 initial favorites in the new release.
%01. Styled Form designer
Together with the IDE HighDPI support, it is great that the gap between the running UI and the UI while designing has been reduced, and keeps in my opinion Delphi IDEs the best to design visual applications - whether it is on desktop OSs or mobile OSs.
%10. HTTP/2 support
I am looking forward to start experimenting with this, and see how much benefit and performance it will give when taking advantage of fully.
%11. Remote Desktop Support improvement
In this world where more people are coming to their senses, and wish to work remotely, focus on improving the IDE experience with remote connection is nice. And the things done can also benefit the applications build.
But there are many other things that not even a list of $11 things would cover it, and I am really looking forward to also experience to the various optimizations and running the IDE in HighDPI on my old Surface Pro.
Go EMBT :)
There is one slightly annoying thing that might split the Delphi community - adding to the list of:
- Is Delphi pronounced /del·fai/ or /del·fee/?
- Does "then begin" go on together on the same line?
- FreeAndNil?
and now this to split the community further and create fractions:
Well the above was just an excuse for me to include that funny Scottish sketch - no harm done I hope.
BTW: If you wonder about the % prefix - the it is the prefix for binary literals adding in Delphi 11.
/Enjoy
Saturday, 22 May 2021
VAT's in it for me? - or I call my layer.
- or a shout-out to the various services of apilayer.com
Have you ever wanted to know the various VAT rates in the EU - no? - well neither have I, because it might put me in a bad mood, but it fits the intended pun for the post, and I also wanted to show how it is done from from Delphi.
The mother company of Embarcadero, Idera acquired another company early this year - this time apilayer.com, which provides numerous "simple" cloud-based API services - among these are:
- IP geolocation and reverse lookup
- Language detection
- Mail address validation
- Phone number validation
- Flight tracking
- Currency conversion and rates (including crypto currency)
- Weather data and forecast
- News, Headline and Stock apis
- Conversion PDF and scraping
Monday, 15 February 2021
Closing in on Modal Jump Lists
- or getting a WM_SYSCOMMAND to a modal dialog.
An idea that initially seemed clever, has been haunting me a bit lately - I did put a modal dialog into a project before the main Application block (Initialize .. Run). Shame on me.
So the code looks similar to like this:
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.Title := 'MyApplication';
Application.CreateForm(TfrmMain, frmMain);
Application.Run;
end;
and the TFrmLaunchSetting.Execute is just a class function returning the ModalResult, from its ShowModal.
But here comes the issue at hand - the Close Window in the task bars Jump List sends a WM_SYSCOMMAND that goes to the system menu in the main window - but if a modal form is shown the main window is disabled - and in this case I do not even have a main form yet.
So TApplication.HookMainWindow to the rescue - that would enable me to intercept messages sent to the main form - and act upon these.
So in the FormCreate of my modal dialog I hook the my hook function up like this:
And on FormDestroy I do the following:
The AppHookFunc goes as follows:
begin
Result := False;
if Message.Msg = WM_SYSCOMMAND then
begin
PostMessage(Handle, WM_CLOSE, 0, 0);
Result := True;
end;
end;
This way modal dialogs can react to Windows messages that normally be intended for the main form.
There are probably side-effects - but the issue at hand is solved - for now?
BTW: Yesterday was Delphi 26th birthday - I did not forget - but I am still wrapping up the present. Stay tuned.
/Enjoy
Wednesday, 30 December 2020
It deploys and runs - what a Big Sur prize
- or the initial steps to get a Windows IDE to run cross-platform using CrossVCL.
Sorry about the pun, and I should also mention that this project is WIP, so no workable release/code yet.
Update: In the original image above the language selection was broken/disabled. Read the update in the end of the post on the changes I decided to do to makes this work better overall.
A few days back was a new update of CrossVCL announced in my email - for the lifetime license I had bought years earlier - which triggered an idea.