ホーム › UI.WindowsAndMessaging › DeferWindowPos
DeferWindowPos
関数一括更新用にウィンドウの位置情報を追加する。
シグネチャ
// USER32.dll
#include <windows.h>
HDWP DeferWindowPos(
HDWP hWinPosInfo,
HWND hWnd,
HWND hWndInsertAfter, // optional
INT x,
INT y,
INT cx,
INT cy,
SET_WINDOW_POS_FLAGS uFlags
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hWinPosInfo | HDWP | in | BeginDeferWindowPosで取得した複数ウィンドウ位置構造体のハンドル(HDWP)。 |
| hWnd | HWND | in | 位置情報を更新キューに追加する対象のウィンドウハンドル。 |
| hWndInsertAfter | HWND | inoptional | Z順序で直前に置くウィンドウのハンドル。HWND_TOPなどの特殊値も指定可。 |
| x | INT | in | 新しい左上隅のX座標(ピクセル)。SWP_NOMOVE指定時は無視される。 |
| y | INT | in | 新しい左上隅のY座標(ピクセル)。SWP_NOMOVE指定時は無視される。 |
| cx | INT | in | 新しい幅(ピクセル)。SWP_NOSIZE指定時は無視される。 |
| cy | INT | in | 新しい高さ(ピクセル)。SWP_NOSIZE指定時は無視される。 |
| uFlags | SET_WINDOW_POS_FLAGS | in | サイズ・位置の変更動作を制御するフラグ。SWP_NOMOVEやSWP_NOSIZEなどの組み合わせ。 |
戻り値の型: HDWP
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
HDWP DeferWindowPos(
HDWP hWinPosInfo,
HWND hWnd,
HWND hWndInsertAfter, // optional
INT x,
INT y,
INT cx,
INT cy,
SET_WINDOW_POS_FLAGS uFlags
);[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr DeferWindowPos(
IntPtr hWinPosInfo, // HDWP
IntPtr hWnd, // HWND
IntPtr hWndInsertAfter, // HWND optional
int x, // INT
int y, // INT
int cx, // INT
int cy, // INT
uint uFlags // SET_WINDOW_POS_FLAGS
);<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function DeferWindowPos(
hWinPosInfo As IntPtr, ' HDWP
hWnd As IntPtr, ' HWND
hWndInsertAfter As IntPtr, ' HWND optional
x As Integer, ' INT
y As Integer, ' INT
cx As Integer, ' INT
cy As Integer, ' INT
uFlags As UInteger ' SET_WINDOW_POS_FLAGS
) As IntPtr
End Function' hWinPosInfo : HDWP
' hWnd : HWND
' hWndInsertAfter : HWND optional
' x : INT
' y : INT
' cx : INT
' cy : INT
' uFlags : SET_WINDOW_POS_FLAGS
Declare PtrSafe Function DeferWindowPos Lib "user32" ( _
ByVal hWinPosInfo As LongPtr, _
ByVal hWnd As LongPtr, _
ByVal hWndInsertAfter As LongPtr, _
ByVal x As Long, _
ByVal y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal uFlags As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DeferWindowPos = ctypes.windll.user32.DeferWindowPos
DeferWindowPos.restype = ctypes.c_void_p
DeferWindowPos.argtypes = [
wintypes.HANDLE, # hWinPosInfo : HDWP
wintypes.HANDLE, # hWnd : HWND
wintypes.HANDLE, # hWndInsertAfter : HWND optional
ctypes.c_int, # x : INT
ctypes.c_int, # y : INT
ctypes.c_int, # cx : INT
ctypes.c_int, # cy : INT
wintypes.DWORD, # uFlags : SET_WINDOW_POS_FLAGS
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
DeferWindowPos = Fiddle::Function.new(
lib['DeferWindowPos'],
[
Fiddle::TYPE_VOIDP, # hWinPosInfo : HDWP
Fiddle::TYPE_VOIDP, # hWnd : HWND
Fiddle::TYPE_VOIDP, # hWndInsertAfter : HWND optional
Fiddle::TYPE_INT, # x : INT
Fiddle::TYPE_INT, # y : INT
Fiddle::TYPE_INT, # cx : INT
Fiddle::TYPE_INT, # cy : INT
-Fiddle::TYPE_INT, # uFlags : SET_WINDOW_POS_FLAGS
],
Fiddle::TYPE_VOIDP)#[link(name = "user32")]
extern "system" {
fn DeferWindowPos(
hWinPosInfo: *mut core::ffi::c_void, // HDWP
hWnd: *mut core::ffi::c_void, // HWND
hWndInsertAfter: *mut core::ffi::c_void, // HWND optional
x: i32, // INT
y: i32, // INT
cx: i32, // INT
cy: i32, // INT
uFlags: u32 // SET_WINDOW_POS_FLAGS
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("USER32.dll", SetLastError = true)]
public static extern IntPtr DeferWindowPos(IntPtr hWinPosInfo, IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_DeferWindowPos' -Namespace Win32 -PassThru
# $api::DeferWindowPos(hWinPosInfo, hWnd, hWndInsertAfter, x, y, cx, cy, uFlags)#uselib "USER32.dll"
#func global DeferWindowPos "DeferWindowPos" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; DeferWindowPos hWinPosInfo, hWnd, hWndInsertAfter, x, y, cx, cy, uFlags ; 戻り値は stat
; hWinPosInfo : HDWP -> "sptr"
; hWnd : HWND -> "sptr"
; hWndInsertAfter : HWND optional -> "sptr"
; x : INT -> "sptr"
; y : INT -> "sptr"
; cx : INT -> "sptr"
; cy : INT -> "sptr"
; uFlags : SET_WINDOW_POS_FLAGS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll"
#cfunc global DeferWindowPos "DeferWindowPos" sptr, sptr, sptr, int, int, int, int, int
; res = DeferWindowPos(hWinPosInfo, hWnd, hWndInsertAfter, x, y, cx, cy, uFlags)
; hWinPosInfo : HDWP -> "sptr"
; hWnd : HWND -> "sptr"
; hWndInsertAfter : HWND optional -> "sptr"
; x : INT -> "int"
; y : INT -> "int"
; cx : INT -> "int"
; cy : INT -> "int"
; uFlags : SET_WINDOW_POS_FLAGS -> "int"; HDWP DeferWindowPos(HDWP hWinPosInfo, HWND hWnd, HWND hWndInsertAfter, INT x, INT y, INT cx, INT cy, SET_WINDOW_POS_FLAGS uFlags)
#uselib "USER32.dll"
#cfunc global DeferWindowPos "DeferWindowPos" intptr, intptr, intptr, int, int, int, int, int
; res = DeferWindowPos(hWinPosInfo, hWnd, hWndInsertAfter, x, y, cx, cy, uFlags)
; hWinPosInfo : HDWP -> "intptr"
; hWnd : HWND -> "intptr"
; hWndInsertAfter : HWND optional -> "intptr"
; x : INT -> "int"
; y : INT -> "int"
; cx : INT -> "int"
; cy : INT -> "int"
; uFlags : SET_WINDOW_POS_FLAGS -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procDeferWindowPos = user32.NewProc("DeferWindowPos")
)
// hWinPosInfo (HDWP), hWnd (HWND), hWndInsertAfter (HWND optional), x (INT), y (INT), cx (INT), cy (INT), uFlags (SET_WINDOW_POS_FLAGS)
r1, _, err := procDeferWindowPos.Call(
uintptr(hWinPosInfo),
uintptr(hWnd),
uintptr(hWndInsertAfter),
uintptr(x),
uintptr(y),
uintptr(cx),
uintptr(cy),
uintptr(uFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HDWPfunction DeferWindowPos(
hWinPosInfo: THandle; // HDWP
hWnd: THandle; // HWND
hWndInsertAfter: THandle; // HWND optional
x: Integer; // INT
y: Integer; // INT
cx: Integer; // INT
cy: Integer; // INT
uFlags: DWORD // SET_WINDOW_POS_FLAGS
): THandle; stdcall;
external 'USER32.dll' name 'DeferWindowPos';result := DllCall("USER32\DeferWindowPos"
, "Ptr", hWinPosInfo ; HDWP
, "Ptr", hWnd ; HWND
, "Ptr", hWndInsertAfter ; HWND optional
, "Int", x ; INT
, "Int", y ; INT
, "Int", cx ; INT
, "Int", cy ; INT
, "UInt", uFlags ; SET_WINDOW_POS_FLAGS
, "Ptr") ; return: HDWP●DeferWindowPos(hWinPosInfo, hWnd, hWndInsertAfter, x, y, cx, cy, uFlags) = DLL("USER32.dll", "void* DeferWindowPos(void*, void*, void*, int, int, int, int, dword)")
# 呼び出し: DeferWindowPos(hWinPosInfo, hWnd, hWndInsertAfter, x, y, cx, cy, uFlags)
# hWinPosInfo : HDWP -> "void*"
# hWnd : HWND -> "void*"
# hWndInsertAfter : HWND optional -> "void*"
# x : INT -> "int"
# y : INT -> "int"
# cx : INT -> "int"
# cy : INT -> "int"
# uFlags : SET_WINDOW_POS_FLAGS -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。