ホーム › UI.Controls › NMTREEVIEWW
NMTREEVIEWW
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| hdr | NMHDR | 24/12 | +0 | +0 | 通知メッセージ共通ヘッダー。送信元情報と通知コードを保持する。 |
| action | NM_TREEVIEW_ACTION | 4 | +24 | +12 | 通知の原因となった操作の種類(NM_TREEVIEW_ACTION)。 |
| itemOld | TVITEMW | 56/40 | +32 | +16 | 操作前または旧の項目情報(Unicode版TVITEMW)。 |
| itemNew | TVITEMW | 56/40 | +88 | +56 | 操作後または新の項目情報(Unicode版TVITEMW)。 |
| ptDrag | POINT | 8 | +144 | +96 | ドラッグ開始時のクライアント座標(POINT)。 |
各言語での定義
#include <windows.h>
// NMHDR (x64 24 / x86 12 バイト)
typedef struct NMHDR {
HWND hwndFrom;
UINT_PTR idFrom;
DWORD code;
} NMHDR;
// TVITEMW (x64 56 / x86 40 バイト)
typedef struct TVITEMW {
TVITEM_MASK mask;
HTREEITEM hItem;
TREE_VIEW_ITEM_STATE_FLAGS state;
TREE_VIEW_ITEM_STATE_FLAGS stateMask;
LPWSTR pszText;
INT cchTextMax;
INT iImage;
INT iSelectedImage;
TVITEMEXW_CHILDREN cChildren;
LPARAM lParam;
} TVITEMW;
// POINT (x64 8 / x86 8 バイト)
typedef struct POINT {
INT x;
INT y;
} POINT;
// NMTREEVIEWW (x64 152 / x86 104 バイト)
typedef struct NMTREEVIEWW {
NMHDR hdr;
NM_TREEVIEW_ACTION action;
TVITEMW itemOld;
TVITEMW itemNew;
POINT ptDrag;
} NMTREEVIEWW;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 TVITEMW
{
public uint mask;
public IntPtr hItem;
public uint state;
public uint stateMask;
public IntPtr pszText;
public int cchTextMax;
public int iImage;
public int iSelectedImage;
public int cChildren;
public IntPtr lParam;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct POINT
{
public int x;
public int y;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NMTREEVIEWW
{
public NMHDR hdr;
public uint action;
public TVITEMW itemOld;
public TVITEMW itemNew;
public POINT ptDrag;
}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 TVITEMW
Public mask As UInteger
Public hItem As IntPtr
Public state As UInteger
Public stateMask As UInteger
Public pszText As IntPtr
Public cchTextMax As Integer
Public iImage As Integer
Public iSelectedImage As Integer
Public cChildren As Integer
Public lParam As IntPtr
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure POINT
Public x As Integer
Public y As Integer
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NMTREEVIEWW
Public hdr As NMHDR
Public action As UInteger
Public itemOld As TVITEMW
Public itemNew As TVITEMW
Public ptDrag As POINT
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 TVITEMW(ctypes.Structure):
_fields_ = [
("mask", wintypes.DWORD),
("hItem", ctypes.c_ssize_t),
("state", wintypes.DWORD),
("stateMask", wintypes.DWORD),
("pszText", ctypes.c_void_p),
("cchTextMax", ctypes.c_int),
("iImage", ctypes.c_int),
("iSelectedImage", ctypes.c_int),
("cChildren", ctypes.c_int),
("lParam", ctypes.c_ssize_t),
]
class POINT(ctypes.Structure):
_fields_ = [
("x", ctypes.c_int),
("y", ctypes.c_int),
]
class NMTREEVIEWW(ctypes.Structure):
_fields_ = [
("hdr", NMHDR),
("action", wintypes.DWORD),
("itemOld", TVITEMW),
("itemNew", TVITEMW),
("ptDrag", POINT),
]#[repr(C)]
pub struct NMHDR {
pub hwndFrom: *mut core::ffi::c_void,
pub idFrom: usize,
pub code: u32,
}
#[repr(C)]
pub struct TVITEMW {
pub mask: u32,
pub hItem: isize,
pub state: u32,
pub stateMask: u32,
pub pszText: *mut core::ffi::c_void,
pub cchTextMax: i32,
pub iImage: i32,
pub iSelectedImage: i32,
pub cChildren: i32,
pub lParam: isize,
}
#[repr(C)]
pub struct POINT {
pub x: i32,
pub y: i32,
}
#[repr(C)]
pub struct NMTREEVIEWW {
pub hdr: NMHDR,
pub action: u32,
pub itemOld: TVITEMW,
pub itemNew: TVITEMW,
pub ptDrag: POINT,
}import "golang.org/x/sys/windows"
type NMHDR struct {
hwndFrom uintptr
idFrom uintptr
code uint32
}
type TVITEMW struct {
mask uint32
hItem uintptr
state uint32
stateMask uint32
pszText uintptr
cchTextMax int32
iImage int32
iSelectedImage int32
cChildren int32
lParam uintptr
}
type POINT struct {
x int32
y int32
}
type NMTREEVIEWW struct {
hdr NMHDR
action uint32
itemOld TVITEMW
itemNew TVITEMW
ptDrag POINT
}type
NMHDR = record
hwndFrom: Pointer;
idFrom: NativeUInt;
code: DWORD;
end;
TVITEMW = record
mask: DWORD;
hItem: NativeInt;
state: DWORD;
stateMask: DWORD;
pszText: Pointer;
cchTextMax: Integer;
iImage: Integer;
iSelectedImage: Integer;
cChildren: Integer;
lParam: NativeInt;
end;
POINT = record
x: Integer;
y: Integer;
end;
NMTREEVIEWW = record
hdr: NMHDR;
action: DWORD;
itemOld: TVITEMW;
itemNew: TVITEMW;
ptDrag: POINT;
end;const NMHDR = extern struct {
hwndFrom: ?*anyopaque,
idFrom: usize,
code: u32,
};
const TVITEMW = extern struct {
mask: u32,
hItem: isize,
state: u32,
stateMask: u32,
pszText: ?*anyopaque,
cchTextMax: i32,
iImage: i32,
iSelectedImage: i32,
cChildren: i32,
lParam: isize,
};
const POINT = extern struct {
x: i32,
y: i32,
};
const NMTREEVIEWW = extern struct {
hdr: NMHDR,
action: u32,
itemOld: TVITEMW,
itemNew: TVITEMW,
ptDrag: POINT,
};type
NMHDR {.bycopy.} = object
hwndFrom: pointer
idFrom: uint
code: uint32
TVITEMW {.bycopy.} = object
mask: uint32
hItem: int
state: uint32
stateMask: uint32
pszText: pointer
cchTextMax: int32
iImage: int32
iSelectedImage: int32
cChildren: int32
lParam: int
POINT {.bycopy.} = object
x: int32
y: int32
NMTREEVIEWW {.bycopy.} = object
hdr: NMHDR
action: uint32
itemOld: TVITEMW
itemNew: TVITEMW
ptDrag: POINTstruct NMHDR
{
void* hwndFrom;
size_t idFrom;
uint code;
}
struct TVITEMW
{
uint mask;
ptrdiff_t hItem;
uint state;
uint stateMask;
void* pszText;
int cchTextMax;
int iImage;
int iSelectedImage;
int cChildren;
ptrdiff_t lParam;
}
struct POINT
{
int x;
int y;
}
struct NMTREEVIEWW
{
NMHDR hdr;
uint action;
TVITEMW itemOld;
TVITEMW itemNew;
POINT ptDrag;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; NMTREEVIEWW サイズ: 104 バイト(x86)
dim st, 26 ; 4byte整数×26(構造体サイズ 104 / 4 切り上げ)
; hdr : NMHDR (+0, 12byte) varptr(st)+0 を基点に操作(12byte:入れ子/配列)
; action : NM_TREEVIEW_ACTION (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; itemOld : TVITEMW (+16, 40byte) varptr(st)+16 を基点に操作(40byte:入れ子/配列)
; itemNew : TVITEMW (+56, 40byte) varptr(st)+56 を基点に操作(40byte:入れ子/配列)
; ptDrag : POINT (+96, 8byte) varptr(st)+96 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NMTREEVIEWW サイズ: 152 バイト(x64)
dim st, 38 ; 4byte整数×38(構造体サイズ 152 / 4 切り上げ)
; hdr : NMHDR (+0, 24byte) varptr(st)+0 を基点に操作(24byte:入れ子/配列)
; action : NM_TREEVIEW_ACTION (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; itemOld : TVITEMW (+32, 56byte) varptr(st)+32 を基点に操作(56byte:入れ子/配列)
; itemNew : TVITEMW (+88, 56byte) varptr(st)+88 を基点に操作(56byte:入れ子/配列)
; ptDrag : POINT (+144, 8byte) varptr(st)+144 を基点に操作(8byte:入れ子/配列)
; ※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 TVITEMW
#field int mask
#field intptr hItem
#field int state
#field int stateMask
#field intptr pszText
#field int cchTextMax
#field int iImage
#field int iSelectedImage
#field int cChildren
#field intptr lParam
#endstruct
#defstruct global POINT
#field int x
#field int y
#endstruct
#defstruct global NMTREEVIEWW
#field NMHDR hdr
#field int action
#field TVITEMW itemOld
#field TVITEMW itemNew
#field POINT ptDrag
#endstruct
stdim st, NMTREEVIEWW ; NSTRUCT 変数を確保
st->action = 100
mes "action=" + st->action