Pages

Wednesday, March 07, 2007

Delphi 2007 - New Vista dialogs

Delphi 2007 supports new-style Open/Save dialogs on Vista, allows you to configure new features in those dialogs and does it in a way that's compatible with older applications. Sadly, it only does two out of three things at once (admittedly, even that is a lot and more would be a pure magic).

If you know you'll be running on Vista, you can use new TFileOpenDialog (or TFileSaveDialog - everything I'll tell you about Open dialog holds also for Save dialog) which exposes new properties, such as FavoriteLinks and OkButtonLabel, and new options. But if you'll try to open this dialog on pre-Vista Windows, you'll only get an error message. (Still, that app will load fine up to the point when you actually try to display the dialog, so it is entirely possible to code two paths in your application, one using TFileOpenDialog if OS is Vista and another using TOpenDialog in all other cases.)

If you use TOpenDialog, you'll get an old-shool dialog, but it will work on all Windows.

And then there's a third possibility - you can use TOpenDialog while setting the global variable UseLatestCommonDialogs (declared in Dialogs.pas) to True. In that case, TOpenDialog will use new-style dialog on Vista and old-style dialog on older Windows. However, you'll not be able to specify any new Vista-only properties (like the OkButtonLabel I mentioned above).

In visual summary, your options are:

TOpenDialog

TOpenDialog +
UseLatestCommonDialogs

TFileOpenDialog

Vista
Windows XP

Besides file open/save dialogs, Delphi 2007 includes support for task dialogs. TTaskDialog components allows for simple creation of task dialogs, together with icons, expanded section, progress bar etc. Of course, it will only work on Windows Vista.


[I'm blogging about Spacely - the beta version of Delphi 2007 for Win32 - with special permission given from CodeGear.]

Technorati tags: , ,

3 comments:

  1. Anonymous21:48

    Why not make the TFileOpenDialog (and TFileSaveDialog) smart enough to load on all OSes and only show those features supported by each OS?

    The way it's implemented doesn't make it look 'pure', it makes it look like a kludge - one that makes you have to code in a workaround for something that should have been obvious to CodeGear.

    ReplyDelete
  2. As I'm not working for CodeGear, I couldn't really say.

    Go to the Quality Central and enter a feature suggestion.

    ReplyDelete
  3. I will assume because there is new functionality on the Vista Dialog that is not available on XP, so you will need to enter code exclusively for XP and code exclusively for Vista and this code will be executed with nice Ifs everywhere.

    If that is what you will end up doing, I think that the best visual way to achieve the same goal will be to have that coding as a visual component, or to have a component that can use the share common elements so you only enter code for visual elements that are common, loosing on the process the new Vista features.

    Oh wait, that is what they implemented.

    ReplyDelete