![]() |
Platforms, Frameworks & Libraries »
Vista API »
General
Intermediate
Vista ControlsBy Pedro M. C. CardosoWindows Vista Controls that degrade gracefully on Legacy Windows |
C# 2.0, Windows, .NET, Visual Studio, Dev
|
|
Advanced Search |
|
|
|
||||||||||||||||

Vista Controls is a class library that provides the ability to use the new style controls on Microsoft Windows Vista.
.NET 2.0 applications that use the Treeview, Listview, OpenFileDialog, SaveFileDialog and FolderBrowserDialog classes provided in the System.Windows.Forms assembly will find that when they run on Windows Vista, they do not use the new, Vista-style look and feel, but instead continue to use the old, XP-style look and feel.
In Vista Controls you will find five replacement classes, that will use the Vista look and feel when running on Windows Vista, and the old style on older versions of Windows. This allows you to target both Windows Vista and other versions of Windows without any additional effort on your part.
Additionally, Vista Controls includes a new control added to Vista, the Command Link. Because this control doesn't exist in previous versions of Windows, an emulated version that mimics Vista look and feel is used on those Windows versions.
The classes in Vista Controls have exactly the same public interface and functionality (with a few minor exceptions noted below), so you can just replace all instances of System.Windows.Forms.TreeView, System.Windows.Forms.ListView, System.Windows.Forms.FileDialog, System.Windows.Forms.OpenFileDialog, System.Windows.Forms.SaveFileDialog and System.Windows.Forms.FolderBrowserDialog with Vista_Api.TreeView, Vista_Api.ListView, Vista_Api.FileDialog, Vista_Api.OpenFileDialog. Vista_Api.SaveFileDialog and Vista_Api.FolderBrowserDialog respectively.
The Vista Controls classes automatically fall back to the regular look if the Vista style look and feel is not supported (if your application is running on older versions of Windows). This means that you can use these classes even if your application is not targeted exclusively at Windows Vista. These classes fully support all platforms targeted by the .NET Framework 2.0, and will use the best available appearance on each of them.
There are a few places where Vista Controls classes deviate from their counterparts in System.Windows.Forms:
SupportMultiDottedExtensions property has no effect on the Vista style dialogs. ReadOnlyChecked property has no effect on the Vista style dialogs. The ReadOnlyChecked property is still used to determine whether the user chose this option after the dialog is closed. For the VistaFolderBrowserDialog class: FolderBrowserDialog class without testing your application in both Windows Vista and older Windows versions. RootFolder property has no effect on the Vista style dialog. ShowNewFolderButton property has no effect on the Vista style dialog; the button is always visible. UseDescriptionForTitle property to indicate that you want the value of the Description property to be used as the dialog title instead for the Vista style dialog. This has no effect on the old style dialogs. VistaDialogs if all you have is FileDialogPermission. Your application needs to have full trust to use the Vista Controls assembly. The Open File, Save File and Open Folder common dialogs.

private void button6_Click(object sender, EventArgs e)
{
Vista_Api.OpenFileDialog d = new Vista_Api.OpenFileDialog();
d.ShowDialog();
}

private void button5_Click(object sender, EventArgs e)
{
Vista_Api.SaveFileDialog d = new Vista_Api.SaveFileDialog();
d.ShowDialog();
}

private void button4_Click(object sender, EventArgs e)
{
FolderBrowserDialog d = new FolderBrowserDialog();
d.ShowDialog();
}
Command links are a new control that presents options to the user with links instead of command buttons or radio buttons. They are the preferred approach when longer labels are needed to help users make informed choices. They also reduce the number of clicks required to make choices.
private void commandLink2_Click(object sender, EventArgs e)
{
List<vista_api.commandlink> links=new List<vista_api.commandlink>();
Vista_Api.CommandLink cl = new Vista_Api.CommandLink(
Vista_Api.CommandLink.DisplayStyle.Arrow, "Lorem Ipsum",
"Lorem Ipsum");
cl = new Vista_Api.CommandLink(Vista_Api.CommandLink.DisplayStyle.Arrow,
"Lorem Ipsum", "Lorem Ipsum");
cl.BackColor = SystemColors.Window;
links.Add(cl);
cl = new Vista_Api.CommandLink(Vista_Api.CommandLink.DisplayStyle.Arrow,
"Lorem Ipsum", "Lorem Ipsum");
cl.BackColor = SystemColors.Window;
links.Add(cl);
cl = new Vista_Api.CommandLink(Vista_Api.CommandLink.DisplayStyle.Shield,
"Lorem Ipsum", "Lorem Ipsum");
cl.BackColor = SystemColors.Window;
links.Add(cl);
Vista_Api.CommandDialog cd = new Vista_Api.CommandDialog(links);
cd.Title = "Lorem Ipsum";
cd.Description = "Lorem Ipsum";
cd.ShowDialog();
}
</vista_api.commandlink></vista_api.commandlink>
TreeViews Enhancements:
ListViews Enhancements:
See the initial image for screen shots of these controls.
The detection of the Windows version is made in Vista_Api.Dialog.Native.NativeMethods.
/// <value>
/// Returns true on Windows Vista or newer operating systems; otherwise,
/// false.
/// </value>
false)>
public static bool IsVistaOrLater
{
get
{
return Environment.OSVersion.Platform ==
PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 6;
}
}
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 18 Apr 2007 Editor: Sean Ewington |
Copyright 2007 by Pedro M. C. Cardoso Everything else Copyright © CodeProject, 1999-2009 Web11 | Advertise on the Code Project |