ホーム › UI.WindowsAndMessaging › WINDOWPOS
WINDOWPOS
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| hwnd | HWND | 8/4 | +0 | +0 | 位置やサイズを変更するウィンドウのハンドルである。 |
| hwndInsertAfter | HWND | 8/4 | +8 | +4 | Z オーダー上でこのウィンドウの直前に配置するウィンドウのハンドルである。 |
| x | INT | 4 | +16 | +8 | ウィンドウ左端の位置である。 |
| y | INT | 4 | +20 | +12 | ウィンドウ上端の位置である。 |
| cx | INT | 4 | +24 | +16 | ウィンドウの幅(ピクセル)である。 |
| cy | INT | 4 | +28 | +20 | ウィンドウの高さ(ピクセル)である。 |
| flags | SET_WINDOW_POS_FLAGS | 4 | +32 | +24 | ウィンドウの位置決めオプションを示すフラグである(SWP_NOMOVE など)。 |
各言語での定義
#include <windows.h>
// WINDOWPOS (x64 40 / x86 28 バイト)
typedef struct WINDOWPOS {
HWND hwnd;
HWND hwndInsertAfter;
INT x;
INT y;
INT cx;
INT cy;
SET_WINDOW_POS_FLAGS flags;
} WINDOWPOS;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WINDOWPOS
{
public IntPtr hwnd;
public IntPtr hwndInsertAfter;
public int x;
public int y;
public int cx;
public int cy;
public uint flags;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WINDOWPOS
Public hwnd As IntPtr
Public hwndInsertAfter As IntPtr
Public x As Integer
Public y As Integer
Public cx As Integer
Public cy As Integer
Public flags As UInteger
End Structureimport ctypes
from ctypes import wintypes
class WINDOWPOS(ctypes.Structure):
_fields_ = [
("hwnd", ctypes.c_void_p),
("hwndInsertAfter", ctypes.c_void_p),
("x", ctypes.c_int),
("y", ctypes.c_int),
("cx", ctypes.c_int),
("cy", ctypes.c_int),
("flags", wintypes.DWORD),
]#[repr(C)]
pub struct WINDOWPOS {
pub hwnd: *mut core::ffi::c_void,
pub hwndInsertAfter: *mut core::ffi::c_void,
pub x: i32,
pub y: i32,
pub cx: i32,
pub cy: i32,
pub flags: u32,
}import "golang.org/x/sys/windows"
type WINDOWPOS struct {
hwnd uintptr
hwndInsertAfter uintptr
x int32
y int32
cx int32
cy int32
flags uint32
}type
WINDOWPOS = record
hwnd: Pointer;
hwndInsertAfter: Pointer;
x: Integer;
y: Integer;
cx: Integer;
cy: Integer;
flags: DWORD;
end;const WINDOWPOS = extern struct {
hwnd: ?*anyopaque,
hwndInsertAfter: ?*anyopaque,
x: i32,
y: i32,
cx: i32,
cy: i32,
flags: u32,
};type
WINDOWPOS {.bycopy.} = object
hwnd: pointer
hwndInsertAfter: pointer
x: int32
y: int32
cx: int32
cy: int32
flags: uint32struct WINDOWPOS
{
void* hwnd;
void* hwndInsertAfter;
int x;
int y;
int cx;
int cy;
uint flags;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; WINDOWPOS サイズ: 28 バイト(x86)
dim st, 7 ; 4byte整数×7(構造体サイズ 28 / 4 切り上げ)
; hwnd : HWND (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; hwndInsertAfter : HWND (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; x : INT (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; y : INT (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; cx : INT (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; cy : INT (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; flags : SET_WINDOW_POS_FLAGS (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WINDOWPOS サイズ: 40 バイト(x64)
dim st, 10 ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; hwnd : HWND (+0, 8byte) qpoke st,0,値 / qpeek(st,0) ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; hwndInsertAfter : HWND (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; x : INT (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; y : INT (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; cx : INT (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; cy : INT (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; flags : SET_WINDOW_POS_FLAGS (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global WINDOWPOS
#field intptr hwnd
#field intptr hwndInsertAfter
#field int x
#field int y
#field int cx
#field int cy
#field int flags
#endstruct
stdim st, WINDOWPOS ; NSTRUCT 変数を確保
st->x = 100
mes "x=" + st->x