ホーム › UI.WindowsAndMessaging › CascadeWindows
CascadeWindows
関数指定した子ウィンドウを重ねて段違いに配置する。
シグネチャ
// USER32.dll
#include <windows.h>
WORD CascadeWindows(
HWND hwndParent, // optional
CASCADE_WINDOWS_HOW wHow,
const RECT* lpRect, // optional
DWORD cKids,
const HWND* lpKids // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hwndParent | HWND | inoptional |
| wHow | CASCADE_WINDOWS_HOW | in |
| lpRect | RECT* | inoptional |
| cKids | DWORD | in |
| lpKids | HWND* | inoptional |
戻り値の型: WORD
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
WORD CascadeWindows(
HWND hwndParent, // optional
CASCADE_WINDOWS_HOW wHow,
const RECT* lpRect, // optional
DWORD cKids,
const HWND* lpKids // optional
);[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern ushort CascadeWindows(
IntPtr hwndParent, // HWND optional
uint wHow, // CASCADE_WINDOWS_HOW
IntPtr lpRect, // RECT* optional
uint cKids, // DWORD
IntPtr lpKids // HWND* optional
);<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CascadeWindows(
hwndParent As IntPtr, ' HWND optional
wHow As UInteger, ' CASCADE_WINDOWS_HOW
lpRect As IntPtr, ' RECT* optional
cKids As UInteger, ' DWORD
lpKids As IntPtr ' HWND* optional
) As UShort
End Function' hwndParent : HWND optional
' wHow : CASCADE_WINDOWS_HOW
' lpRect : RECT* optional
' cKids : DWORD
' lpKids : HWND* optional
Declare PtrSafe Function CascadeWindows Lib "user32" ( _
ByVal hwndParent As LongPtr, _
ByVal wHow As Long, _
ByVal lpRect As LongPtr, _
ByVal cKids As Long, _
ByVal lpKids As LongPtr) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CascadeWindows = ctypes.windll.user32.CascadeWindows
CascadeWindows.restype = ctypes.c_ushort
CascadeWindows.argtypes = [
wintypes.HANDLE, # hwndParent : HWND optional
wintypes.DWORD, # wHow : CASCADE_WINDOWS_HOW
ctypes.c_void_p, # lpRect : RECT* optional
wintypes.DWORD, # cKids : DWORD
ctypes.c_void_p, # lpKids : HWND* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
CascadeWindows = Fiddle::Function.new(
lib['CascadeWindows'],
[
Fiddle::TYPE_VOIDP, # hwndParent : HWND optional
-Fiddle::TYPE_INT, # wHow : CASCADE_WINDOWS_HOW
Fiddle::TYPE_VOIDP, # lpRect : RECT* optional
-Fiddle::TYPE_INT, # cKids : DWORD
Fiddle::TYPE_VOIDP, # lpKids : HWND* optional
],
-Fiddle::TYPE_SHORT)#[link(name = "user32")]
extern "system" {
fn CascadeWindows(
hwndParent: *mut core::ffi::c_void, // HWND optional
wHow: u32, // CASCADE_WINDOWS_HOW
lpRect: *const RECT, // RECT* optional
cKids: u32, // DWORD
lpKids: *mut *mut core::ffi::c_void // HWND* optional
) -> u16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("USER32.dll", SetLastError = true)]
public static extern ushort CascadeWindows(IntPtr hwndParent, uint wHow, IntPtr lpRect, uint cKids, IntPtr lpKids);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_CascadeWindows' -Namespace Win32 -PassThru
# $api::CascadeWindows(hwndParent, wHow, lpRect, cKids, lpKids)#uselib "USER32.dll"
#func global CascadeWindows "CascadeWindows" sptr, sptr, sptr, sptr, sptr
; CascadeWindows hwndParent, wHow, varptr(lpRect), cKids, lpKids ; 戻り値は stat
; hwndParent : HWND optional -> "sptr"
; wHow : CASCADE_WINDOWS_HOW -> "sptr"
; lpRect : RECT* optional -> "sptr"
; cKids : DWORD -> "sptr"
; lpKids : HWND* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USER32.dll" #cfunc global CascadeWindows "CascadeWindows" sptr, int, var, int, sptr ; res = CascadeWindows(hwndParent, wHow, lpRect, cKids, lpKids) ; hwndParent : HWND optional -> "sptr" ; wHow : CASCADE_WINDOWS_HOW -> "int" ; lpRect : RECT* optional -> "var" ; cKids : DWORD -> "int" ; lpKids : HWND* optional -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USER32.dll" #cfunc global CascadeWindows "CascadeWindows" sptr, int, sptr, int, sptr ; res = CascadeWindows(hwndParent, wHow, varptr(lpRect), cKids, lpKids) ; hwndParent : HWND optional -> "sptr" ; wHow : CASCADE_WINDOWS_HOW -> "int" ; lpRect : RECT* optional -> "sptr" ; cKids : DWORD -> "int" ; lpKids : HWND* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; WORD CascadeWindows(HWND hwndParent, CASCADE_WINDOWS_HOW wHow, RECT* lpRect, DWORD cKids, HWND* lpKids) #uselib "USER32.dll" #cfunc global CascadeWindows "CascadeWindows" intptr, int, var, int, intptr ; res = CascadeWindows(hwndParent, wHow, lpRect, cKids, lpKids) ; hwndParent : HWND optional -> "intptr" ; wHow : CASCADE_WINDOWS_HOW -> "int" ; lpRect : RECT* optional -> "var" ; cKids : DWORD -> "int" ; lpKids : HWND* optional -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; WORD CascadeWindows(HWND hwndParent, CASCADE_WINDOWS_HOW wHow, RECT* lpRect, DWORD cKids, HWND* lpKids) #uselib "USER32.dll" #cfunc global CascadeWindows "CascadeWindows" intptr, int, intptr, int, intptr ; res = CascadeWindows(hwndParent, wHow, varptr(lpRect), cKids, lpKids) ; hwndParent : HWND optional -> "intptr" ; wHow : CASCADE_WINDOWS_HOW -> "int" ; lpRect : RECT* optional -> "intptr" ; cKids : DWORD -> "int" ; lpKids : HWND* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procCascadeWindows = user32.NewProc("CascadeWindows")
)
// hwndParent (HWND optional), wHow (CASCADE_WINDOWS_HOW), lpRect (RECT* optional), cKids (DWORD), lpKids (HWND* optional)
r1, _, err := procCascadeWindows.Call(
uintptr(hwndParent),
uintptr(wHow),
uintptr(lpRect),
uintptr(cKids),
uintptr(lpKids),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WORDfunction CascadeWindows(
hwndParent: THandle; // HWND optional
wHow: DWORD; // CASCADE_WINDOWS_HOW
lpRect: Pointer; // RECT* optional
cKids: DWORD; // DWORD
lpKids: Pointer // HWND* optional
): Word; stdcall;
external 'USER32.dll' name 'CascadeWindows';result := DllCall("USER32\CascadeWindows"
, "Ptr", hwndParent ; HWND optional
, "UInt", wHow ; CASCADE_WINDOWS_HOW
, "Ptr", lpRect ; RECT* optional
, "UInt", cKids ; DWORD
, "Ptr", lpKids ; HWND* optional
, "UShort") ; return: WORD●CascadeWindows(hwndParent, wHow, lpRect, cKids, lpKids) = DLL("USER32.dll", "int CascadeWindows(void*, dword, void*, dword, void*)")
# 呼び出し: CascadeWindows(hwndParent, wHow, lpRect, cKids, lpKids)
# hwndParent : HWND optional -> "void*"
# wHow : CASCADE_WINDOWS_HOW -> "dword"
# lpRect : RECT* optional -> "void*"
# cKids : DWORD -> "dword"
# lpKids : HWND* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。