New download: Ookii.Dialogs

I have made available a new download: Ookii.Dialogs.

Ookii.Dialogs is a class library that provides a number of common dialogs for use in .Net applications. The dialogs provided are the task dialog, progress dialog, credential dialog, input dialog and Vista-style common file dialogs.

The download contains two class libraries, one for Windows Forms and one for Windows Presentation Foundation (WPF). The contents are nearly identical; only the input dialog is not available for WPF. Some utility classes are provided for Windows Forms; these are not available for WPF either.

Most of these dialogs are wrappers around Windows API functionality. The TaskDialog class wraps the task dialog API provided in Windows Vista and later. The ProgressDialog class wraps the IProgressDialog API available since Windows 2000. The CredentialDialog class wraps the CredUI API introduced in Windows XP, and the VistaOpenFileDialog, VistaSaveFileDialog and VistaFolderBrowserDialog classes wrap the IFileDialog API introduced in Windows Vista. Only the InputDialog is not a wrapper; this is a custom dialog that performs the same functionality as the old Visual Basic InputBox function. Visit the link above for more details on each dialog.

Each class has been designed to be not merely a wrapper around their respective native API, but to provide a programming interface that is natural to .Net developers, with full support for the component designer. The complete source code of the class libraries, as well as documentation and a sample application are provided.

The classes aim to give the best experience possible on each OS, where applicable. In the case of the CredentialDialog class, this means that the new Vista-style dialog is automatically used on operating systems that support it (Vista and newer). The Vista-style file dialog classes will automatically fall back to the old style dialogs when using Windows XP. This is also true of the VistaFolderBrowserDialog class for WPF, even though WPF itself doesn't provide a folder browser dialog; the VistaFolderBrowserDialog class is a full folder browser dialog implementation for WPF supporting XP and newer.

This library replaces the Ookii.VistaDialogs library, which contained only the Vista-style file dialogs and didn't offer any support for WPF.

This library is a collection of classes that I have developed for personal use over the years. Because of the difference in age of some of the code, and the many modifications made over time, there may be some inconsistencies.

Let me know what you think of it, if you use it.

Categories: Software, General computing, Programming
Posted on: 2009-01-28 11:54 UTC.

Comments

Christian Liensberger

2009-01-28 12:46 UTC

Nice work, Sven! :)

Long Zheng

2009-02-02 04:55 UTC

Please email me, urgent!

ltctech

2009-04-01 00:35 UTC

The dialogs look great, might add some of them to my applications.

I am running Windows Server 2008 x64. When I use the Vista style Credentials Dialog, the Username and Password contains garbage. With the older style dialog, there is no issue. I am guessing it some weird buffer issue with packing/unpacking. Have you seen it and/or know the solution?

Hamy

2009-04-11 10:11 UTC

Sorry abut this comment cause its not related to your post. but I really needed to thank you about your Brightness Controller software and adding a comment seems the only way to contact you.
thank you again for that perfect software and may we meet up again in future :)

details:
http://www.amilo-forum.com/post,8415.html#p8415

Gael

2009-04-17 19:48 UTC

Hi Sven and ltctech,

To fix the issue with CredentialDialog.cs,

replace (line 775)
-------
UserName = userName.ToString();
Password = password.ToString();

with
----
UserName = userName.ToString(0, userNameSize);
Password = password.ToString(0, passwordSize);

Hope this helps

noobo

2009-05-08 22:47 UTC

i won't downlode

Anthony Kilhoffer

2009-07-10 21:31 UTC

Awesome! Thank you so much. I was needing a FolderBrowser dialog in a WPF application, and this saved me the time to wrap the necessary Win API calls.

Steve

2009-07-28 20:59 UTC

When I use your WPF VistaFolderBrowserDialog in XP, the description comes out as a row of 'boxes'. Any idea why this might be?

Zzz

2009-08-23 13:49 UTC

To fix the garbage characters problem with WPF VistaFolderBrowserDialog in XP,

Add the following code before "public struct BROWSEINFO" in the NativeMethods.cs

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]

jmatos

2009-09-20 23:20 UTC

I try to figure it out how to use the Glass.DrawCompositedText with no luck, can you send me a sample how to use it. THANKS.

DrFooMod2

2009-10-20 16:29 UTC

This stuff is great. Thanks for posting a fix to the garbage chars issue. Have you though of migrating this to Codeplex so we can help support it?

DrFooMod2

2009-10-20 16:41 UTC

I spoke too soon. If you replace with this:

UserName = userName.ToString(0, userNameSize);
Password = password.ToString(0, passwordSize);

The code won't build do to:

Error 2 Argument '2': cannot convert from 'uint' to 'int' C:\src\Ookii\Dialogs\src\Ookii.Dialogs.Wpf\CredentialDialog.cs 775 53 Ookii.Dialogs.Wpf


If you use this construct:

UserName = userName.ToString(0, userName.Capacity);
Password = password.ToString(0, password.Capacity);

It will build. However, I find that if, and only if, I set the ShowSaveCheckBox property to true does the UserName property include garbage.

Email me so we can discuss. Thanks.

Sven Groot Author comment

2009-10-21 00:35 UTC

I'm sorry, I've been aware of this issue for some time but have not had time to fix it and re-release.

In truth, although Gael's fix works (you just need to cast them back to int; using Capacity instead won't work), there are other issues with the new-style dialog on Vista. In particular, if ShowUIForSavedCredentials is true, on Vista the password box will not be populated with the stored password. This is a bug in the Vista version of the credential dialog, it's not a bug with my code, and I have no way to work around it.

I would therefore suggest that you change line 458 from:
if( NativeMethods.IsWindowsVistaOrLater )

to:
if( Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version >= new Version(6, 1) )

This limits the new-style dialog to Windows 7, and causes Vista to use the old-style dialog, which does behave correctly in all circumstances.

DrFooMod2

2009-10-21 19:42 UTC

Worked like a charm. Just as a side note, it was like 456. Thanks again and I still think this should be moved to Codeplex.

Martin

2009-10-31 23:00 UTC

Hi Sven. Maybe stupid questions, but I am new to Windows/C# programming world :-)

a) does your library actually paint/compose those controls or is it just wrapping system controls?

b) I desperately want UI of Windows Explorer on Windows 7/Vista in the app I am coding (I want those breadcrumbs, toolbar, advanced list view items like those under Computer node...). Is it possible?

-M

Paul

2009-11-12 04:49 UTC

Hi Sven, great work! I was looking for a way to display the native CredentialDialog but needed to store domain credentials. I've made a few changes to CredentialDialog.cs and it seems to work ok. Happy to send it to you, just let me know.
Regards,
Paul.

Jan

2010-07-03 21:31 UTC

Hi,
I'm trying to use the Ookii.Dialogs.Wpf.dll in Visual Studio Express 2010, but I'm just getting errors messages. Is there a chance this will be compatible with the 2010 editions?

Cheetah

2010-08-03 16:31 UTC

Unfortunately I've found that the vista file dialog can crash if you point it at things that don't exist, e.g. setting InitialDirectory to a folder that doesn't exist causes this:

System.ComponentModel.Win32Exception: The system cannot find the file specified
at Ookii.Dialogs.Wpf.NativeMethods.CreateItemFromParsingName(String path)
at Ookii.Dialogs.Wpf.VistaFileDialog.SetDialogProperties(IFileDialog dialog)
at Ookii.Dialogs.Wpf.VistaOpenFileDialog.SetDialogProperties(IFileDialog dialog)
at Ookii.Dialogs.Wpf.VistaFileDialog.RunFileDialog(IntPtr hwndOwner)
at Ookii.Dialogs.Wpf.VistaFileDialog.ShowDialog(Window owner)

Garry

2010-08-17 13:02 UTC

Sven,
I love teh work you did on these dialogs. It has saved me quite a bit of time not having to implement my own, but I need to know if you can recompile these in the new 4.0 framework as I am working on a new 4.0 project and I can not include these as it would put a dependency on the 2.0 framework. Also just to let you know I pointed the company Telerik at your dialogs saying they should incorporate something similar to this in their controls. So if you get contacted that's why. :)

Sven Groot Author comment

2010-08-17 13:04 UTC

You can add a reference to a 2.0 assembly in a 4.0 project without getting a dependency on the 2.0 framework. Additionally, the source is included, so you could always recompile it yourself. :)

DrFooMod2

2010-09-20 15:28 UTC

I'm using the Login (CredUI) for the first time on Win7 Pro x86. The ShowDialog() method is throwing an exception after displaying the CredUI window. It is as follows:

Index and length must refer to a location within the string.
Parameter name: length

Could this be as a result of an update to the Win32 API in Win7? Thanks!

DrFooMod2

2010-09-20 15:38 UTC

I dropped the DLL reference and added the Ookii src project to my solution. It's throwing that exception on the

UserName = userName.ToString(0, (int)userNameSize);

construct. Uh oh. Now what?

Ristogod

2011-02-24 14:31 UTC

I'm using the VistaOpenFileDialog and creating a new instance every time I want to open a dialog. I set the InitialDirectory property on the dialog object every time. However, despite me telling it where to open, it instead remembers the last location and always opens that instead. I need it to open to a specific directory, not the last remembered.

Otherwise, this is a great piece of software and I appreciate you sharing it.

Coach Outlet Online

2011-04-19 07:54 UTC

just we know,your website is useful to many people.

Todd Jackson

2011-05-19 15:17 UTC

Love the Ookii.Dialogs!

Features i'd to see in an upcoming release:
• Multiselect in VistaFolderBrowserDialog
(this obviously wasn't supported in the original FolderBrowserDialog, but could/should in the Vista-style dialog)
• Hybrid dialog that lets you select files and/or folders simultaneously
(for example, suppose I want to select "something.txt" and folder "widgets" simultaneously)

Please consider implementing these requests in your next release. Thank you for a wonderful product!

Laszlo Szikszai

2011-05-31 12:27 UTC

Hello Sven,

I am having difficulty cranking up ookii pocket dictionary on a recent winmo 6.5 mobile. The query about installed fonts doesnt seem to work with either japanese input or the dictionary. Now I could modify the font for the jap. input in the registry and works well but can't seem to do it for the dicitonary itself. Can you help me out here?
Thanks

Pat

2011-06-08 17:14 UTC

Since this is the best way to contact you, here goes. I really like your Dialogs package, but I would like to use it (specifically, the folder browser) in a .NET 4 Client Profile application. (So would others - see http://stackoverflow.com/questions/31059/how-do-you-configure-an-openfiledialog-to-select-folders/511161#511161 .) As I'm sure you know, your assembly targets .NET 3.5 and can't be used in 4-Client because of various designer references.

Because you provide the source, I modified it to work with 4-Client. In doing so, I had to get rid of the TaskDialog and CredentialsDialog. I know that others are interested in using your library with 4-Client, so it would be generous of you to separate out the dialogs that can be converted to 4-client into individual assemblies. It would be great if the whole library could be converted, but, from my experience, that might be a difficult task.

Thanks for your time and great library. If you are so inclined, I would recommend that you post the source to a public repository (e.g. github.com, sourceforge.net, bitbucket.org, etc) and clarify the license so that others can at least contribute patches more easily.
Pat

Useful links:
http://social.msdn.microsoft.com/Forums/en-US/winformsdesigner/thread/8d9217f8-addd-4c91-93fc-a9ee56dc2eba/
http://social.msdn.microsoft.com/Forums/en-US/winformsdesigner/thread/b5906c4d-86ff-49e4-8e6e-d3170e477d7a

none

2011-06-09 20:02 UTC

How do you use this with Vb?

Lance

2011-07-01 18:14 UTC

I'm having the same .NET 4 problems. Pat, you mentioned you modified it to work. Are you willing to share?

Kelly

2012-02-06 23:46 UTC

Thanks a lot, Sven. It saved me a bunch of time, and it really works great.

Will Barrows

2012-06-05 05:30 UTC

I wish I had found this weeks ago! My app really needs a Folder-picker that won't drive users mad.
Due to our security requirements in our environment, I could not download the compiled dlls into ABS, so I got the source code only and compiled it in Visual Studio 2010. Compiles and runs without complaint in Debug mode, but in Release Mode I get a bunch of messages, including some errors. I dealt with the errors, but these warnings in SafeHandles.cs need explanation:
CA2143 : Microsoft.Security : 'ActivationContextSafeHandle', a transparent type or method, contains a declarative security demand for
'SecurityPermissionAttribute'. 'ActivationContextSafeHandle' should be made security-safe critical or the demand should be removed from the transparent code.
CA2143 : Microsoft.Security : 'SafeDeviceHandle', a transparent type or method, contains a declarative security demand for 'SecurityPermissionAttribute'.
'SafeDeviceHandle' should be made security-safe critical or the demand should be removed from the transparent code.
CA2143 : Microsoft.Security : 'SafeGDIHandle', a transparent type or method, contains a declarative security demand for 'SecurityPermissionAttribute'.
'SafeGDIHandle' should be made security-safe critical or the demand should be removed from the transparent code.
Can you help?

Chris

2012-07-14 14:43 UTC

Thanks so much Sven. Thank you also to Zzz for saving a LOT of time with the garbage characters in VistaFolderBrowserDialog in XP!

Berend

2012-08-02 14:07 UTC

Yeah, thanks a lot for spending your time on this!

One question: Is there a way to change the OK/Cancel button captions on the InputDialog? Can I create a custom resource file, or something like that?

bhavin doshi

2012-08-09 16:22 UTC

Thanks a lot for sharing this valuable asset..

Liam

2013-02-28 16:10 UTC

I love this dialog library! Very useful. Thank you Sven.

jixu

2013-04-27 08:39 UTC

I love the Ookii dialog, but I found two problemss(WPF branch for Credentials dialog):
[1] Empty password also will show in password field of the security dialog when calling CredUIPromptForWindowsCredentials dialog.
* First time, I open Credential dialog, checked 'saved credential' checkbox and just only input username
* Second time, when I open the Credential dialog, it showed saved username and passwoed. BUT it should show only username, because I do NOT input any char for password first time.

[2] Modified password field invalid
* First time, I open Credential dialog, checked 'saved credential' checkbox and input username and password(assumed as string "demo")
* Second time, when I open the Credential dialog, it showed saved username and passwoed. BUT if I appended some char(assumed "test") for password filed, then I will get "SAVED_PASSWORDtest" string for password field when calling CredUnPackAuthenticationBuffer to get password

jixu

2013-04-27 08:43 UTC

I love the Ookii dialog, but I found two problemss(WPF branch for Credentials dialog):
[1] Empty password also will show in password field of the security dialog when calling CredUIPromptForWindowsCredentials dialog.
* First time, I open Credential dialog, checked 'saved credential' checkbox and just only input username
* Second time, when I open the Credential dialog, it showed saved username and passwoed. BUT it should show only username, because I do NOT input any char for password first time.

[2] Modified password field invalid
* First time, I open Credential dialog, checked 'saved credential' checkbox and input username and password(assumed as string "demo")
* Second time, when I open the Credential dialog, it showed saved username and passwoed. BUT if I appended some char(assumed "test") for password filed, then I will get "SAVED_PASSWORDtest" string for password field when calling CredUnPackAuthenticationBuffer to get password

Nils

2013-05-17 00:15 UTC

Hello Mr. Groot,

I really like what you achieved with the dialogs. However, during my use of your awesome library, I found a bug with the FilterIndex property of file dialogs. I managed to fix it for me (only needed to get the value) by inserting the following code in line 575 of WPF\VistaFileDialogs.cs:

Ookii.Dialogs.Wpf.Interop.IFileOpenDialog dlg = dialog as Ookii.Dialogs.Wpf.Interop.IFileOpenDialog;
if (dlg != null)
{
uint index;
dlg.GetFileTypeIndex(out index);
_filterIndex = (int)index;
}

I hope you find the time to include some bug fixes in your code and thank you again for creating such a powerful and easy to use library.

Add comment

Comments are closed for this post. Sorry.

Latest posts

Categories

Archive

Syndication

RSS Subscribe