Win32 API 日本語リファレンス
ホームUI.Shell › NSTCCUSTOMDRAW

NSTCCUSTOMDRAW

構造体
サイズx64: 48 バイト / x86: 32 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
psiIShellItem*8/4+0+0描画対象のシェル項目(IShellItem)。
uItemStateDWORD4+8+4項目の状態フラグ(選択・ホット等)。
nstcisDWORD4+12+8ナビゲーションツリー項目の状態(NSTCITEMSTATE)。
pszTextLPWSTR8/4+16+12項目の表示テキスト(Unicode)。
iImageINT4+24+16項目アイコンのイメージインデックス。
himlHIMAGELIST8/4+32+20アイコンを含むイメージリストのハンドル。
iLevelINT4+40+24ツリー内での階層レベル。
iIndentINT4+44+28項目のインデント量。

各言語での定義

#include <windows.h>

// NSTCCUSTOMDRAW  (x64 48 / x86 32 バイト)
typedef struct NSTCCUSTOMDRAW {
    IShellItem* psi;
    DWORD uItemState;
    DWORD nstcis;
    LPWSTR pszText;
    INT iImage;
    HIMAGELIST himl;
    INT iLevel;
    INT iIndent;
} NSTCCUSTOMDRAW;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NSTCCUSTOMDRAW
{
    public IntPtr psi;
    public uint uItemState;
    public uint nstcis;
    public IntPtr pszText;
    public int iImage;
    public IntPtr himl;
    public int iLevel;
    public int iIndent;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NSTCCUSTOMDRAW
    Public psi As IntPtr
    Public uItemState As UInteger
    Public nstcis As UInteger
    Public pszText As IntPtr
    Public iImage As Integer
    Public himl As IntPtr
    Public iLevel As Integer
    Public iIndent As Integer
End Structure
import ctypes
from ctypes import wintypes

class NSTCCUSTOMDRAW(ctypes.Structure):
    _fields_ = [
        ("psi", ctypes.c_void_p),
        ("uItemState", wintypes.DWORD),
        ("nstcis", wintypes.DWORD),
        ("pszText", ctypes.c_void_p),
        ("iImage", ctypes.c_int),
        ("himl", ctypes.c_ssize_t),
        ("iLevel", ctypes.c_int),
        ("iIndent", ctypes.c_int),
    ]
#[repr(C)]
pub struct NSTCCUSTOMDRAW {
    pub psi: *mut core::ffi::c_void,
    pub uItemState: u32,
    pub nstcis: u32,
    pub pszText: *mut core::ffi::c_void,
    pub iImage: i32,
    pub himl: isize,
    pub iLevel: i32,
    pub iIndent: i32,
}
import "golang.org/x/sys/windows"

type NSTCCUSTOMDRAW struct {
	psi uintptr
	uItemState uint32
	nstcis uint32
	pszText uintptr
	iImage int32
	himl uintptr
	iLevel int32
	iIndent int32
}
type
  NSTCCUSTOMDRAW = record
    psi: Pointer;
    uItemState: DWORD;
    nstcis: DWORD;
    pszText: Pointer;
    iImage: Integer;
    himl: NativeInt;
    iLevel: Integer;
    iIndent: Integer;
  end;
const NSTCCUSTOMDRAW = extern struct {
    psi: ?*anyopaque,
    uItemState: u32,
    nstcis: u32,
    pszText: ?*anyopaque,
    iImage: i32,
    himl: isize,
    iLevel: i32,
    iIndent: i32,
};
type
  NSTCCUSTOMDRAW {.bycopy.} = object
    psi: pointer
    uItemState: uint32
    nstcis: uint32
    pszText: pointer
    iImage: int32
    himl: int
    iLevel: int32
    iIndent: int32
struct NSTCCUSTOMDRAW
{
    void* psi;
    uint uItemState;
    uint nstcis;
    void* pszText;
    int iImage;
    ptrdiff_t himl;
    int iLevel;
    int iIndent;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; NSTCCUSTOMDRAW サイズ: 32 バイト(x86)
dim st, 8    ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; psi : IShellItem* (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; uItemState : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; nstcis : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; pszText : LPWSTR (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; iImage : INT (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; himl : HIMAGELIST (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; iLevel : INT (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; iIndent : INT (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NSTCCUSTOMDRAW サイズ: 48 バイト(x64)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; psi : IShellItem* (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; uItemState : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; nstcis : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; pszText : LPWSTR (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; iImage : INT (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; himl : HIMAGELIST (+32, 8byte)  qpoke st,32,値 / qpeek(st,32)  ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; iLevel : INT (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; iIndent : INT (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global NSTCCUSTOMDRAW
    #field intptr psi
    #field int uItemState
    #field int nstcis
    #field intptr pszText
    #field int iImage
    #field intptr himl
    #field int iLevel
    #field int iIndent
#endstruct

stdim st, NSTCCUSTOMDRAW        ; NSTRUCT 変数を確保
st->uItemState = 100
mes "uItemState=" + st->uItemState