I'm working on modernizing an old Delphi 7 app for a customer. I already successfully migrated it to Delphi Sydney but the code I'm working with has a ground problem which is all the forms (nearly 200) are shown using Tform.showmodal (and sometimes it could be up to 10 forms on top of each other) which leads me to my problem:
I would like to show on the windows taskbar preview (the one shown when you hover the app) the current form the user is in. Not all the chain of possible forms opened, not the mainform and the last one opened, just the current one.
I've been researching about the Delphi object TTaskbar without much luck as well as the form CreateParams method when the form is shown but the most I've managed to do is to show the chain of all forms opened on the taskbar separately using this code:
procedure TForm1.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.Style := Params.Style and not WS_POPUP;
Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
Params.WndParent:=application.Handle;
end;
I've also tried to change the mainform on execution (I know it's highly against good practices being a pointer) as a prove of concept, but didn't work either:
Pointer((@Application.MainForm)^) := form1;
Some other researches led me to use the windows messages WM_DWMSENDICONICLIVEPREVIEWBITMAP and WM_DWMSENDICONICTHUMBNAIL to inject straight to the thumbnail the image I want, but that would imply, if I'm not wrong, to regenerate the thumbnail every time the user changes anything on the current form, which I think is not very optimized.
Does anyone know any way to fix this issue without changing the way the forms are shown in the whole application?