Win32 API 日本語リファレンス
ホームGraphics.Gdi › CreateSolidBrush

CreateSolidBrush

関数
指定した色の塗りつぶし用ソリッドブラシを作成する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// GDI32.dll
#include <windows.h>

HBRUSH CreateSolidBrush(
    COLORREF color
);

パラメーター

名前方向
colorCOLORREFin

戻り値の型: HBRUSH

各言語での呼び出し定義

// GDI32.dll
#include <windows.h>

HBRUSH CreateSolidBrush(
    COLORREF color
);
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern IntPtr CreateSolidBrush(
    uint color   // COLORREF
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function CreateSolidBrush(
    color As UInteger   ' COLORREF
) As IntPtr
End Function
' color : COLORREF
Declare PtrSafe Function CreateSolidBrush Lib "gdi32" ( _
    ByVal color As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CreateSolidBrush = ctypes.windll.gdi32.CreateSolidBrush
CreateSolidBrush.restype = ctypes.c_void_p
CreateSolidBrush.argtypes = [
    wintypes.DWORD,  # color : COLORREF
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
CreateSolidBrush = Fiddle::Function.new(
  lib['CreateSolidBrush'],
  [
    -Fiddle::TYPE_INT,  # color : COLORREF
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "gdi32")]
extern "system" {
    fn CreateSolidBrush(
        color: u32  // COLORREF
    ) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("GDI32.dll")]
public static extern IntPtr CreateSolidBrush(uint color);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_CreateSolidBrush' -Namespace Win32 -PassThru
# $api::CreateSolidBrush(color)
#uselib "GDI32.dll"
#func global CreateSolidBrush "CreateSolidBrush" sptr
; CreateSolidBrush color   ; 戻り値は stat
; color : COLORREF -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "GDI32.dll"
#cfunc global CreateSolidBrush "CreateSolidBrush" int
; res = CreateSolidBrush(color)
; color : COLORREF -> "int"
; HBRUSH CreateSolidBrush(COLORREF color)
#uselib "GDI32.dll"
#cfunc global CreateSolidBrush "CreateSolidBrush" int
; res = CreateSolidBrush(color)
; color : COLORREF -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procCreateSolidBrush = gdi32.NewProc("CreateSolidBrush")
)

// color (COLORREF)
r1, _, err := procCreateSolidBrush.Call(
	uintptr(color),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HBRUSH
function CreateSolidBrush(
  color: DWORD   // COLORREF
): THandle; stdcall;
  external 'GDI32.dll' name 'CreateSolidBrush';
result := DllCall("GDI32\CreateSolidBrush"
    , "UInt", color   ; COLORREF
    , "Ptr")   ; return: HBRUSH
●CreateSolidBrush(color) = DLL("GDI32.dll", "void* CreateSolidBrush(dword)")
# 呼び出し: CreateSolidBrush(color)
# color : COLORREF -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。