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

GdipCreateHatchBrush

関数
ハッチパターンのブラシを作成する。
DLLgdiplus.dll呼出規約winapi

シグネチャ

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

Status GdipCreateHatchBrush(
    HatchStyle hatchstyle,
    DWORD forecol,
    DWORD backcol,
    GpHatch** brush
);

パラメーター

名前方向
hatchstyleHatchStylein
forecolDWORDin
backcolDWORDin
brushGpHatch**inout

戻り値の型: Status

各言語での呼び出し定義

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

Status GdipCreateHatchBrush(
    HatchStyle hatchstyle,
    DWORD forecol,
    DWORD backcol,
    GpHatch** brush
);
[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipCreateHatchBrush(
    int hatchstyle,   // HatchStyle
    uint forecol,   // DWORD
    uint backcol,   // DWORD
    IntPtr brush   // GpHatch** in/out
);
<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipCreateHatchBrush(
    hatchstyle As Integer,   ' HatchStyle
    forecol As UInteger,   ' DWORD
    backcol As UInteger,   ' DWORD
    brush As IntPtr   ' GpHatch** in/out
) As Integer
End Function
' hatchstyle : HatchStyle
' forecol : DWORD
' backcol : DWORD
' brush : GpHatch** in/out
Declare PtrSafe Function GdipCreateHatchBrush Lib "gdiplus" ( _
    ByVal hatchstyle As Long, _
    ByVal forecol As Long, _
    ByVal backcol As Long, _
    ByVal brush As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GdipCreateHatchBrush = ctypes.windll.gdiplus.GdipCreateHatchBrush
GdipCreateHatchBrush.restype = ctypes.c_int
GdipCreateHatchBrush.argtypes = [
    ctypes.c_int,  # hatchstyle : HatchStyle
    wintypes.DWORD,  # forecol : DWORD
    wintypes.DWORD,  # backcol : DWORD
    ctypes.c_void_p,  # brush : GpHatch** in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('gdiplus.dll')
GdipCreateHatchBrush = Fiddle::Function.new(
  lib['GdipCreateHatchBrush'],
  [
    Fiddle::TYPE_INT,  # hatchstyle : HatchStyle
    -Fiddle::TYPE_INT,  # forecol : DWORD
    -Fiddle::TYPE_INT,  # backcol : DWORD
    Fiddle::TYPE_VOIDP,  # brush : GpHatch** in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdiplus")]
extern "system" {
    fn GdipCreateHatchBrush(
        hatchstyle: i32,  // HatchStyle
        forecol: u32,  // DWORD
        backcol: u32,  // DWORD
        brush: *mut *mut GpHatch  // GpHatch** in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("gdiplus.dll")]
public static extern int GdipCreateHatchBrush(int hatchstyle, uint forecol, uint backcol, IntPtr brush);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipCreateHatchBrush' -Namespace Win32 -PassThru
# $api::GdipCreateHatchBrush(hatchstyle, forecol, backcol, brush)
#uselib "gdiplus.dll"
#func global GdipCreateHatchBrush "GdipCreateHatchBrush" sptr, sptr, sptr, sptr
; GdipCreateHatchBrush hatchstyle, forecol, backcol, varptr(brush)   ; 戻り値は stat
; hatchstyle : HatchStyle -> "sptr"
; forecol : DWORD -> "sptr"
; backcol : DWORD -> "sptr"
; brush : GpHatch** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "gdiplus.dll"
#cfunc global GdipCreateHatchBrush "GdipCreateHatchBrush" int, int, int, var
; res = GdipCreateHatchBrush(hatchstyle, forecol, backcol, brush)
; hatchstyle : HatchStyle -> "int"
; forecol : DWORD -> "int"
; backcol : DWORD -> "int"
; brush : GpHatch** in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; Status GdipCreateHatchBrush(HatchStyle hatchstyle, DWORD forecol, DWORD backcol, GpHatch** brush)
#uselib "gdiplus.dll"
#cfunc global GdipCreateHatchBrush "GdipCreateHatchBrush" int, int, int, var
; res = GdipCreateHatchBrush(hatchstyle, forecol, backcol, brush)
; hatchstyle : HatchStyle -> "int"
; forecol : DWORD -> "int"
; backcol : DWORD -> "int"
; brush : GpHatch** in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
	procGdipCreateHatchBrush = gdiplus.NewProc("GdipCreateHatchBrush")
)

// hatchstyle (HatchStyle), forecol (DWORD), backcol (DWORD), brush (GpHatch** in/out)
r1, _, err := procGdipCreateHatchBrush.Call(
	uintptr(hatchstyle),
	uintptr(forecol),
	uintptr(backcol),
	uintptr(brush),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // Status
function GdipCreateHatchBrush(
  hatchstyle: Integer;   // HatchStyle
  forecol: DWORD;   // DWORD
  backcol: DWORD;   // DWORD
  brush: Pointer   // GpHatch** in/out
): Integer; stdcall;
  external 'gdiplus.dll' name 'GdipCreateHatchBrush';
result := DllCall("gdiplus\GdipCreateHatchBrush"
    , "Int", hatchstyle   ; HatchStyle
    , "UInt", forecol   ; DWORD
    , "UInt", backcol   ; DWORD
    , "Ptr", brush   ; GpHatch** in/out
    , "Int")   ; return: Status
●GdipCreateHatchBrush(hatchstyle, forecol, backcol, brush) = DLL("gdiplus.dll", "int GdipCreateHatchBrush(int, dword, dword, void*)")
# 呼び出し: GdipCreateHatchBrush(hatchstyle, forecol, backcol, brush)
# hatchstyle : HatchStyle -> "int"
# forecol : DWORD -> "dword"
# backcol : DWORD -> "dword"
# brush : GpHatch** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。