ホーム › Graphics.Gdi › DrawStateA
DrawStateA
関数状態フラグに応じて淡色化等の効果を付けて画像や文字列を描画する(ANSI版)。
シグネチャ
// USER32.dll (ANSI / -A)
#include <windows.h>
BOOL DrawStateA(
HDC hdc,
HBRUSH hbrFore, // optional
DRAWSTATEPROC qfnCallBack, // optional
LPARAM lData,
WPARAM wData,
INT x,
INT y,
INT cx,
INT cy,
DRAWSTATE_FLAGS uFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hdc | HDC | in |
| hbrFore | HBRUSH | inoptional |
| qfnCallBack | DRAWSTATEPROC | inoptional |
| lData | LPARAM | in |
| wData | WPARAM | in |
| x | INT | in |
| y | INT | in |
| cx | INT | in |
| cy | INT | in |
| uFlags | DRAWSTATE_FLAGS | in |
戻り値の型: BOOL
各言語での呼び出し定義
// USER32.dll (ANSI / -A)
#include <windows.h>
BOOL DrawStateA(
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.Ansi, ExactSpelling = true)]
static extern bool DrawStateA(
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.Ansi, ExactSpelling:=True)>
Public Shared Function DrawStateA(
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 DrawStateA 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
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DrawStateA = ctypes.windll.user32.DrawStateA
DrawStateA.restype = wintypes.BOOL
DrawStateA.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')
DrawStateA = Fiddle::Function.new(
lib['DrawStateA'],
[
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)#[link(name = "user32")]
extern "system" {
fn DrawStateA(
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.Ansi)]
public static extern bool DrawStateA(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_DrawStateA' -Namespace Win32 -PassThru
# $api::DrawStateA(hdc, hbrFore, qfnCallBack, lData, wData, x, y, cx, cy, uFlags)#uselib "USER32.dll"
#func global DrawStateA "DrawStateA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; DrawStateA hdc, hbrFore, qfnCallBack, lData, wData, x, y, cx, cy, uFlags ; 戻り値は stat
; hdc : HDC -> "sptr"
; hbrFore : HBRUSH optional -> "sptr"
; qfnCallBack : DRAWSTATEPROC optional -> "sptr"
; lData : LPARAM -> "sptr"
; wData : WPARAM -> "sptr"
; x : INT -> "sptr"
; y : INT -> "sptr"
; cx : INT -> "sptr"
; cy : INT -> "sptr"
; uFlags : DRAWSTATE_FLAGS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll"
#cfunc global DrawStateA "DrawStateA" sptr, sptr, sptr, sptr, sptr, int, int, int, int, int
; res = DrawStateA(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 DrawStateA(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 DrawStateA "DrawStateA" intptr, intptr, intptr, intptr, intptr, int, int, int, int, int
; res = DrawStateA(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")
procDrawStateA = user32.NewProc("DrawStateA")
)
// 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 := procDrawStateA.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 // BOOLfunction DrawStateA(
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 'DrawStateA';result := DllCall("USER32\DrawStateA"
, "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●DrawStateA(hdc, hbrFore, qfnCallBack, lData, wData, x, y, cx, cy, uFlags) = DLL("USER32.dll", "bool DrawStateA(void*, void*, void*, int, int, int, int, int, int, dword)")
# 呼び出し: DrawStateA(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)。