Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/VCL/Core VCL Classes/TForm    [ Add a report in this area ]  
Report #:  82381   Status: Closed
Z-Order not preserved when swiching between applications
Project:  Delphi Build #:  12.0.3420.21218
Version:    12.3 Submitted By:   Alex Willis
Report Type:  Minor failure / Design problem Date Reported:  2/22/2010 8:39:43 AM
Severity:    Commonly encountered problem Last Updated: 2/6/2013 11:38:04 PM
Platform:    All versions Internal Tracking #:   275219
Resolution: Cannot Reproduce (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
I've created a simple VCL Form application with a mainform and 2 other forms. Switching between this application and others sometimes changes the z-order of the forms.

Added by Sysop
Please use attached project to reproduce this issue.
Steps to Reproduce:
Added by Sysop
Arange the windows like in the screenshot (begin with form1, then form3 and last form2). Forms must be overlapping.
Now switch to a different application via windows taskbar (for example internet explorer). The different application should have a window that overlaps our test application.
Every now and then, depending on how the three forms are cycled before, the form3 comes to foreground and gets active. You can see it short time before the test application looses focus or if you switch back via taskbar.

I've found myself some kind of workaround (see folder "Z-Order-Problem Workaround"), maybe this helps.

Created a test app (delphi 2009) with a main form and 2 forms as follows;

Application.MainFormOnTaskbar := True;
Application.CreateForm(TfrmZ_Order_Main, frmZ_Order_Main);
Application.CreateForm(TfrmZ_Order_Form1, frmZ_Order_Form1);
Application.CreateForm(TfrmZ_Order_Form2, frmZ_Order_Form2);

Also a button on Main form used to show the other forms

Behavior can be recreated as follows;

1. Launch application
2. Click show button on main form
3. Position child forms to be overlapping.
4. Make sure no applications are selected, then select child forms in sequence.
4. select a different application from the taskbar
5. Forms interchange z-order.

Tomohiro Takahashi at 2/22/2010 5:44:47 PM -
Could you please attach sample project to reproduce your issue?

Alex Willis at 2/24/2010 5:52:28 AM -
I can't see any way of adding content or editing my report. How do I do this?

However the only other code in my project was the following, which was assigned to the onClick event of Button1 on my main form. All other settings are default settings.

procedure TfrmZ_Order_Main.Button1Click(Sender: TObject);

Tomohiro Takahashi at 2/24/2010 11:27:40 PM -
> I can't see any way of adding content or editing my report. How do I do this?
Please try to use Windows Native QC client to update your report and attach .zip file into the report.
The standalone client comes with Delphi.

Alex Willis at 2/25/2010 3:11:33 AM -
I've attached the project. Also note that this only seems to happen when changing applications via the task bar

Christian Herrmann at 11/7/2011 5:38:32 AM -
Is there any solution on this bug right now?
I'm looking desperately for a workaround for Delphi 2006.

All I could find out is, that the WindowPosChanging-event is called for the form that takes the focus. This places the form behind an invisible OfficeTooltip-window (in my case), thus becoming the topmost-window of my application.

Maybe it isn't a Delphi bug, but maybe someone has found a solution.

Tomohiro Takahashi at 11/7/2011 7:10:28 AM -
What version of Delphi do you use?
Does this issue still occur with XE2?

Christian Herrmann at 11/7/2011 7:18:06 AM -
I'm not sure, but i think i have testet with xe also, but not with xe2. But xe2 will be no alternative, because we need delphi 2006 for BoldForDelphi.

Tomohiro Takahashi at 11/8/2011 5:27:43 PM -
Unfortunately, we can not reproduce this issue with attached project due to lack of 'Z_Order_Base.pas'.

If you have any simple sample project to reproduce this issue?
If yes, could you please upload it(as a .zip) to Discussion Forum? I will check and attached it to this report.
[Embarcadero Discussion Forums >> Attachments]

Christian Herrmann at 11/9/2011 7:04:32 AM -
For sample project look at:

Tomohiro Takahashi at 11/9/2011 7:48:35 AM -
I attached it to this report.
Many thanks.

Tomohiro Takahashi at 11/10/2011 4:20:17 AM -
Unfortunately, I can not reproduce this issue with my environment(Delphi 2009 / WinXP)...

Tomohiro Takahashi at 11/8/2011 5:24:21 PM -
This is a comment from internal tracking system.
This is likely to be an Application.MainFormOnTaskbar issue - but there is a missing file in the attachment, Z_Order_Base, that may be essential to seeing the problem.

Server Response from: ETNACODE01