Vista Bridgeライブラリ

今日は、.NET Framework 3.0に欠けている機能を「補う」Vista Bridgeライブラリについて少し書きたいと思います。





小さな紹介。



.NET FW 3.0のリリースにより、多くの開発者は、フレームワーク自体はリリースとともにリリースされましたが、Windows Vistaで導入されたものの一部がそこに実装されていないことに気付いたかもしれません。 これは:



もちろん、これはすべて、ネイティブ関数を呼び出して、たとえばPaint.NETプロジェクトで行われた独自のライブラリを作成することで実現できますが、Microsoftは明らかにこのギャップを埋めることを決定し、不足している機能を含む独自のライブラリをリリースしました。

このライブラリの名前はVista Bridgeです。 このライブラリ(ソースコード)はWindows SDKの一部ですが、最新バージョンは上記のリンクからダウンロードできます。



指定されたリンクからダウンロードされるアーカイブには、ライブラリのソースコードと一連のサンプルが含まれています。

ライブラリを構築したら、任意のプロジェクトに接続できます。 ライブラリ自体は大きくなく、約140 KBです。 ただし、プロジェクトを作成するときは、2つのことを考慮する必要があります。

  1. アプリケーションはWindows Vistaでのみ動作します。
  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 .



    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 .



    そうしないと、アプリケーションがクラッシュする可能性があります(少なくともこれらの行を追加する前にクラッシュしました)。




ダイアログボックスの作成例





WPFに適しているのはこのライブラリです。リソース(たとえば、ウィンドウ)でタスクダイアログを作成し、それを使用できます。

以下に、このライブラリを使用して様式化されたダイアログボックスを作成する方法の例を示しました。





  1. < ウィンドウ x:クラス = "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. タイトル = "Window1" 高さ = "300" = "300" >
  6. < Window.Resources >
  7. < vl:TaskDialog x:Key = "SampleUACDialog"
  8. キャプション =「ユーザーアカウント制御」
  9. FooterText = "ユーザーアカウント制御(UAC)は、コンピューターへの不正な変更を防ぐのに役立ちます。"
  10. CollapsedControlText = "詳細"
  11. ExpandedText = "C:\ Windows \ System \ mmc.exe"
  12. MainIcon = "Shield" Instruction = "Windowsには続行するためのアクセス許可が必要です" Content = "このアクションを開始した場合、続行します。MMC管理コンソール" >
  13. < vl:TaskDialogBu​​tton Text = "Continue" />
  14. < vl:TaskDialogBu​​tton Text = "Cancel" />
  15. </ vl:TaskDialog >
  16. </ Window.Resources >
  17. < グリッド >
  18. < ボタンの 高さ = "23" Horizo​​ntalAlignment = "右" マージン = "0,0,26,38" 名前 = "button1" VerticalAlignment = "下" = "75" クリック = "button1_Click" >ボタン</ ボタン >
  19. </ グリッド >
  20. </ ウィンドウ >
*このソースコードは、 ソースコードハイライターで強調表示されました。




このダイアログを呼び出すコード

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 .







次に、何が起こるかを示します(展開オプションと折りたたみオプション)。









結論の代わりに





このライブラリの完全な機能については説明しませんでした。 彼女に付属している例によって、自分自身で何をどのように把握するかはかなり可能です。 しかし、私の意見では、多くの定型化されたプロジェクトのこのようなダイアログボックスはそれほど悪くないでしょう。



残念ながら、そのようなタスクを作成するための多くの機能はサポートされていません(おそらく今のところ)。 したがって、Contentプロパティには文字列のみを使用できます。他の要素のコンテナであると便利です。好きなように詰め込むことができます。 このようなウィンドウのサイズを変更することもできませんが、これはおそらくWindows自体の制限です。






All Articles