Win32 API 日本語リファレンス
ホームUI.Input.Ime › INPUTCONTEXT

INPUTCONTEXT

構造体
サイズx64: 352 バイト / x86: 320 バイト

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

フィールド

フィールドサイズx64x86説明
hWndHWND8/4+0+0この入力コンテキストに関連付くウィンドウハンドルである。
fOpenBOOL4+8+4IMEが開いている(オン)かを示す真偽値である。
ptStatusWndPosPOINT8+12+8ステータスウィンドウの位置を示すPOINTである。
ptSoftKbdPosPOINT8+20+16ソフトキーボードの位置を示すPOINTである。
fdwConversionDWORD4+28+24変換モードを示すフラグ(IME_CMODE_系)である。
fdwSentenceDWORD4+32+28文節変換モードを示すフラグ(IME_SMODE_系)である。
lfFont_lfFont_e__Union92+36+32変換ウィンドウで使用するフォント情報の共用体である。
cfCompFormCOMPOSITIONFORM28+128+124変換ウィンドウの配置情報COMPOSITIONFORMである。
cfCandFormCANDIDATEFORM128+156+152候補ウィンドウの配置情報CANDIDATEFORMである。
hCompStrHIMCC8/4+288+280変換文字列データを保持するHIMCCハンドルである。
hCandInfoHIMCC8/4+296+284候補情報を保持するHIMCCハンドルである。
hGuideLineHIMCC8/4+304+288ガイドライン情報を保持するHIMCCハンドルである。
hPrivateHIMCC8/4+312+292IME独自データを保持するHIMCCハンドルである。
dwNumMsgBufDWORD4+320+296メッセージバッファ内のメッセージ個数である。
hMsgBufHIMCC8/4+328+300メッセージバッファを保持するHIMCCハンドルである。
fdwInitDWORD4+336+304初期化済みメンバを示すフラグである。
dwReserveDWORD12+340+308予約領域である。

共用体: _lfFont_e__Union x64 92B / x86 92B

フィールドサイズx64x86
ALOGFONTA60+0+0
WLOGFONTW92+0+0

各言語での定義

#include <windows.h>

// POINT  (x64 8 / x86 8 バイト)
typedef struct POINT {
    INT x;
    INT y;
} POINT;

// RECT  (x64 16 / x86 16 バイト)
typedef struct RECT {
    INT left;
    INT top;
    INT right;
    INT bottom;
} RECT;

// COMPOSITIONFORM  (x64 28 / x86 28 バイト)
typedef struct COMPOSITIONFORM {
    DWORD dwStyle;
    POINT ptCurrentPos;
    RECT rcArea;
} COMPOSITIONFORM;

// CANDIDATEFORM  (x64 32 / x86 32 バイト)
typedef struct CANDIDATEFORM {
    DWORD dwIndex;
    DWORD dwStyle;
    POINT ptCurrentPos;
    RECT rcArea;
} CANDIDATEFORM;

// INPUTCONTEXT  (x64 352 / x86 320 バイト)
typedef struct INPUTCONTEXT {
    HWND hWnd;
    BOOL fOpen;
    POINT ptStatusWndPos;
    POINT ptSoftKbdPos;
    DWORD fdwConversion;
    DWORD fdwSentence;
    _lfFont_e__Union lfFont;
    COMPOSITIONFORM cfCompForm;
    CANDIDATEFORM cfCandForm[4];
    HIMCC hCompStr;
    HIMCC hCandInfo;
    HIMCC hGuideLine;
    HIMCC hPrivate;
    DWORD dwNumMsgBuf;
    HIMCC hMsgBuf;
    DWORD fdwInit;
    DWORD dwReserve[3];
} INPUTCONTEXT;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct POINT
{
    public int x;
    public int y;
}

[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 COMPOSITIONFORM
{
    public uint dwStyle;
    public POINT ptCurrentPos;
    public RECT rcArea;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CANDIDATEFORM
{
    public uint dwIndex;
    public uint dwStyle;
    public POINT ptCurrentPos;
    public RECT rcArea;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct INPUTCONTEXT
{
    public IntPtr hWnd;
    [MarshalAs(UnmanagedType.Bool)] public bool fOpen;
    public POINT ptStatusWndPos;
    public POINT ptSoftKbdPos;
    public uint fdwConversion;
    public uint fdwSentence;
    public _lfFont_e__Union lfFont;
    public COMPOSITIONFORM cfCompForm;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public CANDIDATEFORM[] cfCandForm;
    public IntPtr hCompStr;
    public IntPtr hCandInfo;
    public IntPtr hGuideLine;
    public IntPtr hPrivate;
    public uint dwNumMsgBuf;
    public IntPtr hMsgBuf;
    public uint fdwInit;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public uint[] dwReserve;
}
Imports System.Runtime.InteropServices

<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 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 COMPOSITIONFORM
    Public dwStyle As UInteger
    Public ptCurrentPos As POINT
    Public rcArea As RECT
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CANDIDATEFORM
    Public dwIndex As UInteger
    Public dwStyle As UInteger
    Public ptCurrentPos As POINT
    Public rcArea As RECT
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure INPUTCONTEXT
    Public hWnd As IntPtr
    <MarshalAs(UnmanagedType.Bool)> Public fOpen As Boolean
    Public ptStatusWndPos As POINT
    Public ptSoftKbdPos As POINT
    Public fdwConversion As UInteger
    Public fdwSentence As UInteger
    Public lfFont As _lfFont_e__Union
    Public cfCompForm As COMPOSITIONFORM
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public cfCandForm() As CANDIDATEFORM
    Public hCompStr As IntPtr
    Public hCandInfo As IntPtr
    Public hGuideLine As IntPtr
    Public hPrivate As IntPtr
    Public dwNumMsgBuf As UInteger
    Public hMsgBuf As IntPtr
    Public fdwInit As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> Public dwReserve() As UInteger
End Structure
import ctypes
from ctypes import wintypes

class POINT(ctypes.Structure):
    _fields_ = [
        ("x", ctypes.c_int),
        ("y", ctypes.c_int),
    ]

class RECT(ctypes.Structure):
    _fields_ = [
        ("left", ctypes.c_int),
        ("top", ctypes.c_int),
        ("right", ctypes.c_int),
        ("bottom", ctypes.c_int),
    ]

class COMPOSITIONFORM(ctypes.Structure):
    _fields_ = [
        ("dwStyle", wintypes.DWORD),
        ("ptCurrentPos", POINT),
        ("rcArea", RECT),
    ]

class CANDIDATEFORM(ctypes.Structure):
    _fields_ = [
        ("dwIndex", wintypes.DWORD),
        ("dwStyle", wintypes.DWORD),
        ("ptCurrentPos", POINT),
        ("rcArea", RECT),
    ]

class INPUTCONTEXT(ctypes.Structure):
    _fields_ = [
        ("hWnd", ctypes.c_void_p),
        ("fOpen", wintypes.BOOL),
        ("ptStatusWndPos", POINT),
        ("ptSoftKbdPos", POINT),
        ("fdwConversion", wintypes.DWORD),
        ("fdwSentence", wintypes.DWORD),
        ("lfFont", _lfFont_e__Union),
        ("cfCompForm", COMPOSITIONFORM),
        ("cfCandForm", CANDIDATEFORM * 4),
        ("hCompStr", ctypes.c_void_p),
        ("hCandInfo", ctypes.c_void_p),
        ("hGuideLine", ctypes.c_void_p),
        ("hPrivate", ctypes.c_void_p),
        ("dwNumMsgBuf", wintypes.DWORD),
        ("hMsgBuf", ctypes.c_void_p),
        ("fdwInit", wintypes.DWORD),
        ("dwReserve", wintypes.DWORD * 3),
    ]
#[repr(C)]
pub struct POINT {
    pub x: i32,
    pub y: i32,
}

#[repr(C)]
pub struct RECT {
    pub left: i32,
    pub top: i32,
    pub right: i32,
    pub bottom: i32,
}

#[repr(C)]
pub struct COMPOSITIONFORM {
    pub dwStyle: u32,
    pub ptCurrentPos: POINT,
    pub rcArea: RECT,
}

#[repr(C)]
pub struct CANDIDATEFORM {
    pub dwIndex: u32,
    pub dwStyle: u32,
    pub ptCurrentPos: POINT,
    pub rcArea: RECT,
}

#[repr(C)]
pub struct INPUTCONTEXT {
    pub hWnd: *mut core::ffi::c_void,
    pub fOpen: i32,
    pub ptStatusWndPos: POINT,
    pub ptSoftKbdPos: POINT,
    pub fdwConversion: u32,
    pub fdwSentence: u32,
    pub lfFont: _lfFont_e__Union,
    pub cfCompForm: COMPOSITIONFORM,
    pub cfCandForm: [CANDIDATEFORM; 4],
    pub hCompStr: *mut core::ffi::c_void,
    pub hCandInfo: *mut core::ffi::c_void,
    pub hGuideLine: *mut core::ffi::c_void,
    pub hPrivate: *mut core::ffi::c_void,
    pub dwNumMsgBuf: u32,
    pub hMsgBuf: *mut core::ffi::c_void,
    pub fdwInit: u32,
    pub dwReserve: [u32; 3],
}
import "golang.org/x/sys/windows"

type POINT struct {
	x int32
	y int32
}

type RECT struct {
	left int32
	top int32
	right int32
	bottom int32
}

type COMPOSITIONFORM struct {
	dwStyle uint32
	ptCurrentPos POINT
	rcArea RECT
}

type CANDIDATEFORM struct {
	dwIndex uint32
	dwStyle uint32
	ptCurrentPos POINT
	rcArea RECT
}

type INPUTCONTEXT struct {
	hWnd uintptr
	fOpen int32
	ptStatusWndPos POINT
	ptSoftKbdPos POINT
	fdwConversion uint32
	fdwSentence uint32
	lfFont _lfFont_e__Union
	cfCompForm COMPOSITIONFORM
	cfCandForm [4]CANDIDATEFORM
	hCompStr uintptr
	hCandInfo uintptr
	hGuideLine uintptr
	hPrivate uintptr
	dwNumMsgBuf uint32
	hMsgBuf uintptr
	fdwInit uint32
	dwReserve [3]uint32
}
type
  POINT = record
    x: Integer;
    y: Integer;
  end;

  RECT = record
    left: Integer;
    top: Integer;
    right: Integer;
    bottom: Integer;
  end;

  COMPOSITIONFORM = record
    dwStyle: DWORD;
    ptCurrentPos: POINT;
    rcArea: RECT;
  end;

  CANDIDATEFORM = record
    dwIndex: DWORD;
    dwStyle: DWORD;
    ptCurrentPos: POINT;
    rcArea: RECT;
  end;

  INPUTCONTEXT = record
    hWnd: Pointer;
    fOpen: BOOL;
    ptStatusWndPos: POINT;
    ptSoftKbdPos: POINT;
    fdwConversion: DWORD;
    fdwSentence: DWORD;
    lfFont: _lfFont_e__Union;
    cfCompForm: COMPOSITIONFORM;
    cfCandForm: array[0..3] of CANDIDATEFORM;
    hCompStr: Pointer;
    hCandInfo: Pointer;
    hGuideLine: Pointer;
    hPrivate: Pointer;
    dwNumMsgBuf: DWORD;
    hMsgBuf: Pointer;
    fdwInit: DWORD;
    dwReserve: array[0..2] of DWORD;
  end;
const POINT = extern struct {
    x: i32,
    y: i32,
};

const RECT = extern struct {
    left: i32,
    top: i32,
    right: i32,
    bottom: i32,
};

const COMPOSITIONFORM = extern struct {
    dwStyle: u32,
    ptCurrentPos: POINT,
    rcArea: RECT,
};

const CANDIDATEFORM = extern struct {
    dwIndex: u32,
    dwStyle: u32,
    ptCurrentPos: POINT,
    rcArea: RECT,
};

const INPUTCONTEXT = extern struct {
    hWnd: ?*anyopaque,
    fOpen: i32,
    ptStatusWndPos: POINT,
    ptSoftKbdPos: POINT,
    fdwConversion: u32,
    fdwSentence: u32,
    lfFont: _lfFont_e__Union,
    cfCompForm: COMPOSITIONFORM,
    cfCandForm: [4]CANDIDATEFORM,
    hCompStr: ?*anyopaque,
    hCandInfo: ?*anyopaque,
    hGuideLine: ?*anyopaque,
    hPrivate: ?*anyopaque,
    dwNumMsgBuf: u32,
    hMsgBuf: ?*anyopaque,
    fdwInit: u32,
    dwReserve: [3]u32,
};
type
  POINT {.bycopy.} = object
    x: int32
    y: int32

  RECT {.bycopy.} = object
    left: int32
    top: int32
    right: int32
    bottom: int32

  COMPOSITIONFORM {.bycopy.} = object
    dwStyle: uint32
    ptCurrentPos: POINT
    rcArea: RECT

  CANDIDATEFORM {.bycopy.} = object
    dwIndex: uint32
    dwStyle: uint32
    ptCurrentPos: POINT
    rcArea: RECT

  INPUTCONTEXT {.bycopy.} = object
    hWnd: pointer
    fOpen: int32
    ptStatusWndPos: POINT
    ptSoftKbdPos: POINT
    fdwConversion: uint32
    fdwSentence: uint32
    lfFont: _lfFont_e__Union
    cfCompForm: COMPOSITIONFORM
    cfCandForm: array[4, CANDIDATEFORM]
    hCompStr: pointer
    hCandInfo: pointer
    hGuideLine: pointer
    hPrivate: pointer
    dwNumMsgBuf: uint32
    hMsgBuf: pointer
    fdwInit: uint32
    dwReserve: array[3, uint32]
struct POINT
{
    int x;
    int y;
}

struct RECT
{
    int left;
    int top;
    int right;
    int bottom;
}

struct COMPOSITIONFORM
{
    uint dwStyle;
    POINT ptCurrentPos;
    RECT rcArea;
}

struct CANDIDATEFORM
{
    uint dwIndex;
    uint dwStyle;
    POINT ptCurrentPos;
    RECT rcArea;
}

struct INPUTCONTEXT
{
    void* hWnd;
    int fOpen;
    POINT ptStatusWndPos;
    POINT ptSoftKbdPos;
    uint fdwConversion;
    uint fdwSentence;
    _lfFont_e__Union lfFont;
    COMPOSITIONFORM cfCompForm;
    CANDIDATEFORM[4] cfCandForm;
    void* hCompStr;
    void* hCandInfo;
    void* hGuideLine;
    void* hPrivate;
    uint dwNumMsgBuf;
    void* hMsgBuf;
    uint fdwInit;
    uint[3] dwReserve;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; INPUTCONTEXT サイズ: 320 バイト(x86)
dim st, 80    ; 4byte整数×80(構造体サイズ 320 / 4 切り上げ)
; hWnd : HWND (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; fOpen : BOOL (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; ptStatusWndPos : POINT (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; ptSoftKbdPos : POINT (+16, 8byte)  varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; fdwConversion : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; fdwSentence : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; lfFont : _lfFont_e__Union (+32, 92byte)  varptr(st)+32 を基点に操作(92byte:入れ子/配列)
; cfCompForm : COMPOSITIONFORM (+124, 28byte)  varptr(st)+124 を基点に操作(28byte:入れ子/配列)
; cfCandForm : CANDIDATEFORM (+152, 128byte)  varptr(st)+152 を基点に操作(128byte:入れ子/配列)
; hCompStr : HIMCC (+280, 4byte)  st.70 = 値  /  値 = st.70   (lpoke/lpeek も可)
; hCandInfo : HIMCC (+284, 4byte)  st.71 = 値  /  値 = st.71   (lpoke/lpeek も可)
; hGuideLine : HIMCC (+288, 4byte)  st.72 = 値  /  値 = st.72   (lpoke/lpeek も可)
; hPrivate : HIMCC (+292, 4byte)  st.73 = 値  /  値 = st.73   (lpoke/lpeek も可)
; dwNumMsgBuf : DWORD (+296, 4byte)  st.74 = 値  /  値 = st.74   (lpoke/lpeek も可)
; hMsgBuf : HIMCC (+300, 4byte)  st.75 = 値  /  値 = st.75   (lpoke/lpeek も可)
; fdwInit : DWORD (+304, 4byte)  st.76 = 値  /  値 = st.76   (lpoke/lpeek も可)
; dwReserve : DWORD (+308, 12byte)  varptr(st)+308 を基点に操作(12byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; INPUTCONTEXT サイズ: 352 バイト(x64)
dim st, 88    ; 4byte整数×88(構造体サイズ 352 / 4 切り上げ)
; hWnd : HWND (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; fOpen : BOOL (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; ptStatusWndPos : POINT (+12, 8byte)  varptr(st)+12 を基点に操作(8byte:入れ子/配列)
; ptSoftKbdPos : POINT (+20, 8byte)  varptr(st)+20 を基点に操作(8byte:入れ子/配列)
; fdwConversion : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; fdwSentence : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; lfFont : _lfFont_e__Union (+36, 92byte)  varptr(st)+36 を基点に操作(92byte:入れ子/配列)
; cfCompForm : COMPOSITIONFORM (+128, 28byte)  varptr(st)+128 を基点に操作(28byte:入れ子/配列)
; cfCandForm : CANDIDATEFORM (+156, 128byte)  varptr(st)+156 を基点に操作(128byte:入れ子/配列)
; hCompStr : HIMCC (+288, 8byte)  qpoke st,288,値 / qpeek(st,288)  ※IronHSPのみ。3.7/3.8は lpoke st,288,下位 : lpoke st,292,上位
; hCandInfo : HIMCC (+296, 8byte)  qpoke st,296,値 / qpeek(st,296)  ※IronHSPのみ。3.7/3.8は lpoke st,296,下位 : lpoke st,300,上位
; hGuideLine : HIMCC (+304, 8byte)  qpoke st,304,値 / qpeek(st,304)  ※IronHSPのみ。3.7/3.8は lpoke st,304,下位 : lpoke st,308,上位
; hPrivate : HIMCC (+312, 8byte)  qpoke st,312,値 / qpeek(st,312)  ※IronHSPのみ。3.7/3.8は lpoke st,312,下位 : lpoke st,316,上位
; dwNumMsgBuf : DWORD (+320, 4byte)  st.80 = 値  /  値 = st.80   (lpoke/lpeek も可)
; hMsgBuf : HIMCC (+328, 8byte)  qpoke st,328,値 / qpeek(st,328)  ※IronHSPのみ。3.7/3.8は lpoke st,328,下位 : lpoke st,332,上位
; fdwInit : DWORD (+336, 4byte)  st.84 = 値  /  値 = st.84   (lpoke/lpeek も可)
; dwReserve : DWORD (+340, 12byte)  varptr(st)+340 を基点に操作(12byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global POINT
    #field int x
    #field int y
#endstruct

#defstruct global RECT
    #field int left
    #field int top
    #field int right
    #field int bottom
#endstruct

#defstruct global COMPOSITIONFORM
    #field int dwStyle
    #field POINT ptCurrentPos
    #field RECT rcArea
#endstruct

#defstruct global CANDIDATEFORM
    #field int dwIndex
    #field int dwStyle
    #field POINT ptCurrentPos
    #field RECT rcArea
#endstruct

#defstruct global INPUTCONTEXT
    #field intptr hWnd
    #field bool fOpen
    #field POINT ptStatusWndPos
    #field POINT ptSoftKbdPos
    #field int fdwConversion
    #field int fdwSentence
    #field byte lfFont 92
    #field COMPOSITIONFORM cfCompForm
    #field CANDIDATEFORM cfCandForm 4
    #field intptr hCompStr
    #field intptr hCandInfo
    #field intptr hGuideLine
    #field intptr hPrivate
    #field int dwNumMsgBuf
    #field intptr hMsgBuf
    #field int fdwInit
    #field int dwReserve 3
#endstruct

stdim st, INPUTCONTEXT        ; NSTRUCT 変数を確保
st->fOpen = 100
mes "fOpen=" + st->fOpen
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。