Bug 1223 - Windows native dialogs have layout issues
Summary: Windows native dialogs have layout issues
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: General ()
Version: Trunk
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Carlos Alberto Cortez
Depends on:
Reported: 2011-10-04 09:08 UTC by Mikayla Hutchinson [MSFT]
Modified: 2014-12-13 12:04 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Screenshot showing the issues. (106.51 KB, image/png)
2011-10-04 09:08 UTC, Mikayla Hutchinson [MSFT]
How the open file dialog appears in my Windows 7 setup (76.61 KB, image/png)
2011-10-13 12:31 UTC, Carlos Alberto Cortez
Windows API CodePack dialog layout (76.61 KB, image/png)
2011-11-19 03:54 UTC, Carlos Alberto Cortez
Windows API CodePack dialog layout (correct) (142.47 KB, image/png)
2011-11-19 03:56 UTC, Carlos Alberto Cortez

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Mikayla Hutchinson [MSFT] 2011-10-04 09:08:43 UTC
Created attachment 576 [details]
Screenshot showing the issues.

The custom widgets in the windows native dialogs don't lay out correctly. Also, the window icon is wrong, it should get the icon of the entry executable and use that. See attached screenshot.
Comment 1 Carlos Alberto Cortez 2011-10-06 00:13:19 UTC
Hey Michael,

The layout section is something I just recently discovered, and that seems to only affect Windows Vista/ 7. Working on that.
Comment 2 Carlos Alberto Cortez 2011-10-13 10:31:48 UTC
Commit 4b57638 fixes the icon issue; commits 5f851d3 and bf7471b fix the layout issues.
Comment 3 Mikayla Hutchinson [MSFT] 2011-10-13 10:45:02 UTC
Thanks for fixing this!

I'm still seeing a few issues:
* The layout of the buttons and custom widgets isn't consistent with other Windows apps, e.g. Notepad and VS
* The initial size of the open/save dialogs is strange.
* When closing the open/save dialogs, they can be seen to resize smaller briefly before closing.
* On Win7, it does't seem to be using the Win7 or Vista version of the Open/Save dialog, it looks like the WinXP version.
Comment 4 Carlos Alberto Cortez 2011-10-13 11:58:59 UTC

My comments below:

* What issues are you observing on the custom widgets? They should be aligned to match the labels/comboboxes of the dialogs. I may me missing something, of course.

* The size of the dialogs is pre-defined, and there's only a hack to modify them. What are you observing specifically about them? Too big, too small?

* Regarding the closing/resize, is something I have no idea about, and which seems  to be related to the dialogs being run on a separated thread. As soon as the Main method of MD is marked with STAThread and we can run the dialogs on the same thread, it should dissapear.

* Right, the dialogs are using the classic look, as the default dialog (WPF based) requires a different kind of approach to contain custom controls. There are a pair of ways to enable that, but that would obviously fail to work for users using Windows XP.
Comment 5 Carlos Alberto Cortez 2011-10-13 12:31:34 UTC
Created attachment 690 [details]
How the open file dialog appears in my Windows 7 setup
Comment 6 Mikayla Hutchinson [MSFT] 2011-10-13 14:14:30 UTC
This is how it appears to me: http://screencast.com/t/a3S8EmJiVQ2

But notepad looks like this: http://screencast.com/t/Fnd4v7BeEi
And VS looks like this: http://screencast.com/t/rL5ETFBcnu

The placement of the buttons and the "file types" combo are very different.
Comment 7 Carlos Alberto Cortez 2011-10-13 14:22:05 UTC
Oh, indeed, that's related to the new layout used by the WPF based file dialogs. The way they the controls are currently aligned matches the alignment of the extra controls in the pre-Windows Vista/7 dialogs.

So, the issue here is basically the fact that the new WPF dialog may likely not be available under Windows XP systems. This is a question of only supporting the WPF dialogs and ignore the previous versions OR detect/mantain the two of them.
Comment 8 Mikayla Hutchinson [MSFT] 2011-10-13 15:53:52 UTC
They're not WPF, they're just the Windows Vista / Win7 variants of the Win32 Common dialogs. WindowsPlatform already includes the Windows API Code Pack dll, which has a wrapper for them.
Comment 9 Carlos Alberto Cortez 2011-10-14 16:33:05 UTC
Tried one more time the API Code Pack under Windows XP, and it fails to run, complaining precisely about the need of Windows Vista and further.

So, I was saying, it's a matter of either dropping support for Windows XP, or keep support for the two of them -support for the classic under XP, and support for new one under Vista-.
Comment 10 Mikayla Hutchinson [MSFT] 2011-10-18 04:26:53 UTC
If we're only going to maintain one, I'd suggest the Windows 7 one, and fall back to GTK+ for older systems. A pretty large proportion of Windows users have Win7 and it's increasing all the time, whereas WinXP is declining.
Comment 11 Carlos Alberto Cortez 2011-10-18 19:24:07 UTC
Sounds like a fair option -hopefully it's as you said and most users are already using Windows Vista and newer-.

I will cook the changes over the next weekend. Thanks for your feedback.
Comment 12 Mikayla Hutchinson [MSFT] 2011-10-19 18:49:22 UTC
Awesome! Thanks for your contribution, I've been using MD on Windows a lot and it's really nice to have native dialogs :)
Comment 13 Carlos Alberto Cortez 2011-11-19 03:54:10 UTC
Hey Michael,

I've been a little busy, but I'm gonna summarize why IHMO I don't think the usage of the new file dialogs is gonna happen any time soon:

The only current way to customize the new controls is through the usage of Windows API Code Pack (not even the WPF api allows it). But this library has several issues:

* It doesn't allow the user to specify the layout of child controls. You can only add them and they will appear sequentially. Zero control over that, as mentioned in the docs. We end up with something like the thing in the attached screenshot.

* Once the controls have been added to the dialog, they can't be modified. This is specially troublesome for our combo boxes for the encoding/viewer, as we need them to change their contents on the fly. Destroying the old control and adding a new one fails as well.

Also, there's a chance to use any custom hack to properly display such child controls. The issue is that most of them stay as dirty hacks, and even the best one I found out there (below), probably can't be used, as the guy who wrote it mentions in the doc that he used a Reflector to see the internals of the MS impl (no details in the link, don't worry). On top of that, since it's counting on the internals, it seems to easily break from version to version (as stated in the comments section).

The last chance is to modify the Windows API code pack ourselves do update the controls and its contents -possible from the unmanaged code API-. It *seems* it's possible to take a look at the code and modify it, as the licence states. BUT the layout issue would remain, I'm afraid.

Hope this wasn't a long, long summary ;-)

Comment 14 Carlos Alberto Cortez 2011-11-19 03:54:55 UTC
Created attachment 910 [details]
Windows API CodePack dialog layout
Comment 15 Carlos Alberto Cortez 2011-11-19 03:56:36 UTC
Created attachment 911 [details]
Windows API CodePack dialog layout (correct)

Sorry, the last one was wrong ;-)
Comment 16 Marius Ungureanu 2014-12-13 12:04:05 UTC
We have reimplemented the Windows native dialogs in our application. This should be better now.