ホーム › UI.Controls › DRAWITEMSTRUCT
DRAWITEMSTRUCT
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| CtlType | DRAWITEMSTRUCT_CTL_TYPE | 4 | +0 | +0 | コントロールの種類(DRAWITEMSTRUCT_CTL_TYPE、ODT_*)。 |
| CtlID | DWORD | 4 | +4 | +4 | コントロールの識別子。 |
| itemID | DWORD | 4 | +8 | +8 | 描画対象項目のインデックス。空の場合は-1。 |
| itemAction | ODA_FLAGS | 4 | +12 | +12 | 必要な描画動作(ODA_FLAGS、ODA_DRAWENTIRE等)。 |
| itemState | ODS_FLAGS | 4 | +16 | +16 | 項目の表示状態(ODS_FLAGS、選択・無効・フォーカスなど)。 |
| hwndItem | HWND | 8/4 | +24 | +20 | オーナードローコントロールのウィンドウハンドル。 |
| hDC | HDC | 8/4 | +32 | +24 | 描画に使用するデバイスコンテキストのハンドル。 |
| rcItem | RECT | 16 | +40 | +28 | 描画する項目の境界矩形(RECT)。 |
| itemData | UINT_PTR | 8/4 | +56 | +44 | 項目に関連付けられたアプリケーション定義値。 |
各言語での定義
#include <windows.h>
// RECT (x64 16 / x86 16 バイト)
typedef struct RECT {
INT left;
INT top;
INT right;
INT bottom;
} RECT;
// DRAWITEMSTRUCT (x64 64 / x86 48 バイト)
typedef struct DRAWITEMSTRUCT {
DRAWITEMSTRUCT_CTL_TYPE CtlType;
DWORD CtlID;
DWORD itemID;
ODA_FLAGS itemAction;
ODS_FLAGS itemState;
HWND hwndItem;
HDC hDC;
RECT rcItem;
UINT_PTR itemData;
} DRAWITEMSTRUCT;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DRAWITEMSTRUCT
{
public uint CtlType;
public uint CtlID;
public uint itemID;
public uint itemAction;
public uint itemState;
public IntPtr hwndItem;
public IntPtr hDC;
public RECT rcItem;
public UIntPtr itemData;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure RECT
Public left As Integer
Public top As Integer
Public right As Integer
Public bottom As Integer
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DRAWITEMSTRUCT
Public CtlType As UInteger
Public CtlID As UInteger
Public itemID As UInteger
Public itemAction As UInteger
Public itemState As UInteger
Public hwndItem As IntPtr
Public hDC As IntPtr
Public rcItem As RECT
Public itemData As UIntPtr
End Structureimport ctypes
from ctypes import wintypes
class RECT(ctypes.Structure):
_fields_ = [
("left", ctypes.c_int),
("top", ctypes.c_int),
("right", ctypes.c_int),
("bottom", ctypes.c_int),
]
class DRAWITEMSTRUCT(ctypes.Structure):
_fields_ = [
("CtlType", wintypes.DWORD),
("CtlID", wintypes.DWORD),
("itemID", wintypes.DWORD),
("itemAction", wintypes.DWORD),
("itemState", wintypes.DWORD),
("hwndItem", ctypes.c_void_p),
("hDC", ctypes.c_void_p),
("rcItem", RECT),
("itemData", ctypes.c_size_t),
]#[repr(C)]
pub struct RECT {
pub left: i32,
pub top: i32,
pub right: i32,
pub bottom: i32,
}
#[repr(C)]
pub struct DRAWITEMSTRUCT {
pub CtlType: u32,
pub CtlID: u32,
pub itemID: u32,
pub itemAction: u32,
pub itemState: u32,
pub hwndItem: *mut core::ffi::c_void,
pub hDC: *mut core::ffi::c_void,
pub rcItem: RECT,
pub itemData: usize,
}import "golang.org/x/sys/windows"
type RECT struct {
left int32
top int32
right int32
bottom int32
}
type DRAWITEMSTRUCT struct {
CtlType uint32
CtlID uint32
itemID uint32
itemAction uint32
itemState uint32
hwndItem uintptr
hDC uintptr
rcItem RECT
itemData uintptr
}type
RECT = record
left: Integer;
top: Integer;
right: Integer;
bottom: Integer;
end;
DRAWITEMSTRUCT = record
CtlType: DWORD;
CtlID: DWORD;
itemID: DWORD;
itemAction: DWORD;
itemState: DWORD;
hwndItem: Pointer;
hDC: Pointer;
rcItem: RECT;
itemData: NativeUInt;
end;const RECT = extern struct {
left: i32,
top: i32,
right: i32,
bottom: i32,
};
const DRAWITEMSTRUCT = extern struct {
CtlType: u32,
CtlID: u32,
itemID: u32,
itemAction: u32,
itemState: u32,
hwndItem: ?*anyopaque,
hDC: ?*anyopaque,
rcItem: RECT,
itemData: usize,
};type
RECT {.bycopy.} = object
left: int32
top: int32
right: int32
bottom: int32
DRAWITEMSTRUCT {.bycopy.} = object
CtlType: uint32
CtlID: uint32
itemID: uint32
itemAction: uint32
itemState: uint32
hwndItem: pointer
hDC: pointer
rcItem: RECT
itemData: uintstruct RECT
{
int left;
int top;
int right;
int bottom;
}
struct DRAWITEMSTRUCT
{
uint CtlType;
uint CtlID;
uint itemID;
uint itemAction;
uint itemState;
void* hwndItem;
void* hDC;
RECT rcItem;
size_t itemData;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; DRAWITEMSTRUCT サイズ: 48 バイト(x86)
dim st, 12 ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; CtlType : DRAWITEMSTRUCT_CTL_TYPE (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; CtlID : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; itemID : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; itemAction : ODA_FLAGS (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; itemState : ODS_FLAGS (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; hwndItem : HWND (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; hDC : HDC (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; rcItem : RECT (+28, 16byte) varptr(st)+28 を基点に操作(16byte:入れ子/配列)
; itemData : UINT_PTR (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DRAWITEMSTRUCT サイズ: 64 バイト(x64)
dim st, 16 ; 4byte整数×16(構造体サイズ 64 / 4 切り上げ)
; CtlType : DRAWITEMSTRUCT_CTL_TYPE (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; CtlID : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; itemID : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; itemAction : ODA_FLAGS (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; itemState : ODS_FLAGS (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; hwndItem : HWND (+24, 8byte) qpoke st,24,値 / qpeek(st,24) ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; hDC : HDC (+32, 8byte) qpoke st,32,値 / qpeek(st,32) ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; rcItem : RECT (+40, 16byte) varptr(st)+40 を基点に操作(16byte:入れ子/配列)
; itemData : UINT_PTR (+56, 8byte) qpoke st,56,値 / qpeek(st,56) ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global RECT
#field int left
#field int top
#field int right
#field int bottom
#endstruct
#defstruct global DRAWITEMSTRUCT
#field int CtlType
#field int CtlID
#field int itemID
#field int itemAction
#field int itemState
#field intptr hwndItem
#field intptr hDC
#field RECT rcItem
#field intptr itemData
#endstruct
stdim st, DRAWITEMSTRUCT ; NSTRUCT 変数を確保
st->CtlType = 100
mes "CtlType=" + st->CtlType