📜 ⬆️ ⬇️

Vista Bridge Library

Today I want to write a little about the Vista Bridge library, which “fills in” some functionality that is missing from the .NET Framework 3.0.


A little introduction.


With the release of .NET FW 3.0, many developers may have noticed that some things were not implemented there that were introduced in Windows Vista, although the framework itself was released with its release. It:

Of course, all this can be done by calling native functions and writing your own libraries, which, for example, was done in the Paint.NET project, but Microsoft apparently decided to fill this gap and released its own library, which contains the missing functionality.
The name of this library is Vista Bridge . This library (its source code) is included in the Windows SDK, but the latest version can be downloaded from the link above.

The archive, which is downloaded from the link, contains the source codes of the library and a set of examples.
After building the library, you can connect it to any project. The library itself is not a big one, only about 140Kb. BUT when writing a project, you should consider 2 things:
  1. The application will work only in Windows Vista.
  2. The following lines should be added to the application manifest file (if visual controls are used)
    < dependency > < dependentAssembly > < assemblyIdentity type ="win32" name ="Microsoft.Windows.Common-Controls" version ="6.0.0.0" processorArchitecture ="*" publicKeyToken ="6595b64144ccf1df" language ="*" /> </ dependentAssembly > </ dependency > * This source code was highlighted with Source Code Highlighter .
    1. < dependency > < dependentAssembly > < assemblyIdentity type ="win32" name ="Microsoft.Windows.Common-Controls" version ="6.0.0.0" processorArchitecture ="*" publicKeyToken ="6595b64144ccf1df" language ="*" /> </ dependentAssembly > </ dependency > * This source code was highlighted with Source Code Highlighter .
    2. < dependency > < dependentAssembly > < assemblyIdentity type ="win32" name ="Microsoft.Windows.Common-Controls" version ="6.0.0.0" processorArchitecture ="*" publicKeyToken ="6595b64144ccf1df" language ="*" /> </ dependentAssembly > </ dependency > * This source code was highlighted with Source Code Highlighter .
    3. < dependency > < dependentAssembly > < assemblyIdentity type ="win32" name ="Microsoft.Windows.Common-Controls" version ="6.0.0.0" processorArchitecture ="*" publicKeyToken ="6595b64144ccf1df" language ="*" /> </ dependentAssembly > </ dependency > * This source code was highlighted with Source Code Highlighter .
    4. < dependency > < dependentAssembly > < assemblyIdentity type ="win32" name ="Microsoft.Windows.Common-Controls" version ="6.0.0.0" processorArchitecture ="*" publicKeyToken ="6595b64144ccf1df" language ="*" /> </ dependentAssembly > </ dependency > * This source code was highlighted with Source Code Highlighter .
    5. < dependency > < dependentAssembly > < assemblyIdentity type ="win32" name ="Microsoft.Windows.Common-Controls" version ="6.0.0.0" processorArchitecture ="*" publicKeyToken ="6595b64144ccf1df" language ="*" /> </ dependentAssembly > </ dependency > * This source code was highlighted with Source Code Highlighter .
    6. < dependency > < dependentAssembly > < assemblyIdentity type ="win32" name ="Microsoft.Windows.Common-Controls" version ="6.0.0.0" processorArchitecture ="*" publicKeyToken ="6595b64144ccf1df" language ="*" /> </ dependentAssembly > </ dependency > * This source code was highlighted with Source Code Highlighter .
    7. < dependency > < dependentAssembly > < assemblyIdentity type ="win32" name ="Microsoft.Windows.Common-Controls" version ="6.0.0.0" processorArchitecture ="*" publicKeyToken ="6595b64144ccf1df" language ="*" /> </ dependentAssembly > </ dependency > * This source code was highlighted with Source Code Highlighter .
    8. < dependency > < dependentAssembly > < assemblyIdentity type ="win32" name ="Microsoft.Windows.Common-Controls" version ="6.0.0.0" processorArchitecture ="*" publicKeyToken ="6595b64144ccf1df" language ="*" /> </ dependentAssembly > </ dependency > * This source code was highlighted with Source Code Highlighter .
    9. < dependency > < dependentAssembly > < assemblyIdentity type ="win32" name ="Microsoft.Windows.Common-Controls" version ="6.0.0.0" processorArchitecture ="*" publicKeyToken ="6595b64144ccf1df" language ="*" /> </ dependentAssembly > </ dependency > * This source code was highlighted with Source Code Highlighter .
    10. < dependency > < dependentAssembly > < assemblyIdentity type ="win32" name ="Microsoft.Windows.Common-Controls" version ="6.0.0.0" processorArchitecture ="*" publicKeyToken ="6595b64144ccf1df" language ="*" /> </ dependentAssembly > </ dependency > * This source code was highlighted with Source Code Highlighter .
    11. < dependency > < dependentAssembly > < assemblyIdentity type ="win32" name ="Microsoft.Windows.Common-Controls" version ="6.0.0.0" processorArchitecture ="*" publicKeyToken ="6595b64144ccf1df" language ="*" /> </ dependentAssembly > </ dependency > * This source code was highlighted with Source Code Highlighter .
    12. < dependency > < dependentAssembly > < assemblyIdentity type ="win32" name ="Microsoft.Windows.Common-Controls" version ="6.0.0.0" processorArchitecture ="*" publicKeyToken ="6595b64144ccf1df" language ="*" /> </ dependentAssembly > </ dependency > * This source code was highlighted with Source Code Highlighter .
    < dependency > < dependentAssembly > < assemblyIdentity type ="win32" name ="Microsoft.Windows.Common-Controls" version ="6.0.0.0" processorArchitecture ="*" publicKeyToken ="6595b64144ccf1df" language ="*" /> </ dependentAssembly > </ dependency > * This source code was highlighted with Source Code Highlighter .
    Otherwise, the application may fall down (at least I fell until I added these lines).

')

Example of creating a dialog box



What good is this library for WPF, it allows you to create a Task Dialog in resources (for example, windows), and then use them.
Below I gave an example of how using this library you can make a stylized dialog box:
  1. < Window x: Class = "VBSample.Window1"
  2. xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns: vl = "clr-namespace: Microsoft.SDK.Samples.VistaBridge.Library; assembly = VistaBridgeLibrary"
  5. Title = "Window1" Height = "300" Width = "300" >
  6. < Window.Resources >
  7. < vl: TaskDialog x: Key = "SampleUACDialog"
  8. Caption = "User Account Control"
  9. FooterText = "User Account Control (UAC) helps prevent unauthorized changes to your computer."
  10. CollapsedControlText = "Details"
  11. ExpandedText = "C: \ Windows \ System \ mmc.exe"
  12. MainIcon = "Shield" Instruction = "Windows requires permission to continue." Content = "If this action is started by you, continue. MMC" >
  13. < vl: TaskDialogButton Text = "Continue" />
  14. < vl: TaskDialogButton Text = "Cancel" />
  15. </ vl: TaskDialog >
  16. </ Window.Resources >
  17. < Grid >
  18. < Button Height = "23" HorizontalAlignment = "Right" Margin = "0,0,26,38" Name = "button1" VerticalAlignment = "Bottom" Width = "75" Click = "button1_Click" > Button </ Button >
  19. </ Grid >
  20. </ Window >
* This source code was highlighted with Source Code Highlighter .


and the code that calls this dialogue
private void button1_Click( object sender, RoutedEventArgs e)<br> {<br> TaskDialog td = (TaskDialog)FindResource( "SampleUACDialog" );<br> td.Show();<br> } <br><br> * This source code was highlighted with Source Code Highlighter .


Here's what happens (expanded and collapsed options):




Instead of conclusion



I did not begin to describe all the functionality of this library, since by the examples that go along with it, it is quite possible to figure out for yourself what and how. But such dialog boxes for many stylized projects, in my opinion, will not be very bad.

Many possibilities for creating such tasks are unfortunately not supported (perhaps for now). So, the Content property can only be a string, but it would be nice if it were a container for other elements - you could shove it there, whatever your heart desires. It is also impossible to change the size of such windows, but these are most likely limitations of Windows itself.

Source: https://habr.com/ru/post/45573/


All Articles