Why is it that in certain Delphi applications, minimized windows get lost?

Delphi to Web
Picture of Leonardo Laurencio
Leonardo Laurencio

CSO - Cybele Software

Table of contents

Error

When the main window is minimized in a Windows application, it usually collapses to the taskbar and is replaced by a button there.

did the window hide away?

Minimization in Thinfinity VirtualUI works in a similar fashion, replacing the application window with an icon in the lower-left corner of the page. But a problem is found in certain Delphi applications: when minimized, the window is hidden away, and the taskbar shows no such icon.

While VirtualUI behaves correctly in this regard, applications developed in this language present the following problem: when the Application.MainFormOnTaskBar property is set to False and an application main window is minimized, this window is in fact hidden but it is not done the proper way.

This is the TApplication.Minimize code:

procedure TApplication.Minimize;
begin
  if not IsIconic(Handle) then
  begin
    NormalizeTopMosts;
    if not MainFormOnTaskBar then
      SetActiveWindow(Handle); // WM_ACTIVATEAPP can set AppIconic to False
      FAppIconic := True;      // Set AppIconic here just to be safe
      DoShowOwnedPopups(False);
      if FMainFormOnTaskBar then
      begin
        if FMainForm <> nil then
          FMainForm.WindowState := wsMinimized
        else
          FInitialMainFormState := wsMinimized;
      end
    else
    begin
      if (FMainForm <> nil) and (ShowMainForm or FMainForm.Visible)
      and IsWindowEnabled(FMainForm.Handle) then
      begin
        SetWindowPos(Handle, FMainForm.Handle, FMainForm.Left, FMainForm.Top,
          FMainForm.Width, 0, SWP_SHOWWINDOW);
        DefWindowProc(Handle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
      end
      else
        ShowWinNoAnimate(Handle, SW_MINIMIZE);
    end;
    if Assigned(FOnMinimize) then FOnMinimize(Self);
  end;
end;

To fix this problem, the value of this property must be set to True.

program MinimExample;
uses
  Forms,
  VirtualUI_AutoRun,
  MainForm in 'MainForm.pas' {FormMain};
{$R *.res}
begin
  Application.Initialize;
  Application.CreateForm(TFormMain, FormMain);
  Application.MainFormOnTaskbar := True;
  Application.Run;
end.

With this correction in place, Delphi properly minimizes the application window and the icon is shown on the taskbar as expected.

You may want to continue reading: https://blog.cybelesoft.com/how-to-virtualize-applications/

Thinfinity_logo
Get a Free Trial
Explore Thinfinity Workspace risk-free. Test our Cloud Management and RPAM features for enhanced security and control.

Have any questions?

Book a call today to learn more about how Thinfinity® can help your organization. We are always available to guide you and provide the best solution based on your specific needs.

2 Comments

Mariana
Reply
March 9, 2018 at 8:36 pm

Dear Arek, I had to translate your comment and I’m not sure if you could resolve the Delphi collapse to the taskbar issue.
Did this post work for you?
Otherwise, please send an email to [email protected] so we can help you.

Arek
Reply
February 28, 2018 at 8:22 pm

A mam jeszcze jeden problem z programem. Nie moge go zwinac bezpośrednio do paska. Chodzi o to że jak go zwijam to ładuje mi się nad menu start a nie do paska. Wiecie moze co z tym zrobic ?
delphi zwijanie do paska zadań

Add Comment

Thinfinity-blue-logo
Get a Demo
Experience how Universal ZTNA with Thinfinity integrates with VDI and DaaS for unmatched security and flexibility.
Thinfinity_logo

Get a Demo

Experience how Universal ZTNA with Thinfinity® integrates with VDI and DaaS for unmatched security and flexibility.

Blogs you might be interested in

<span>Application Modernization</span>, <span>Delphi</span>, <span>Developer</span>, <span>HTML5 Conversion</span>, <span>Independent software Vendor (ISV)</span>, <span>SDK</span>, <span>Secure Application Delivery</span>, <span>Thinfinity VirtualUI</span>, <span>Windows Integration</span>