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

NMLINK

構造体
サイズx64: 4304 バイト / x86: 4292 バイト

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

フィールド

フィールドサイズx64x86説明
hdrNMHDR24/12+0+0通知元やコードを含む共通NMHDR構造体。NM_CLICK等で使う。
itemLITEM4280+24+12クリック等の対象となったリンク項目を表すLITEM構造体。

各言語での定義

#include <windows.h>

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

// LITEM  (x64 4280 / x86 4280 バイト)
typedef struct LITEM {
    LIST_ITEM_FLAGS mask;
    INT iLink;
    LIST_ITEM_STATE_FLAGS state;
    LIST_ITEM_STATE_FLAGS stateMask;
    WCHAR szID[48];
    WCHAR szUrl[2084];
} LITEM;

// NMLINK  (x64 4304 / x86 4292 バイト)
typedef struct NMLINK {
    NMHDR hdr;
    LITEM item;
} NMLINK;
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 LITEM
{
    public uint mask;
    public int iLink;
    public uint state;
    public uint stateMask;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 48)] public string szID;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2084)] public string szUrl;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NMLINK
{
    public NMHDR hdr;
    public LITEM 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 LITEM
    Public mask As UInteger
    Public iLink As Integer
    Public state As UInteger
    Public stateMask As UInteger
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=48)> Public szID As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=2084)> Public szUrl As String
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NMLINK
    Public hdr As NMHDR
    Public item As LITEM
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 LITEM(ctypes.Structure):
    _fields_ = [
        ("mask", wintypes.DWORD),
        ("iLink", ctypes.c_int),
        ("state", wintypes.DWORD),
        ("stateMask", wintypes.DWORD),
        ("szID", ctypes.c_wchar * 48),
        ("szUrl", ctypes.c_wchar * 2084),
    ]

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

#[repr(C)]
pub struct LITEM {
    pub mask: u32,
    pub iLink: i32,
    pub state: u32,
    pub stateMask: u32,
    pub szID: [u16; 48],
    pub szUrl: [u16; 2084],
}

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

type NMHDR struct {
	hwndFrom uintptr
	idFrom uintptr
	code uint32
}

type LITEM struct {
	mask uint32
	iLink int32
	state uint32
	stateMask uint32
	szID [48]uint16
	szUrl [2084]uint16
}

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

  LITEM = record
    mask: DWORD;
    iLink: Integer;
    state: DWORD;
    stateMask: DWORD;
    szID: array[0..47] of WideChar;
    szUrl: array[0..2083] of WideChar;
  end;

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

const LITEM = extern struct {
    mask: u32,
    iLink: i32,
    state: u32,
    stateMask: u32,
    szID: [48]u16,
    szUrl: [2084]u16,
};

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

  LITEM {.bycopy.} = object
    mask: uint32
    iLink: int32
    state: uint32
    stateMask: uint32
    szID: array[48, uint16]
    szUrl: array[2084, uint16]

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

struct LITEM
{
    uint mask;
    int iLink;
    uint state;
    uint stateMask;
    wchar[48] szID;
    wchar[2084] szUrl;
}

struct NMLINK
{
    NMHDR hdr;
    LITEM item;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; NMLINK サイズ: 4292 バイト(x86)
dim st, 1073    ; 4byte整数×1073(構造体サイズ 4292 / 4 切り上げ)
; hdr : NMHDR (+0, 12byte)  varptr(st)+0 を基点に操作(12byte:入れ子/配列)
; item : LITEM (+12, 4280byte)  varptr(st)+12 を基点に操作(4280byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NMLINK サイズ: 4304 バイト(x64)
dim st, 1076    ; 4byte整数×1076(構造体サイズ 4304 / 4 切り上げ)
; hdr : NMHDR (+0, 24byte)  varptr(st)+0 を基点に操作(24byte:入れ子/配列)
; item : LITEM (+24, 4280byte)  varptr(st)+24 を基点に操作(4280byte:入れ子/配列)
; ※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 LITEM
    #field int mask
    #field int iLink
    #field int state
    #field int stateMask
    #field wchar szID 48
    #field wchar szUrl 2084
#endstruct

#defstruct global NMLINK
    #field NMHDR hdr
    #field LITEM item
#endstruct

stdim st, NMLINK        ; NSTRUCT 変数を確保