ホーム › UI.Controls › NMTBCUSTOMDRAW
NMTBCUSTOMDRAW
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| nmcd | NMCUSTOMDRAW | 80/48 | +0 | +0 | 基底となるカスタム描画情報を保持するNMCUSTOMDRAW構造体。 |
| hbrMonoDither | HBRUSH | 8/4 | +80 | +48 | モノクロディザリングに使うブラシのハンドル。 |
| hbrLines | HBRUSH | 8/4 | +88 | +52 | 区切り線描画に使うブラシのハンドル。 |
| hpenLines | HPEN | 8/4 | +96 | +56 | 区切り線描画に使うペンのハンドル。 |
| clrText | COLORREF | 4 | +104 | +60 | ボタンテキストの色。COLORREF形式。 |
| clrMark | COLORREF | 4 | +108 | +64 | 強調表示部分の色。COLORREF形式。 |
| clrTextHighlight | COLORREF | 4 | +112 | +68 | ハイライト時のテキスト色。COLORREF形式。 |
| clrBtnFace | COLORREF | 4 | +116 | +72 | ボタン面の色。COLORREF形式。 |
| clrBtnHighlight | COLORREF | 4 | +120 | +76 | ボタンのハイライト色。COLORREF形式。 |
| clrHighlightHotTrack | COLORREF | 4 | +124 | +80 | ホットトラック時のハイライト色。COLORREF形式。 |
| rcText | RECT | 16 | +128 | +84 | テキスト描画矩形を表すRECT。 |
| nStringBkMode | INT | 4 | +144 | +100 | 文字列の背景モード。OPAQUEまたはTRANSPARENT。 |
| nHLStringBkMode | INT | 4 | +148 | +104 | ハイライト文字列の背景モード。OPAQUEまたはTRANSPARENT。 |
| iListGap | INT | 4 | +152 | +108 | リストスタイルでの画像とテキストの間隔。 |
各言語での定義
#include <windows.h>
// NMHDR (x64 24 / x86 12 バイト)
typedef struct NMHDR {
HWND hwndFrom;
UINT_PTR idFrom;
DWORD code;
} NMHDR;
// RECT (x64 16 / x86 16 バイト)
typedef struct RECT {
INT left;
INT top;
INT right;
INT bottom;
} RECT;
// NMCUSTOMDRAW (x64 80 / x86 48 バイト)
typedef struct NMCUSTOMDRAW {
NMHDR hdr;
NMCUSTOMDRAW_DRAW_STAGE dwDrawStage;
HDC hdc;
RECT rc;
UINT_PTR dwItemSpec;
NMCUSTOMDRAW_DRAW_STATE_FLAGS uItemState;
LPARAM lItemlParam;
} NMCUSTOMDRAW;
// NMTBCUSTOMDRAW (x64 160 / x86 112 バイト)
typedef struct NMTBCUSTOMDRAW {
NMCUSTOMDRAW nmcd;
HBRUSH hbrMonoDither;
HBRUSH hbrLines;
HPEN hpenLines;
COLORREF clrText;
COLORREF clrMark;
COLORREF clrTextHighlight;
COLORREF clrBtnFace;
COLORREF clrBtnHighlight;
COLORREF clrHighlightHotTrack;
RECT rcText;
INT nStringBkMode;
INT nHLStringBkMode;
INT iListGap;
} NMTBCUSTOMDRAW;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NMHDR
{
public IntPtr hwndFrom;
public UIntPtr idFrom;
public uint code;
}
[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 NMCUSTOMDRAW
{
public NMHDR hdr;
public uint dwDrawStage;
public IntPtr hdc;
public RECT rc;
public UIntPtr dwItemSpec;
public uint uItemState;
public IntPtr lItemlParam;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NMTBCUSTOMDRAW
{
public NMCUSTOMDRAW nmcd;
public IntPtr hbrMonoDither;
public IntPtr hbrLines;
public IntPtr hpenLines;
public uint clrText;
public uint clrMark;
public uint clrTextHighlight;
public uint clrBtnFace;
public uint clrBtnHighlight;
public uint clrHighlightHotTrack;
public RECT rcText;
public int nStringBkMode;
public int nHLStringBkMode;
public int iListGap;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NMHDR
Public hwndFrom As IntPtr
Public idFrom As UIntPtr
Public code As UInteger
End Structure
<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 NMCUSTOMDRAW
Public hdr As NMHDR
Public dwDrawStage As UInteger
Public hdc As IntPtr
Public rc As RECT
Public dwItemSpec As UIntPtr
Public uItemState As UInteger
Public lItemlParam As IntPtr
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NMTBCUSTOMDRAW
Public nmcd As NMCUSTOMDRAW
Public hbrMonoDither As IntPtr
Public hbrLines As IntPtr
Public hpenLines As IntPtr
Public clrText As UInteger
Public clrMark As UInteger
Public clrTextHighlight As UInteger
Public clrBtnFace As UInteger
Public clrBtnHighlight As UInteger
Public clrHighlightHotTrack As UInteger
Public rcText As RECT
Public nStringBkMode As Integer
Public nHLStringBkMode As Integer
Public iListGap As Integer
End Structureimport ctypes
from ctypes import wintypes
class NMHDR(ctypes.Structure):
_fields_ = [
("hwndFrom", ctypes.c_void_p),
("idFrom", ctypes.c_size_t),
("code", wintypes.DWORD),
]
class RECT(ctypes.Structure):
_fields_ = [
("left", ctypes.c_int),
("top", ctypes.c_int),
("right", ctypes.c_int),
("bottom", ctypes.c_int),
]
class NMCUSTOMDRAW(ctypes.Structure):
_fields_ = [
("hdr", NMHDR),
("dwDrawStage", wintypes.DWORD),
("hdc", ctypes.c_void_p),
("rc", RECT),
("dwItemSpec", ctypes.c_size_t),
("uItemState", wintypes.DWORD),
("lItemlParam", ctypes.c_ssize_t),
]
class NMTBCUSTOMDRAW(ctypes.Structure):
_fields_ = [
("nmcd", NMCUSTOMDRAW),
("hbrMonoDither", ctypes.c_void_p),
("hbrLines", ctypes.c_void_p),
("hpenLines", ctypes.c_void_p),
("clrText", wintypes.DWORD),
("clrMark", wintypes.DWORD),
("clrTextHighlight", wintypes.DWORD),
("clrBtnFace", wintypes.DWORD),
("clrBtnHighlight", wintypes.DWORD),
("clrHighlightHotTrack", wintypes.DWORD),
("rcText", RECT),
("nStringBkMode", ctypes.c_int),
("nHLStringBkMode", ctypes.c_int),
("iListGap", ctypes.c_int),
]#[repr(C)]
pub struct NMHDR {
pub hwndFrom: *mut core::ffi::c_void,
pub idFrom: usize,
pub code: u32,
}
#[repr(C)]
pub struct RECT {
pub left: i32,
pub top: i32,
pub right: i32,
pub bottom: i32,
}
#[repr(C)]
pub struct NMCUSTOMDRAW {
pub hdr: NMHDR,
pub dwDrawStage: u32,
pub hdc: *mut core::ffi::c_void,
pub rc: RECT,
pub dwItemSpec: usize,
pub uItemState: u32,
pub lItemlParam: isize,
}
#[repr(C)]
pub struct NMTBCUSTOMDRAW {
pub nmcd: NMCUSTOMDRAW,
pub hbrMonoDither: *mut core::ffi::c_void,
pub hbrLines: *mut core::ffi::c_void,
pub hpenLines: *mut core::ffi::c_void,
pub clrText: u32,
pub clrMark: u32,
pub clrTextHighlight: u32,
pub clrBtnFace: u32,
pub clrBtnHighlight: u32,
pub clrHighlightHotTrack: u32,
pub rcText: RECT,
pub nStringBkMode: i32,
pub nHLStringBkMode: i32,
pub iListGap: i32,
}import "golang.org/x/sys/windows"
type NMHDR struct {
hwndFrom uintptr
idFrom uintptr
code uint32
}
type RECT struct {
left int32
top int32
right int32
bottom int32
}
type NMCUSTOMDRAW struct {
hdr NMHDR
dwDrawStage uint32
hdc uintptr
rc RECT
dwItemSpec uintptr
uItemState uint32
lItemlParam uintptr
}
type NMTBCUSTOMDRAW struct {
nmcd NMCUSTOMDRAW
hbrMonoDither uintptr
hbrLines uintptr
hpenLines uintptr
clrText uint32
clrMark uint32
clrTextHighlight uint32
clrBtnFace uint32
clrBtnHighlight uint32
clrHighlightHotTrack uint32
rcText RECT
nStringBkMode int32
nHLStringBkMode int32
iListGap int32
}type
NMHDR = record
hwndFrom: Pointer;
idFrom: NativeUInt;
code: DWORD;
end;
RECT = record
left: Integer;
top: Integer;
right: Integer;
bottom: Integer;
end;
NMCUSTOMDRAW = record
hdr: NMHDR;
dwDrawStage: DWORD;
hdc: Pointer;
rc: RECT;
dwItemSpec: NativeUInt;
uItemState: DWORD;
lItemlParam: NativeInt;
end;
NMTBCUSTOMDRAW = record
nmcd: NMCUSTOMDRAW;
hbrMonoDither: Pointer;
hbrLines: Pointer;
hpenLines: Pointer;
clrText: DWORD;
clrMark: DWORD;
clrTextHighlight: DWORD;
clrBtnFace: DWORD;
clrBtnHighlight: DWORD;
clrHighlightHotTrack: DWORD;
rcText: RECT;
nStringBkMode: Integer;
nHLStringBkMode: Integer;
iListGap: Integer;
end;const NMHDR = extern struct {
hwndFrom: ?*anyopaque,
idFrom: usize,
code: u32,
};
const RECT = extern struct {
left: i32,
top: i32,
right: i32,
bottom: i32,
};
const NMCUSTOMDRAW = extern struct {
hdr: NMHDR,
dwDrawStage: u32,
hdc: ?*anyopaque,
rc: RECT,
dwItemSpec: usize,
uItemState: u32,
lItemlParam: isize,
};
const NMTBCUSTOMDRAW = extern struct {
nmcd: NMCUSTOMDRAW,
hbrMonoDither: ?*anyopaque,
hbrLines: ?*anyopaque,
hpenLines: ?*anyopaque,
clrText: u32,
clrMark: u32,
clrTextHighlight: u32,
clrBtnFace: u32,
clrBtnHighlight: u32,
clrHighlightHotTrack: u32,
rcText: RECT,
nStringBkMode: i32,
nHLStringBkMode: i32,
iListGap: i32,
};type
NMHDR {.bycopy.} = object
hwndFrom: pointer
idFrom: uint
code: uint32
RECT {.bycopy.} = object
left: int32
top: int32
right: int32
bottom: int32
NMCUSTOMDRAW {.bycopy.} = object
hdr: NMHDR
dwDrawStage: uint32
hdc: pointer
rc: RECT
dwItemSpec: uint
uItemState: uint32
lItemlParam: int
NMTBCUSTOMDRAW {.bycopy.} = object
nmcd: NMCUSTOMDRAW
hbrMonoDither: pointer
hbrLines: pointer
hpenLines: pointer
clrText: uint32
clrMark: uint32
clrTextHighlight: uint32
clrBtnFace: uint32
clrBtnHighlight: uint32
clrHighlightHotTrack: uint32
rcText: RECT
nStringBkMode: int32
nHLStringBkMode: int32
iListGap: int32struct NMHDR
{
void* hwndFrom;
size_t idFrom;
uint code;
}
struct RECT
{
int left;
int top;
int right;
int bottom;
}
struct NMCUSTOMDRAW
{
NMHDR hdr;
uint dwDrawStage;
void* hdc;
RECT rc;
size_t dwItemSpec;
uint uItemState;
ptrdiff_t lItemlParam;
}
struct NMTBCUSTOMDRAW
{
NMCUSTOMDRAW nmcd;
void* hbrMonoDither;
void* hbrLines;
void* hpenLines;
uint clrText;
uint clrMark;
uint clrTextHighlight;
uint clrBtnFace;
uint clrBtnHighlight;
uint clrHighlightHotTrack;
RECT rcText;
int nStringBkMode;
int nHLStringBkMode;
int iListGap;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; NMTBCUSTOMDRAW サイズ: 112 バイト(x86)
dim st, 28 ; 4byte整数×28(構造体サイズ 112 / 4 切り上げ)
; nmcd : NMCUSTOMDRAW (+0, 48byte) varptr(st)+0 を基点に操作(48byte:入れ子/配列)
; hbrMonoDither : HBRUSH (+48, 4byte) st.12 = 値 / 値 = st.12 (lpoke/lpeek も可)
; hbrLines : HBRUSH (+52, 4byte) st.13 = 値 / 値 = st.13 (lpoke/lpeek も可)
; hpenLines : HPEN (+56, 4byte) st.14 = 値 / 値 = st.14 (lpoke/lpeek も可)
; clrText : COLORREF (+60, 4byte) st.15 = 値 / 値 = st.15 (lpoke/lpeek も可)
; clrMark : COLORREF (+64, 4byte) st.16 = 値 / 値 = st.16 (lpoke/lpeek も可)
; clrTextHighlight : COLORREF (+68, 4byte) st.17 = 値 / 値 = st.17 (lpoke/lpeek も可)
; clrBtnFace : COLORREF (+72, 4byte) st.18 = 値 / 値 = st.18 (lpoke/lpeek も可)
; clrBtnHighlight : COLORREF (+76, 4byte) st.19 = 値 / 値 = st.19 (lpoke/lpeek も可)
; clrHighlightHotTrack : COLORREF (+80, 4byte) st.20 = 値 / 値 = st.20 (lpoke/lpeek も可)
; rcText : RECT (+84, 16byte) varptr(st)+84 を基点に操作(16byte:入れ子/配列)
; nStringBkMode : INT (+100, 4byte) st.25 = 値 / 値 = st.25 (lpoke/lpeek も可)
; nHLStringBkMode : INT (+104, 4byte) st.26 = 値 / 値 = st.26 (lpoke/lpeek も可)
; iListGap : INT (+108, 4byte) st.27 = 値 / 値 = st.27 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NMTBCUSTOMDRAW サイズ: 160 バイト(x64)
dim st, 40 ; 4byte整数×40(構造体サイズ 160 / 4 切り上げ)
; nmcd : NMCUSTOMDRAW (+0, 80byte) varptr(st)+0 を基点に操作(80byte:入れ子/配列)
; hbrMonoDither : HBRUSH (+80, 8byte) qpoke st,80,値 / qpeek(st,80) ※IronHSPのみ。3.7/3.8は lpoke st,80,下位 : lpoke st,84,上位
; hbrLines : HBRUSH (+88, 8byte) qpoke st,88,値 / qpeek(st,88) ※IronHSPのみ。3.7/3.8は lpoke st,88,下位 : lpoke st,92,上位
; hpenLines : HPEN (+96, 8byte) qpoke st,96,値 / qpeek(st,96) ※IronHSPのみ。3.7/3.8は lpoke st,96,下位 : lpoke st,100,上位
; clrText : COLORREF (+104, 4byte) st.26 = 値 / 値 = st.26 (lpoke/lpeek も可)
; clrMark : COLORREF (+108, 4byte) st.27 = 値 / 値 = st.27 (lpoke/lpeek も可)
; clrTextHighlight : COLORREF (+112, 4byte) st.28 = 値 / 値 = st.28 (lpoke/lpeek も可)
; clrBtnFace : COLORREF (+116, 4byte) st.29 = 値 / 値 = st.29 (lpoke/lpeek も可)
; clrBtnHighlight : COLORREF (+120, 4byte) st.30 = 値 / 値 = st.30 (lpoke/lpeek も可)
; clrHighlightHotTrack : COLORREF (+124, 4byte) st.31 = 値 / 値 = st.31 (lpoke/lpeek も可)
; rcText : RECT (+128, 16byte) varptr(st)+128 を基点に操作(16byte:入れ子/配列)
; nStringBkMode : INT (+144, 4byte) st.36 = 値 / 値 = st.36 (lpoke/lpeek も可)
; nHLStringBkMode : INT (+148, 4byte) st.37 = 値 / 値 = st.37 (lpoke/lpeek も可)
; iListGap : INT (+152, 4byte) st.38 = 値 / 値 = st.38 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global NMHDR
#field intptr hwndFrom
#field intptr idFrom
#field int code
#endstruct
#defstruct global RECT
#field int left
#field int top
#field int right
#field int bottom
#endstruct
#defstruct global NMCUSTOMDRAW
#field NMHDR hdr
#field int dwDrawStage
#field intptr hdc
#field RECT rc
#field intptr dwItemSpec
#field int uItemState
#field intptr lItemlParam
#endstruct
#defstruct global NMTBCUSTOMDRAW
#field NMCUSTOMDRAW nmcd
#field intptr hbrMonoDither
#field intptr hbrLines
#field intptr hpenLines
#field int clrText
#field int clrMark
#field int clrTextHighlight
#field int clrBtnFace
#field int clrBtnHighlight
#field int clrHighlightHotTrack
#field RECT rcText
#field int nStringBkMode
#field int nHLStringBkMode
#field int iListGap
#endstruct
stdim st, NMTBCUSTOMDRAW ; NSTRUCT 変数を確保
st->clrText = 100
mes "clrText=" + st->clrText