HELPWININFOW
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| wStructSize | INT | 4 | +0 | +0 | この構造体のサイズ (バイト単位)。 |
| x | INT | 4 | +4 | +4 | ウィンドウの左上隅の X 座標 (スクリーン座標)。 |
| y | INT | 4 | +8 | +8 | ウィンドウの左上隅の Y 座標 (スクリーン座標)。 |
| dx | INT | 4 | +12 | +12 | ウィンドウの幅 (ピクセル単位)。 |
| dy | INT | 4 | +16 | +16 | ウィンドウの高さ (ピクセル単位)。 |
| wMax | INT | 4 | +20 | +20 | ウィンドウの表示に関するオプション。ShowWindow 関数の nCmdShow パラメーターに指定できる値のいずれかを指定できます。 |
| rgchMember | WCHAR | 4 | +24 | +24 | ウィンドウの名前。 |
公式ドキュメント
プライマリまたはセカンダリのヘルプ ウィンドウのサイズと位置を格納します。アプリケーションは、HELP_SETWINPOS 値を指定して WinHelp 関数を呼び出すことで、この情報を設定できます。
解説(Remarks)
Windows ヘルプは、X 方向と Y 方向の両方について、ディスプレイを 1024 単位に分割します。たとえば、ディスプレイの左上 4 分の 1 を占めるセカンダリ ウィンドウを作成するには、アプリケーションは x メンバーと y メンバーに 0 を、dx メンバーと dy メンバーに 512 を指定します。
wStructSize を正しく計算するには、rgchMember に格納する文字列の実際のサイズが分かっている必要があります。sizeof(HELPWININFO) には定義上 2 個の TCHAR が含まれるため、最終的な合計を求める際にはそれらを考慮しなければなりません。次の例は、wStructSize の値を正しく計算する方法を示しています。
WORD wSize;
TCHAR *szWndName = TEXT("wnd_menu");
size_t NameLength;
HRESULT hr;
HELPWININFO hwi;
// StringCbLength returns the length of the string without
// the terminating null character.
hr = StringCbLength(szWndName, STRSAFE_MAX_CCH * sizeof(TCHAR), &NameLength);
if (SUCCEEDED(hr))
{
// Add bytes to account for the name string's terminating null character.
NameLength + sizeof(TCHAR);
// Determine the size of HELPWININFO without the TCHAR array.
wSize = sizeof(HELPWININFO) - (2 * sizeof(TCHAR));
// Determine the total size of the final HELPWININFO structure.
hwi.wStructSize = wSize + NameLength;
}
winuser.h ヘッダーは、UNICODE プリプロセッサー定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして HELPWININFO を定義しています。エンコード中立のエイリアスを、エンコード中立でないコードと混在させて使用すると、不一致が生じてコンパイル エラーや実行時エラーの原因となる可能性があります。詳細については、Conventions for Function Prototypes を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#include <windows.h>
// HELPWININFOW (x64 28 / x86 28 バイト)
typedef struct HELPWININFOW {
INT wStructSize;
INT x;
INT y;
INT dx;
INT dy;
INT wMax;
WCHAR rgchMember[2];
} HELPWININFOW;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct HELPWININFOW
{
public int wStructSize;
public int x;
public int y;
public int dx;
public int dy;
public int wMax;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)] public string rgchMember;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure HELPWININFOW
Public wStructSize As Integer
Public x As Integer
Public y As Integer
Public dx As Integer
Public dy As Integer
Public wMax As Integer
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=2)> Public rgchMember As String
End Structureimport ctypes
from ctypes import wintypes
class HELPWININFOW(ctypes.Structure):
_fields_ = [
("wStructSize", ctypes.c_int),
("x", ctypes.c_int),
("y", ctypes.c_int),
("dx", ctypes.c_int),
("dy", ctypes.c_int),
("wMax", ctypes.c_int),
("rgchMember", ctypes.c_wchar * 2),
]#[repr(C)]
pub struct HELPWININFOW {
pub wStructSize: i32,
pub x: i32,
pub y: i32,
pub dx: i32,
pub dy: i32,
pub wMax: i32,
pub rgchMember: [u16; 2],
}import "golang.org/x/sys/windows"
type HELPWININFOW struct {
wStructSize int32
x int32
y int32
dx int32
dy int32
wMax int32
rgchMember [2]uint16
}type
HELPWININFOW = record
wStructSize: Integer;
x: Integer;
y: Integer;
dx: Integer;
dy: Integer;
wMax: Integer;
rgchMember: array[0..1] of WideChar;
end;const HELPWININFOW = extern struct {
wStructSize: i32,
x: i32,
y: i32,
dx: i32,
dy: i32,
wMax: i32,
rgchMember: [2]u16,
};type
HELPWININFOW {.bycopy.} = object
wStructSize: int32
x: int32
y: int32
dx: int32
dy: int32
wMax: int32
rgchMember: array[2, uint16]struct HELPWININFOW
{
int wStructSize;
int x;
int y;
int dx;
int dy;
int wMax;
wchar[2] rgchMember;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; HELPWININFOW サイズ: 28 バイト(x64)
dim st, 7 ; 4byte整数×7(構造体サイズ 28 / 4 切り上げ)
; wStructSize : INT (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; x : INT (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; y : INT (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; dx : INT (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; dy : INT (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; wMax : INT (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; rgchMember : WCHAR (+24, 4byte) varptr(st)+24 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global HELPWININFOW
#field int wStructSize
#field int x
#field int y
#field int dx
#field int dy
#field int wMax
#field wchar rgchMember 2
#endstruct
stdim st, HELPWININFOW ; NSTRUCT 変数を確保
st->wStructSize = 100
mes "wStructSize=" + st->wStructSize