CreateParams.Style プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > CreateParams.Style プロパティの意味・解説 

CreateParams.Style プロパティ

ウィンドウ スタイル値のビットごとの組み合わせ取得または設定します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

解説解説
使用例使用例

Button から派生した MyIconButton という名前のクラス作成しボタンイメージではなくアイコン表示するために必要な実装提供するコード例を、次に示します。CreateParams プロパティ拡張されボタンImage ではなく Icon表示するための値が Style プロパティ追加されます。

import System.*;
import System.Drawing.*;
import System.Windows.Forms.*;
import System.Runtime.InteropServices.*;
import System.Diagnostics.*;
import System.IO.*;
import System.Security.Permissions.*;

/** @attribute SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)
 */
public class MyIconButton extends Button
{
    private Icon icon;

    public MyIconButton()
    {
        // Set the button's FlatStyle property.
        set_FlatStyle(get_FlatStyle().System);
    } //MyIconButton

    public MyIconButton(Icon ButtonIcon)
    {
        // Assign the icon to the private field.   
        this.icon = ButtonIcon;

        // Size the button to 4 pixels larger than the icon.
        this.set_Height(icon.get_Height() + 4);
        this.set_Width(icon.get_Width() + 4);
    } //MyIconButton

    /** @property 
     */
    protected CreateParams get_CreateParams()
    {
        // Extend the CreateParams property of the Button class.
        CreateParams cp = super.get_CreateParams();

        // Update the button Style.
        cp.set_Style(cp.get_Style() | 0x40); // BS_ICON value
        return cp;
    } //get_CreateParams

    /** @property 
     */
    public Icon get_Icon()
    {
        return icon;
    } //get_Icon

    /** @property 
     */
    public void set_Icon(Icon value)
    {
        icon = value;
        UpdateIcon();

        // Size the button to 4 pixels larger than the icon.
        this.set_Height(icon.get_Height() + 4);
        this.set_Width(icon.get_Width() + 4);
    } //set_Icon

    protected void OnHandleCreated(EventArgs
 e)
    {
        super.OnHandleCreated(e);

        // Update the icon on the button if there is currently an icon
 assigned 
        // to the icon field.
        if (icon != null) {
            UpdateIcon();
        }
    } //OnHandleCreated

    private void UpdateIcon()
    {
        IntPtr iconHandle = IntPtr.Zero;

        // Get the icon's handle.
        if (icon != null) {
            iconHandle = icon.get_Handle();
        }

        // Send Windows the message to update the button. 
        SendMessage(get_Handle(), 0x00F7 /*BM_SETIMAGE value*/, 
            1 /*IMAGE_ICON value*/, (iconHandle.ToInt32())); 
        
    } //UpdateIcon

    // Import the SendMessage method of the User32 DLL.   
    /** @attribute DllImport("user32.dll", CharSet = CharSet.Auto)
     */
    public static native IntPtr SendMessage(IntPtr
 hWnd, int msg, 
        int wParam, int lParam);
} //MyIconButton
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CreateParams クラス
CreateParams メンバ
System.Windows.Forms 名前空間
CreateParams.ExStyle プロパティ
CreateParams.ClassStyle プロパティ


このページでは「.NET Framework クラス ライブラリ リファレンス」からCreateParams.Style プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からCreateParams.Style プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からCreateParams.Style プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「CreateParams.Style プロパティ」の関連用語

CreateParams.Style プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



CreateParams.Style プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS