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

NMLVDISPINFOW

構造体
サイズx64: 112 バイト / x86: 72 バイト

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

フィールド

フィールドサイズx64x86説明
hdrNMHDR24/12+0+0この通知コードに関する情報を格納する NMHDR 構造体です。
itemLVITEMW88/60+24+12項目またはサブ項目を識別する LVITEM 構造体です。この構造体は、項目に関する情報を格納するか、または受け取ります。mask メンバーには、どの項目属性が有効であるかを指定するビットフラグのセットが格納されます。 利用可能なビットフラグの詳細については、LVITEM を参照してください。

公式ドキュメント

LVN_GETDISPINFO または LVN_SETDISPINFO 通知コードに関する情報を格納します。この構造体は LV_DISPINFO 構造体と同一ですが、標準の命名規則に合わせて名前が変更されています。

解説(Remarks)

LVITEM 構造体が項目のテキストを受け取る場合、pszText メンバーと cchTextMax メンバーはバッファーのアドレスとサイズを指定します。バッファーにテキストをコピーすることも、文字列のアドレスを pszText メンバーに代入することもできます。後者の場合、対応する項目のテキストが削除されるか、さらに 2 つの LVN_GETDISPINFO メッセージが送信されるまで、その文字列を変更したり削除したりしてはなりません。

LVN_GETDISPINFO メッセージを処理する場合、LVITEM 構造体の mask メンバーに LVIF_DI_SETITEM フラグを設定できます。これにより、要求されたリスト項目の情報を保存し、再度要求しないようにオペレーティングシステムに指示します。LVS_REPORT スタイルを持つリストビューコントロールの場合、このフラグは最初の列 (サブ項目 0) の情報にのみ適用されます。コントロールはサブ項目の情報を保存しません。

メモ

commctrl.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして NMLVDISPINFO を定義しています。エンコーディング中立のエイリアスと、エンコーディング中立ではないコードを混在させて使用すると、不一致が生じてコンパイルエラーや実行時エラーの原因となる場合があります。詳細については、関数プロトタイプの規則 を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での定義

#include <windows.h>

// NMHDR  (x64 24 / x86 12 バイト)
typedef struct NMHDR {
    HWND hwndFrom;
    UINT_PTR idFrom;
    DWORD code;
} NMHDR;

// LVITEMW  (x64 88 / x86 60 バイト)
typedef struct LVITEMW {
    LIST_VIEW_ITEM_FLAGS mask;
    INT iItem;
    INT iSubItem;
    LIST_VIEW_ITEM_STATE_FLAGS state;
    LIST_VIEW_ITEM_STATE_FLAGS stateMask;
    LPWSTR pszText;
    INT cchTextMax;
    INT iImage;
    LPARAM lParam;
    INT iIndent;
    INT iGroupId;
    DWORD cColumns;
    DWORD* puColumns;
    LIST_VIEW_ITEM_COLUMN_FORMAT_FLAGS* piColFmt;
    INT iGroup;
} LVITEMW;

// NMLVDISPINFOW  (x64 112 / x86 72 バイト)
typedef struct NMLVDISPINFOW {
    NMHDR hdr;
    LVITEMW item;
} NMLVDISPINFOW;
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 LVITEMW
{
    public uint mask;
    public int iItem;
    public int iSubItem;
    public uint state;
    public uint stateMask;
    public IntPtr pszText;
    public int cchTextMax;
    public int iImage;
    public IntPtr lParam;
    public int iIndent;
    public int iGroupId;
    public uint cColumns;
    public IntPtr puColumns;
    public IntPtr piColFmt;
    public int iGroup;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NMLVDISPINFOW
{
    public NMHDR hdr;
    public LVITEMW item;
}
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 LVITEMW
    Public mask As UInteger
    Public iItem As Integer
    Public iSubItem As Integer
    Public state As UInteger
    Public stateMask As UInteger
    Public pszText As IntPtr
    Public cchTextMax As Integer
    Public iImage As Integer
    Public lParam As IntPtr
    Public iIndent As Integer
    Public iGroupId As Integer
    Public cColumns As UInteger
    Public puColumns As IntPtr
    Public piColFmt As IntPtr
    Public iGroup As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NMLVDISPINFOW
    Public hdr As NMHDR
    Public item As LVITEMW
End Structure
import ctypes
from ctypes import wintypes

class NMHDR(ctypes.Structure):
    _fields_ = [
        ("hwndFrom", ctypes.c_void_p),
        ("idFrom", ctypes.c_size_t),
        ("code", wintypes.DWORD),
    ]

class LVITEMW(ctypes.Structure):
    _fields_ = [
        ("mask", wintypes.DWORD),
        ("iItem", ctypes.c_int),
        ("iSubItem", ctypes.c_int),
        ("state", wintypes.DWORD),
        ("stateMask", wintypes.DWORD),
        ("pszText", ctypes.c_void_p),
        ("cchTextMax", ctypes.c_int),
        ("iImage", ctypes.c_int),
        ("lParam", ctypes.c_ssize_t),
        ("iIndent", ctypes.c_int),
        ("iGroupId", ctypes.c_int),
        ("cColumns", wintypes.DWORD),
        ("puColumns", ctypes.c_void_p),
        ("piColFmt", ctypes.c_void_p),
        ("iGroup", ctypes.c_int),
    ]

class NMLVDISPINFOW(ctypes.Structure):
    _fields_ = [
        ("hdr", NMHDR),
        ("item", LVITEMW),
    ]
#[repr(C)]
pub struct NMHDR {
    pub hwndFrom: *mut core::ffi::c_void,
    pub idFrom: usize,
    pub code: u32,
}

#[repr(C)]
pub struct LVITEMW {
    pub mask: u32,
    pub iItem: i32,
    pub iSubItem: i32,
    pub state: u32,
    pub stateMask: u32,
    pub pszText: *mut core::ffi::c_void,
    pub cchTextMax: i32,
    pub iImage: i32,
    pub lParam: isize,
    pub iIndent: i32,
    pub iGroupId: i32,
    pub cColumns: u32,
    pub puColumns: *mut core::ffi::c_void,
    pub piColFmt: *mut core::ffi::c_void,
    pub iGroup: i32,
}

#[repr(C)]
pub struct NMLVDISPINFOW {
    pub hdr: NMHDR,
    pub item: LVITEMW,
}
import "golang.org/x/sys/windows"

type NMHDR struct {
	hwndFrom uintptr
	idFrom uintptr
	code uint32
}

type LVITEMW struct {
	mask uint32
	iItem int32
	iSubItem int32
	state uint32
	stateMask uint32
	pszText uintptr
	cchTextMax int32
	iImage int32
	lParam uintptr
	iIndent int32
	iGroupId int32
	cColumns uint32
	puColumns uintptr
	piColFmt uintptr
	iGroup int32
}

type NMLVDISPINFOW struct {
	hdr NMHDR
	item LVITEMW
}
type
  NMHDR = record
    hwndFrom: Pointer;
    idFrom: NativeUInt;
    code: DWORD;
  end;

  LVITEMW = record
    mask: DWORD;
    iItem: Integer;
    iSubItem: Integer;
    state: DWORD;
    stateMask: DWORD;
    pszText: Pointer;
    cchTextMax: Integer;
    iImage: Integer;
    lParam: NativeInt;
    iIndent: Integer;
    iGroupId: Integer;
    cColumns: DWORD;
    puColumns: Pointer;
    piColFmt: Pointer;
    iGroup: Integer;
  end;

  NMLVDISPINFOW = record
    hdr: NMHDR;
    item: LVITEMW;
  end;
const NMHDR = extern struct {
    hwndFrom: ?*anyopaque,
    idFrom: usize,
    code: u32,
};

const LVITEMW = extern struct {
    mask: u32,
    iItem: i32,
    iSubItem: i32,
    state: u32,
    stateMask: u32,
    pszText: ?*anyopaque,
    cchTextMax: i32,
    iImage: i32,
    lParam: isize,
    iIndent: i32,
    iGroupId: i32,
    cColumns: u32,
    puColumns: ?*anyopaque,
    piColFmt: ?*anyopaque,
    iGroup: i32,
};

const NMLVDISPINFOW = extern struct {
    hdr: NMHDR,
    item: LVITEMW,
};
type
  NMHDR {.bycopy.} = object
    hwndFrom: pointer
    idFrom: uint
    code: uint32

  LVITEMW {.bycopy.} = object
    mask: uint32
    iItem: int32
    iSubItem: int32
    state: uint32
    stateMask: uint32
    pszText: pointer
    cchTextMax: int32
    iImage: int32
    lParam: int
    iIndent: int32
    iGroupId: int32
    cColumns: uint32
    puColumns: pointer
    piColFmt: pointer
    iGroup: int32

  NMLVDISPINFOW {.bycopy.} = object
    hdr: NMHDR
    item: LVITEMW
struct NMHDR
{
    void* hwndFrom;
    size_t idFrom;
    uint code;
}

struct LVITEMW
{
    uint mask;
    int iItem;
    int iSubItem;
    uint state;
    uint stateMask;
    void* pszText;
    int cchTextMax;
    int iImage;
    ptrdiff_t lParam;
    int iIndent;
    int iGroupId;
    uint cColumns;
    void* puColumns;
    void* piColFmt;
    int iGroup;
}

struct NMLVDISPINFOW
{
    NMHDR hdr;
    LVITEMW item;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; NMLVDISPINFOW サイズ: 72 バイト(x86)
dim st, 18    ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; hdr : NMHDR (+0, 12byte)  varptr(st)+0 を基点に操作(12byte:入れ子/配列)
; item : LVITEMW (+12, 60byte)  varptr(st)+12 を基点に操作(60byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NMLVDISPINFOW サイズ: 112 バイト(x64)
dim st, 28    ; 4byte整数×28(構造体サイズ 112 / 4 切り上げ)
; hdr : NMHDR (+0, 24byte)  varptr(st)+0 を基点に操作(24byte:入れ子/配列)
; item : LVITEMW (+24, 88byte)  varptr(st)+24 を基点に操作(88byte:入れ子/配列)
; ※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 LVITEMW
    #field int mask
    #field int iItem
    #field int iSubItem
    #field int state
    #field int stateMask
    #field intptr pszText
    #field int cchTextMax
    #field int iImage
    #field intptr lParam
    #field int iIndent
    #field int iGroupId
    #field int cColumns
    #field intptr puColumns
    #field intptr piColFmt
    #field int iGroup
#endstruct

#defstruct global NMLVDISPINFOW
    #field NMHDR hdr
    #field LVITEMW item
#endstruct

stdim st, NMLVDISPINFOW        ; NSTRUCT 変数を確保