Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/VCL/Dialog Controls/TOpenDialog    [ Add a report in this area ]  
Report #:  43724   Status: Reported
TOpenDialog does not stay on top of parent/main window when switching desktops
Project:  Delphi Build #:  10.0.2288.42451
Version:    11.0 Submitted By:   Laurent C
Report Type:  Basic functionality failure Date Reported:  4/3/2007 6:59:10 AM
Severity:    Serious / Highly visible problem Last Updated: 4/3/2007 9:21:26 AM
Platform:    All versions Internal Tracking #:  
Resolution: None  Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
2.00 out of 5
Total Votes: None
Description
In Turbo Delphi (Borland Delphi for Microsoft Windows Version 10.0.2288.42451 Update 2), file open dialogs of type TOpenDialog do not stay on top of main application window, or of any other parent window, when switching desktops, despite being modal.

This is not the expected behavior and is not consistent with the behavior of openfile dialogs in other applications (MS Office, etc).

Same problem in Delphi 6 (build 6.240 Updt 2) under XP SP2. Same problem if, instead of the VirtuaWin desktop pager, I use the Microsoft "Desktop Manager Powertoy" for Windows XP.

The attachment includes Turbo Delphi files, a screenshot (screenshot.gif), and the VirtuaWin desktop pager from http://virtuawin.sourceforge.net

Note: this was first reported as #43459 but I could not move that report here. Thank you.
Steps to Reproduce:
- create main application form (Form1);
- add a button to Form1 (Button1);
- add a TOpenDialog component to Form1 (OpenDialog1);
- add an OnClick event handler for Button1 to launch OpenDialog1 (-> OpenDialog1.Execute);
- install a desktop pager (e.g., VirtuaWin, http://virtuawin.sourceforge.net/ or the Microsoft Desktop Manager Powertoy for Windows XP);
- launch application, click button to open OpenDialog1, then switch to a different desktop, then switch back to the first desktop: OpenDialog1 is hidden behind main application window.
Workarounds
None that I am aware of.
Attachment
43724.zip
Comments

Laurent C at 4/8/2007 1:37:42 PM -
This applies not only to TOpenDialog dialogs, but also to modal dialogs such as those brought up by calls to ShowMessage and Application.MessageBox.

Joe White at 4/14/2007 7:05:37 AM -
Yes, Execute (no parameters) will have this problem, and there's probably not much that can be done about it.

However, if you use the Execute(ParentWnd: HWND), it should work correctly, and stay on top of the parent window you specify. This sort of problem is the reason why the HWND overload was added.

You should always specify a parent window for dialog boxes if your app will run in XP or later. Otherwise the OS does Bad Things with your Z-order.

Laurent C at 4/15/2007 6:30:04 AM -
Joe, I have tried and, unfortunately, it doesn't seem to work for me. I launch OpenDialog1 when I click a button on main form Form1, like this:

If OpenDialog1.Execute(Form1.Handle) then ...

Upon switching desktops OpenDialog1 is still hidden behind the Form1 window. I am using Borland Delphi for Microsoft Windows Version 10.0.2558.35231 Update 2.

Any suggestions? Thanks.

Laurent C at 5/13/2007 9:17:29 PM -
Here is what seems to fix the problem: edit the Dialogs.pas unit as indicated below, then rebuild it:

http://www.installationexcellence.com/articles/VistaWithDelphi/Original/Index.html#New_Common_Dialogs

Server Response from: ETNACODE01