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

WINDOWPOS

構造体
サイズx64: 40 バイト / x86: 28 バイト

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

フィールド

フィールドサイズx64x86説明
hwndHWND8/4+0+0ウィンドウへのハンドル。
hwndInsertAfterHWND8/4+8+4Z オーダー(前後方向の位置)におけるウィンドウの位置。このメンバーには、このウィンドウを背後に配置する対象となるウィンドウのハンドル、または SetWindowPos 関数に記載されている特別な値のいずれかを指定できます。
xINT4+16+8ウィンドウの左端の位置。
yINT4+20+12ウィンドウの上端の位置。
cxINT4+24+16ウィンドウの幅(ピクセル単位)。
cyINT4+28+20ウィンドウの高さ(ピクセル単位)。
flagsSET_WINDOW_POS_FLAGS4+32+24

ウィンドウの位置。このメンバーには、次の値の 1 つ以上を指定できます。

意味
SWP_DRAWFRAME
0x0020
ウィンドウの周囲にフレーム(ウィンドウのクラス記述で定義されたもの)を描画します。SWP_FRAMECHANGED フラグと同じです。
SWP_FRAMECHANGED
0x0020
ウィンドウのサイズが変更されない場合でも、ウィンドウに WM_NCCALCSIZE メッセージを送信します。このフラグが指定されていない場合、WM_NCCALCSIZE はウィンドウのサイズが変更されるときにのみ送信されます。
SWP_HIDEWINDOW
0x0080
ウィンドウを非表示にします。
SWP_NOACTIVATE
0x0010
ウィンドウをアクティブにしません。このフラグが設定されていない場合、ウィンドウはアクティブになり、最前面グループまたは非最前面グループの先頭に移動されます(どちらになるかは hwndInsertAfter メンバーの設定によって決まります)。
SWP_NOCOPYBITS
0x0100
クライアント領域の内容全体を破棄します。このフラグが指定されていない場合、クライアント領域の有効な内容は保存され、ウィンドウのサイズ変更または位置変更の後にクライアント領域へコピーし戻されます。
SWP_NOMOVE
0x0002
現在の位置を保持します( x メンバーと y メンバーは無視されます)。
SWP_ NOOWNERZORDER
0x0200
オーナーウィンドウの Z オーダー内での位置を変更しません。
SWP_NOREDRAW
0x0008
変更を再描画しません。このフラグが設定されている場合、いかなる種類の再描画も行われません。これは、クライアント領域、非クライアント領域(タイトルバーやスクロールバーを含む)、およびウィンドウが移動した結果として現れた親ウィンドウの部分に適用されます。このフラグが設定されている場合、アプリケーションは再描画が必要なウィンドウおよび親ウィンドウの部分を明示的に無効化または再描画する必要があります。
SWP_NOREPOSITION
0x0200
オーナーウィンドウの Z オーダー内での位置を変更しません。SWP_NOOWNERZORDER フラグと同じです。
SWP_NOSENDCHANGING
0x0400
ウィンドウが WM_WINDOWPOSCHANGING メッセージを受け取らないようにします。
SWP_NOSIZE
0x0001
現在のサイズを保持します( cx メンバーと cy メンバーは無視されます)。
SWP_NOZORDER
0x0004
現在の Z オーダーを保持します( hwndInsertAfter メンバーは無視されます)。
SWP_SHOWWINDOW
0x0040
ウィンドウを表示します。

公式ドキュメント

ウィンドウのサイズと位置に関する情報を格納します。

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

各言語での定義

#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 Structure
import 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: uint32
struct 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