[Win32] When minimizing/restoring a modal form, an unnecessary Application icon appears
* Lazarus/FPC Version: trunk (6ed6e91651) * Operating System: Windows 11 * CPU / Bitness: x64 ## What happens I call the modal form via `ShowModal` while the main form is not yet displayed. This form has a property `ShowInTaskBar := stAlways`. And minimizing and maximizing it causes an unwanted Application.Handle icon to appear in the taskbar. This behavior is incorrect because the modal form is not the main form. ## What did you expect I have developed a fix that causes the correct behavior in both modes of `Application.MainFormOnTaskBar`. (my previous bug report contained incorrect information). Also this fix prevents the bug where `Application.MainFormOnTaskBar := False` (default mode) prevents non-modal forms from being minimized. [changes.patch](/uploads/0fc57f2e3f9bc12722f2b94f6d72be53/changes.patch) Two videos, as it was and as it became: <details><summary>Click to expand</summary> ![bandicam_2024-10-12_22-32-14-170](/uploads/e397fc45dd61a0526eedc7051e91b134/bandicam_2024-10-12_22-32-14-170.mp4) ![bandicam_2024-10-12_22-38-10-269](/uploads/e9f832e9879c0c9febdee47ec1022f66/bandicam_2024-10-12_22-38-10-269.mp4) </details> ## Steps to reproduce ``` var f: TForm; begin RequireDerivedFormResource:=True; Application.Scaled:=True; Application.Initialize; f := TForm.CreateNew(nil); f.ShowInTaskBar:=stAlways; f.ShowModal; // minimize this form Application.CreateForm(TForm1, Form1); Application.Run; end. ```
issue