次の方法で共有


IUIService.Styles プロパティ

ホストの環境に固有なスタイルのコレクションを取得します。

ReadOnly Property Styles As IDictionary
[C#]
IDictionary Styles {get;}
[C++]
__property IDictionary* get_Styles();
[JScript]
function get Styles() : IDictionary;

プロパティ値

スタイルの設定値を格納している IDictionary

解説

ディクショナリは、ホスト環境からの情報を提供できます。少なくとも、ディクショナリは、標準の UI テキストに使用するフォント、および強調表示に使用する色で構成されています。これらの必須スタイルは "DialogFont" および "HighlightColor" です。

これらのスタイルの値は、スタイルをディクショナリのキーとして使用し、キーをインデクサとして使用してディクショナリにアクセスして取得できます。例: (IUIService を実装しているオブジェクト).Styles[(引用符で囲まれたスタイル名文字列)]

使用例

[Visual Basic, C#, C++] ホスト環境からダイアログ フォントを取得する例を次に示します。

 
' The specified IDesigner implements IUIService.
Function GetFont(designer As IDesigner) As Font
    Dim hostfont As Font
       
    ' Gets the dialog box font from the host environment.
    hostfont = CType(CType(designer, IUIService).Styles("DialogFont"), Font)
       
    Return hostfont
End Function


[C#] 
// The specified IDesigner implements IUIService.
Font GetFont(IDesigner designer)
{      
      Font        hostfont;

      // Gets the dialog box font from the host environment. 
      hostfont = (Font)((IUIService)designer).Styles["DialogFont"];
      
      return hostfont;
}
   

[C++] 
// The specified IDesigner implements IUIService.
System::Drawing::Font* GetFont(IDesigner* designer) {
    System::Drawing::Font* hostfont;

    // Gets the dialog box font from the host environment.
    hostfont = dynamic_cast<System::Drawing::Font*>( dynamic_cast<IUIService*>(designer)->Styles->Item[S"DialogFont"] );

    return hostfont;
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

IUIService インターフェイス | IUIService メンバ | System.Windows.Forms.Design 名前空間 | Font