Style Common Dialog Boxes
-
How can one apply an application style to the Common Dialogs? I've got a dark style going on in my app and this file open dialog is so bright it is jarring. Any ideas?
// Configure open file dialog box Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = "Document"; // Default file name dlg.DefaultExt = ".txt"; // Default file extension dlg.Filter = "Text documents (.txt)|*.txt"; // Filter files by extension // Show open file dialog box Nullable<bool> result = dlg.ShowDialog(); // Process open file dialog box results if (result == true) { // Open document string filename = dlg.FileName; }
Sincerely, -Ron
-
How can one apply an application style to the Common Dialogs? I've got a dark style going on in my app and this file open dialog is so bright it is jarring. Any ideas?
// Configure open file dialog box Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = "Document"; // Default file name dlg.DefaultExt = ".txt"; // Default file extension dlg.Filter = "Text documents (.txt)|*.txt"; // Filter files by extension // Show open file dialog box Nullable<bool> result = dlg.ShowDialog(); // Process open file dialog box results if (result == true) { // Open document string filename = dlg.FileName; }
Sincerely, -Ron
Ron, Dialog boxes are generally styled according to the operating system, as opposed to the UI that opened them since the users desktop theme will be used to style the dialog box. Example, Windows XP and Vista File Open dialogs look and work slightly different and are styled according to the users desktop theme. If you check out the WPF SDK, there is a Vista Bridge library that gets you going with using dialog boxes that are operating system specific. I have been hoping that Microsoft would bake operating system dialogs into .NET so that no matter which O/S was running the correct dialog for that O/S would display without a lot of extra work on the developers part. You "could" always write your own... No fun working with the Win32 API if you don't really have to. Sorry I could be of more help.
Cheers, Karl
» CodeProject 2008 MVP » Microsoft MVP - Client App Dev My Blog | Mole's Home Page | MVP ProfileJust a grain of sand on the worlds beaches.
-
Ron, Dialog boxes are generally styled according to the operating system, as opposed to the UI that opened them since the users desktop theme will be used to style the dialog box. Example, Windows XP and Vista File Open dialogs look and work slightly different and are styled according to the users desktop theme. If you check out the WPF SDK, there is a Vista Bridge library that gets you going with using dialog boxes that are operating system specific. I have been hoping that Microsoft would bake operating system dialogs into .NET so that no matter which O/S was running the correct dialog for that O/S would display without a lot of extra work on the developers part. You "could" always write your own... No fun working with the Win32 API if you don't really have to. Sorry I could be of more help.
Cheers, Karl
» CodeProject 2008 MVP » Microsoft MVP - Client App Dev My Blog | Mole's Home Page | MVP ProfileJust a grain of sand on the worlds beaches.
-
Ron, Yes. Give this article a look: http://www.codeproject.com/KB/WPF/WPFTaskDialogVistaAndXP.aspx[^] This is where you need to make a decision. You can have all custom dialogs or use the operating system ones. For the message boxes, I wanted my XP users to have the rich features of the TaskDialog so I wrote the above library to provide that. I also have similar boxes for my file dialogs.
Cheers, Karl
» CodeProject 2008 MVP » Microsoft MVP - Client App Dev My Blog | Mole's Home Page | MVP ProfileJust a grain of sand on the worlds beaches.