5

This pertains to a Delphi application with a child form that has been shown and then hidden but not freed. If a user hovers over the (Windows 10) taskbar "mini-view" of the application the hidden form(s) will become visible (during the hover.) They will hide when the user clicks on the mini-view to change focus to the application. Is there any way to avoid this?

To recreate:

  1. Create a New VCL Forms application.
  2. Add a new form to the project and set it to autocreate.
  3. Add a button to show and then hide the form (or open it with ShowModal)
  4. Run the application
  5. Click the button to show the second form and then close it.
  6. Hover over the applications taskbar button to show the mini-view of the main window.
  7. Hover the mouse over the mini-view and see that the hidden windows appear over the main form.

Note that minimizing the application and restoring it does "fix" the affect until the next time the forms are shown. Perhaps that's a clue as to what is causing it or a clue to a work-around? This isn't a huge issue as it doesn't appear to cause any actual problems, but it does look unprofessional.

Adding code as requested (however it's not going to be very interesting.)

program Project1;
uses
  Vcl.Forms,
  Unit1 in 'Unit1.pas' {Form1},
  Unit2 in 'Unit2.pas' {Form2};
{$R *.res}
begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TForm2, Form2);
  Application.Run;
end.

// Only code that was added to TForm1:
procedure TForm1.Button1Click(Sender: TObject);
begin
  // Show and then hide the form or use ShowModal and close it before testing the hover.
  Form2.Show;
  Form2.Hide;
  // Form2.ShowModal;
end;

Update: How to show the issue using just the Delphi IDE.

  1. Run Delphi
  2. Open any code file and search for a string and then use F3 until you get the dialog "Search Match Not Found", "Restart search from beginning of the file"
  3. Close the "search match not found" window from step 2.
  4. Hover your mouse over the Delphi taskbar button and then move it to the mini-preview.
  5. You should see the "Search Match Not Found" window appear over the Delphi main window. I've verified this on Berlin and Tokyo (10.2.1)

[2023 Update] This behavior is directly related to the option called "Animate windows when minimizing and maximizing" in System properties, Advanced, Performance settings, on Windows 10 and 11. When that option is turned off the above behavior does not happen.

MarkF
  • 1,616
  • 1
  • 17
  • 27
  • I was able to duplicate this using 10.1 Berlin but it appears to have been fixed in 10.2 Tokyo. I compared some simple things between the two (`Params` values during `CreateParams` of the Forms for example) but they appeared the same. I will guess that the fix was made within the VCL's `TTaskBarHandler` component and the MainForm's interaction with it. It will require a deeper dive into both versions to determine if there might be a simple work around (other than just upgrading to Tokyo). – Dave Olson Aug 05 '17 at 16:40
  • Dave, thanks for checking. I just tested with 10.2 Tokyo and do see the same problem (I had a test 10.2 install on a laptop, but haven't switched to it yet.) Did you definitely show and then hide the form in your 10.2 test? – MarkF Aug 05 '17 at 17:01
  • Yes - does not repeat under 10.2. I've got 2 forms; main form has 2 buttons; Button1 'shows' Form2; button2 'hides' Form2; Either click Button1, then close Form2; Or, click button1, then click button2. Both do not show the problem. Exact same code using 10.1 does show the problem. – Dave Olson Aug 05 '17 at 18:00
  • 1
    I install my diff versions of Delphi in separate VMs. If i copy the EXE generated by the 10.1 Delphi over to the VM with 10.2 *it still shows the problem*. So, I don't think it's a Windows version issue. Tokyo Delphi: Win 10 Pro, Ver 1607, build 14393. Same for Berlin Delphi. – Dave Olson Aug 05 '17 at 18:03
  • Please provide a [mcve] that reproduces the problem. – Remy Lebeau Aug 05 '17 at 18:21
  • @Remy - I followed MarkF's steps listed in his question. Repeated the problem under 10.1 Berlin; Did not repeat for 10.2 Tokyo. – Dave Olson Aug 05 '17 at 18:26
  • @DaveOlson and yet, he said it repeats for him under 10.2, so clearly his test is different than yours. So he needs to provide his test code. – Remy Lebeau Aug 05 '17 at 18:27
  • I used the steps above on my 10.2 test. I did not copy the project. I still see the problem every time. – MarkF Aug 05 '17 at 18:37
  • I've added the test code above. It does help to resize form2 so it's very obvious when it is shown by the hover. – MarkF Aug 05 '17 at 20:26
  • @Remy - "so clearly his test is different than yours" No, it's not. His 7 simple instructions were the clear thing. Following those 7 simple instructions, I was able to duplicate his problem under Berlin. I was not able to duplicate it under Tokyo. He *is* able to duplicate the problem under his version of Tokyo. His question is not the (nearly) usual unintelligible, broken English, poorly worded sort; so, it's reasonable to assume that he tested the same code under both versions. Simple logic suggests that there is a version issue here; either Delphi or (less likely) a Windows version. – Dave Olson Aug 05 '17 at 23:54
  • Here's my version info: Delphi 10.2 Version 25.0.26309.314 Windows 10 Pro 64bit Build 15063... Btw, not sure why this is getting off track, I'd love it if it's fixed in 10.2, but it's not in my current version (granted I don't have the hotfix installed, but I checked the notes and didn't see any mention of something like this.) – MarkF Aug 06 '17 at 02:51
  • I could not recreate this under Delphi 10.1 Berlin (Update 2), using exact steps / sample code provided above, on Windows 10 Creator's. – Jerry Dodge Aug 06 '17 at 13:21
  • Oddly, after *only* changing the unit name of the secondary form, suddenly I have this issue. Very strange. Originally, it was just `Unit2.pas`, as default. Couldn't recreate. Now I named it `uSecond.pas` and I have the problem. I can't imagine for the life of me how that could introduce the issue though. Out of instinct though, I would imagine it's Windows' responsibility to decide what to show in this preview. – Jerry Dodge Aug 06 '17 at 13:33
  • It seems like there's some variability in how this works (or doesn't work.) I played around with enumerating the windows and looking at the window styles and I'm just more confused then when I started. I even added some direct calls to ShowWindow with SW_HIDE to see if that changed anything (since the standard hide for form2 is using SetWindowPos with SWP_HIDEWINDOW.) So far, I've got nothing except a mild headache... – MarkF Aug 06 '17 at 19:00
  • Re-verified using Delphi Tokyo 10.2.1. Also noted that the issue can be seen just using the Delphi IDE and gave the steps above. – MarkF Aug 09 '17 at 13:32

1 Answers1

0

It appears that Dave Olson's comment about this being Windows version specific is correct. This issue seems to have completely gone away in the latest builds of Windows 10 (even when used with older compiled versions of programs that would show the issue previously.) As an aside I wonder if the people who couldn't reproduce the issue were on the Windows Insider Program and had newer builds.

MarkF
  • 1,616
  • 1
  • 17
  • 27
  • Please define your "latest build". I am on the latest build of the branch my PC is assigned to: Version 1709 (Build 16299.666). Facing the same issue. But only with Delphi applications and Delphi IDE (Berlin) itself. – Martin Schneider Oct 02 '18 at 12:17
  • I've just retested and the issue does appear to be back. I'm not sure what build I had back in May but now It's October and I tend to have the latest release (but not the insider ones.) – MarkF Oct 03 '18 at 16:21