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:

if (TfrmLaunchSetting.Execute = mrOK) then
  Application.MainFormOnTaskbar := True;
  Application.Title := 'MyApplication';
  Application.CreateForm(TfrmMain, frmMain);

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:

function TfrmLaunchSetting.AppHookFunc(var Message: TMessage): Boolean;
  Result := False;
  if Message.Msg = WM_SYSCOMMAND then
    PostMessage(Handle, WM_CLOSE, 0, 0);
    Result := True;

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.


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.

Saturday, 28 November 2020

A Set back?

- or how could I forget some set operators.

Recently a colleague of mine asked me to review some old code, and a line similar to the one below pop into my view as strange:

if (doorStates * [dsClosed, dsUnlocked] <> []) then

It had been so many years since I had used that specific syntax, that I completely forgot about some of the set operators in Pascal and Delphi - so I thought I would write up a small post on Sets in Pascal/Delphi.

In regards to the silly doorStates example above - here is a little riddle: When is a door not a door?

Saturday, 31 October 2020

Not exactly Kierkegaard - pun intended

- or the books on Delphi keep coming.

Well the pun in the title would probably need a bit of explaining, so the reference is to Søren Kierkegaard (1813-1855) - the Danish philosopher, theologian, poet, social critic and religious author who is widely considered to be the first existentialist philosopher - but his surname is also pronounced as the Danish word for graveyard or churchyard.

I sometimes still hear people say, that nothing is happening in relation to Delphi in general or more specific in the Delphi book area - but that is not true.

It might have been many years since a Danish book on Delphi was published - but there where many in the early days - I had only 2 of the 15-16 published, all the rest I had were in English. So the scene for Danish Delphi books does feel like a "kirkegård".

And it is all my fault - I do prefer my technical books (and my software) in English, and I am sure most Danish developers feel the same.

But when you look at the number of English books that has been published the last couple of years - the technical quality, the passion, level of detail and diversity of topics matches greatly what also has been going on in the rest of the Delphi community - if you haven't noticed you might be looking in the wrong places.

Fellow Embarcadero MVP Patrick Prémartin has started to setup a nice site called - some books still need to be added at the time of writing this. - no books in the Danish section yet - but covers are scanned. Update: Patrick has uploaded the info and covers I provided him with - and also published an extensive open-data API for the site.

I know Patrick has grouping by "year published" on his to-do list, that will help indicate how much great content has been published in traditional book form the latest years - so a big thanks to all the authors and publishers - for keep doing this non-trivial task of writing books.

It is almost 30 years since I co-authored two books on Paradox DOS - in Danish and just prior to Paradox Windows was launched - they were not bestsellers btw 😁. But I still remember the tolls it took on everyone, and still surprised that my then to-be-my wife, stayed.

/Enjoy some of these great books.

Wednesday, 30 September 2020

Good on ya, mate!

- or a shout-out for Alister Christie's new book: Code Faster in Delphi.

I just got a chance to review the first of a series of new books about Delphi from Alister Christie, and even if it is a short book - 160 pages - it is perfect and on the spot - looking forward to the next in the series.

You can get the book here: - just take a look at the Table Of Content - a lot of great stuff.

Alister Christie has been doing his for many years - and his 150+ short videos are always to the point - on topic and precise - at least those I have seen :)

And speaking of video - watch his promotional video for the book - always fun and this one has WordStar bits :)

I will get my dead tree version as well - even if shipment cost probably will exceed the price of the book - but I want this nice books content and cover on my bookshelf.

Speaking of cover - as a little bonus I found this on 99designs: - so if anyone has a potential writer in them, this shows one process of getting a nice cover selected.

It has been more than 25 years since I last wrote a book - even if self publishing and cover contents are now a thing - it is not a trivial task - as I remember it, so well done - and thanks.

/Enjoy Alister's new book.

Monday, 31 August 2020

Hygge by the fireside

- or a fireside chat with Jim McKeeth

End April in the evening Jim and I had a fireside chat, which should had been in front of our masonry oven - but I ended up having it from my home office.

You can see the chat here - it is a bit long but I think we had fun, and to help you through it, I have done this post as a commentary track, and put a bit more details in various places.

And the word hygge now seems to have gotten into the Oxford English Dictionary - but still pronounced wrong :)

Friday, 31 July 2020

I am no Charles TDickensionary<>

- or a few TDictionary<> tricks.

One of my favourite classes in Delphi is TDictionary<> - might be because it resembles a database table which can have composite keys, and I have always been a ClientDataset/VirtualTable/FDMemTable fan-boy :)

I do not get to use the memTables that much i recent years, and the RTL generic collections also got better - while not on par with third party collections like Spring4D - which I also not get to use much.

I recently had a task where I had to transform some code that was collecting data from an external source, that provided data in a way that multiple iterations had to be done, before each row/item was complete - since data was coming in subsets per field/property. TDictionary<> to the rescue.