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

DrawStateW

関数
状態フラグに応じて淡色化等の効果を付けて画像や文字列を描画する(Unicode版)。
DLLUSER32.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// USER32.dll  (Unicode / -W)
#include <windows.h>

BOOL DrawStateW(
    HDC hdc,
    HBRUSH hbrFore,   // optional
    DRAWSTATEPROC qfnCallBack,   // optional
    LPARAM lData,
    WPARAM wData,
    INT x,
    INT y,
    INT cx,
    INT cy,
    DRAWSTATE_FLAGS uFlags
);

パラメーター

名前方向
hdcHDCin
hbrForeHBRUSHinoptional
qfnCallBackDRAWSTATEPROCinoptional
lDataLPARAMin
wDataWPARAMin
xINTin
yINTin
cxINTin
cyINTin
uFlagsDRAWSTATE_FLAGSin

戻り値の型: BOOL

各言語での呼び出し定義

// USER32.dll  (Unicode / -W)
#include <windows.h>

BOOL DrawStateW(
    HDC hdc,
    HBRUSH hbrFore,   // optional
    DRAWSTATEPROC qfnCallBack,   // optional
    LPARAM lData,
    WPARAM wData,
    INT x,
    INT y,
    INT cx,
    INT cy,
    DRAWSTATE_FLAGS uFlags
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool DrawStateW(
    IntPtr hdc,   // HDC
    IntPtr hbrFore,   // HBRUSH optional
    IntPtr qfnCallBack,   // DRAWSTATEPROC optional
    IntPtr lData,   // LPARAM
    UIntPtr wData,   // WPARAM
    int x,   // INT
    int y,   // INT
    int cx,   // INT
    int cy,   // INT
    uint uFlags   // DRAWSTATE_FLAGS
);
<DllImport("USER32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function DrawStateW(
    hdc As IntPtr,   ' HDC
    hbrFore As IntPtr,   ' HBRUSH optional
    qfnCallBack As IntPtr,   ' DRAWSTATEPROC optional
    lData As IntPtr,   ' LPARAM
    wData As UIntPtr,   ' WPARAM
    x As Integer,   ' INT
    y As Integer,   ' INT
    cx As Integer,   ' INT
    cy As Integer,   ' INT
    uFlags As UInteger   ' DRAWSTATE_FLAGS
) As Boolean
End Function
' hdc : HDC
' hbrFore : HBRUSH optional
' qfnCallBack : DRAWSTATEPROC optional
' lData : LPARAM
' wData : WPARAM
' x : INT
' y : INT
' cx : INT
' cy : INT
' uFlags : DRAWSTATE_FLAGS
Declare PtrSafe Function DrawStateW Lib "user32" ( _
    ByVal hdc As LongPtr, _
    ByVal hbrFore As LongPtr, _
    ByVal qfnCallBack As LongPtr, _
    ByVal lData As LongPtr, _
    ByVal wData As LongPtr, _
    ByVal x As Long, _
    ByVal y As Long, _
    ByVal cx As Long, _
    ByVal cy As Long, _
    ByVal uFlags As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DrawStateW = ctypes.windll.user32.DrawStateW
DrawStateW.restype = wintypes.BOOL
DrawStateW.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    wintypes.HANDLE,  # hbrFore : HBRUSH optional
    ctypes.c_void_p,  # qfnCallBack : DRAWSTATEPROC optional
    ctypes.c_ssize_t,  # lData : LPARAM
    ctypes.c_size_t,  # wData : WPARAM
    ctypes.c_int,  # x : INT
    ctypes.c_int,  # y : INT
    ctypes.c_int,  # cx : INT
    ctypes.c_int,  # cy : INT
    wintypes.DWORD,  # uFlags : DRAWSTATE_FLAGS
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
DrawStateW = Fiddle::Function.new(
  lib['DrawStateW'],
  [
    Fiddle::TYPE_VOIDP,  # hdc : HDC
    Fiddle::TYPE_VOIDP,  # hbrFore : HBRUSH optional
    Fiddle::TYPE_VOIDP,  # qfnCallBack : DRAWSTATEPROC optional
    Fiddle::TYPE_INTPTR_T,  # lData : LPARAM
    Fiddle::TYPE_UINTPTR_T,  # wData : WPARAM
    Fiddle::TYPE_INT,  # x : INT
    Fiddle::TYPE_INT,  # y : INT
    Fiddle::TYPE_INT,  # cx : INT
    Fiddle::TYPE_INT,  # cy : INT
    -Fiddle::TYPE_INT,  # uFlags : DRAWSTATE_FLAGS
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "user32")]
extern "system" {
    fn DrawStateW(
        hdc: *mut core::ffi::c_void,  // HDC
        hbrFore: *mut core::ffi::c_void,  // HBRUSH optional
        qfnCallBack: *const core::ffi::c_void,  // DRAWSTATEPROC optional
        lData: isize,  // LPARAM
        wData: usize,  // WPARAM
        x: i32,  // INT
        y: i32,  // INT
        cx: i32,  // INT
        cy: i32,  // INT
        uFlags: u32  // DRAWSTATE_FLAGS
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", CharSet = CharSet.Unicode)]
public static extern bool DrawStateW(IntPtr hdc, IntPtr hbrFore, IntPtr qfnCallBack, IntPtr lData, UIntPtr wData, int x, int y, int cx, int cy, uint uFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_DrawStateW' -Namespace Win32 -PassThru
# $api::DrawStateW(hdc, hbrFore, qfnCallBack, lData, wData, x, y, cx, cy, uFlags)
#uselib "USER32.dll"
#func global DrawStateW "DrawStateW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; DrawStateW hdc, hbrFore, qfnCallBack, lData, wData, x, y, cx, cy, uFlags   ; 戻り値は stat
; hdc : HDC -> "wptr"
; hbrFore : HBRUSH optional -> "wptr"
; qfnCallBack : DRAWSTATEPROC optional -> "wptr"
; lData : LPARAM -> "wptr"
; wData : WPARAM -> "wptr"
; x : INT -> "wptr"
; y : INT -> "wptr"
; cx : INT -> "wptr"
; cy : INT -> "wptr"
; uFlags : DRAWSTATE_FLAGS -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "USER32.dll"
#cfunc global DrawStateW "DrawStateW" sptr, sptr, sptr, sptr, sptr, int, int, int, int, int
; res = DrawStateW(hdc, hbrFore, qfnCallBack, lData, wData, x, y, cx, cy, uFlags)
; hdc : HDC -> "sptr"
; hbrFore : HBRUSH optional -> "sptr"
; qfnCallBack : DRAWSTATEPROC optional -> "sptr"
; lData : LPARAM -> "sptr"
; wData : WPARAM -> "sptr"
; x : INT -> "int"
; y : INT -> "int"
; cx : INT -> "int"
; cy : INT -> "int"
; uFlags : DRAWSTATE_FLAGS -> "int"
; BOOL DrawStateW(HDC hdc, HBRUSH hbrFore, DRAWSTATEPROC qfnCallBack, LPARAM lData, WPARAM wData, INT x, INT y, INT cx, INT cy, DRAWSTATE_FLAGS uFlags)
#uselib "USER32.dll"
#cfunc global DrawStateW "DrawStateW" intptr, intptr, intptr, intptr, intptr, int, int, int, int, int
; res = DrawStateW(hdc, hbrFore, qfnCallBack, lData, wData, x, y, cx, cy, uFlags)
; hdc : HDC -> "intptr"
; hbrFore : HBRUSH optional -> "intptr"
; qfnCallBack : DRAWSTATEPROC optional -> "intptr"
; lData : LPARAM -> "intptr"
; wData : WPARAM -> "intptr"
; x : INT -> "int"
; y : INT -> "int"
; cx : INT -> "int"
; cy : INT -> "int"
; uFlags : DRAWSTATE_FLAGS -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procDrawStateW = user32.NewProc("DrawStateW")
)

// hdc (HDC), hbrFore (HBRUSH optional), qfnCallBack (DRAWSTATEPROC optional), lData (LPARAM), wData (WPARAM), x (INT), y (INT), cx (INT), cy (INT), uFlags (DRAWSTATE_FLAGS)
r1, _, err := procDrawStateW.Call(
	uintptr(hdc),
	uintptr(hbrFore),
	uintptr(qfnCallBack),
	uintptr(lData),
	uintptr(wData),
	uintptr(x),
	uintptr(y),
	uintptr(cx),
	uintptr(cy),
	uintptr(uFlags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function DrawStateW(
  hdc: THandle;   // HDC
  hbrFore: THandle;   // HBRUSH optional
  qfnCallBack: Pointer;   // DRAWSTATEPROC optional
  lData: NativeInt;   // LPARAM
  wData: NativeUInt;   // WPARAM
  x: Integer;   // INT
  y: Integer;   // INT
  cx: Integer;   // INT
  cy: Integer;   // INT
  uFlags: DWORD   // DRAWSTATE_FLAGS
): BOOL; stdcall;
  external 'USER32.dll' name 'DrawStateW';
result := DllCall("USER32\DrawStateW"
    , "Ptr", hdc   ; HDC
    , "Ptr", hbrFore   ; HBRUSH optional
    , "Ptr", qfnCallBack   ; DRAWSTATEPROC optional
    , "Ptr", lData   ; LPARAM
    , "UPtr", wData   ; WPARAM
    , "Int", x   ; INT
    , "Int", y   ; INT
    , "Int", cx   ; INT
    , "Int", cy   ; INT
    , "UInt", uFlags   ; DRAWSTATE_FLAGS
    , "Int")   ; return: BOOL
●DrawStateW(hdc, hbrFore, qfnCallBack, lData, wData, x, y, cx, cy, uFlags) = DLL("USER32.dll", "bool DrawStateW(void*, void*, void*, int, int, int, int, int, int, dword)")
# 呼び出し: DrawStateW(hdc, hbrFore, qfnCallBack, lData, wData, x, y, cx, cy, uFlags)
# hdc : HDC -> "void*"
# hbrFore : HBRUSH optional -> "void*"
# qfnCallBack : DRAWSTATEPROC optional -> "void*"
# lData : LPARAM -> "int"
# wData : WPARAM -> "int"
# x : INT -> "int"
# y : INT -> "int"
# cx : INT -> "int"
# cy : INT -> "int"
# uFlags : DRAWSTATE_FLAGS -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。