ホーム › UI.WindowsAndMessaging › TileWindows
TileWindows
関数指定した子ウィンドウをタイル状に並べて配置する。
シグネチャ
// USER32.dll
#include <windows.h>
WORD TileWindows(
HWND hwndParent, // optional
TILE_WINDOWS_HOW wHow,
const RECT* lpRect, // optional
DWORD cKids,
const HWND* lpKids // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||
|---|---|---|---|---|---|---|---|---|---|
| hwndParent | HWND | inoptional | 親ウィンドウへのハンドル。このパラメーターが NULL の場合、デスクトップウィンドウが使用されます。 | ||||||
| wHow | TILE_WINDOWS_HOW | in | タイル配置フラグ。このパラメーターには次のいずれかの値を指定できます。無効化された MDI 子ウィンドウをタイル配置の対象から除外するには、MDITILE_SKIPDISABLED と組み合わせて指定できます。
| ||||||
| lpRect | RECT* | inoptional | ウィンドウを配置する矩形領域を、クライアント座標で指定する構造体へのポインター。このパラメーターが NULL の場合、親ウィンドウのクライアント領域が使用されます。 | ||||||
| cKids | DWORD | in | lpKids パラメーターで指定する配列の要素数。lpKids が NULL の場合、このパラメーターは無視されます。 | ||||||
| lpKids | HWND* | inoptional | 配置する子ウィンドウのハンドルの配列。指定した子ウィンドウが WS_EX_TOPMOST または WS_EX_TOOLWINDOW スタイルを持つトップレベルウィンドウである場合、その子ウィンドウは配置されません。このパラメーターが NULL の場合、指定した親ウィンドウ(またはデスクトップウィンドウ)のすべての子ウィンドウが配置されます。 |
戻り値の型: WORD
公式ドキュメント
指定した親ウィンドウの指定した子ウィンドウをタイル状に並べます。
戻り値
解説(Remarks)
TileWindows を呼び出すと、最大化されているすべてのウィンドウが以前のサイズに復元されます。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
WORD TileWindows(
HWND hwndParent, // optional
TILE_WINDOWS_HOW wHow,
const RECT* lpRect, // optional
DWORD cKids,
const HWND* lpKids // optional
);[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern ushort TileWindows(
IntPtr hwndParent, // HWND optional
uint wHow, // TILE_WINDOWS_HOW
IntPtr lpRect, // RECT* optional
uint cKids, // DWORD
IntPtr lpKids // HWND* optional
);<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function TileWindows(
hwndParent As IntPtr, ' HWND optional
wHow As UInteger, ' TILE_WINDOWS_HOW
lpRect As IntPtr, ' RECT* optional
cKids As UInteger, ' DWORD
lpKids As IntPtr ' HWND* optional
) As UShort
End Function' hwndParent : HWND optional
' wHow : TILE_WINDOWS_HOW
' lpRect : RECT* optional
' cKids : DWORD
' lpKids : HWND* optional
Declare PtrSafe Function TileWindows 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
TileWindows = ctypes.windll.user32.TileWindows
TileWindows.restype = ctypes.c_ushort
TileWindows.argtypes = [
wintypes.HANDLE, # hwndParent : HWND optional
wintypes.DWORD, # wHow : TILE_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')
TileWindows = Fiddle::Function.new(
lib['TileWindows'],
[
Fiddle::TYPE_VOIDP, # hwndParent : HWND optional
-Fiddle::TYPE_INT, # wHow : TILE_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 TileWindows(
hwndParent: *mut core::ffi::c_void, // HWND optional
wHow: u32, // TILE_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 TileWindows(IntPtr hwndParent, uint wHow, IntPtr lpRect, uint cKids, IntPtr lpKids);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_TileWindows' -Namespace Win32 -PassThru
# $api::TileWindows(hwndParent, wHow, lpRect, cKids, lpKids)#uselib "USER32.dll"
#func global TileWindows "TileWindows" sptr, sptr, sptr, sptr, sptr
; TileWindows hwndParent, wHow, varptr(lpRect), cKids, lpKids ; 戻り値は stat
; hwndParent : HWND optional -> "sptr"
; wHow : TILE_WINDOWS_HOW -> "sptr"
; lpRect : RECT* optional -> "sptr"
; cKids : DWORD -> "sptr"
; lpKids : HWND* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USER32.dll" #cfunc global TileWindows "TileWindows" sptr, int, var, int, sptr ; res = TileWindows(hwndParent, wHow, lpRect, cKids, lpKids) ; hwndParent : HWND optional -> "sptr" ; wHow : TILE_WINDOWS_HOW -> "int" ; lpRect : RECT* optional -> "var" ; cKids : DWORD -> "int" ; lpKids : HWND* optional -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USER32.dll" #cfunc global TileWindows "TileWindows" sptr, int, sptr, int, sptr ; res = TileWindows(hwndParent, wHow, varptr(lpRect), cKids, lpKids) ; hwndParent : HWND optional -> "sptr" ; wHow : TILE_WINDOWS_HOW -> "int" ; lpRect : RECT* optional -> "sptr" ; cKids : DWORD -> "int" ; lpKids : HWND* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; WORD TileWindows(HWND hwndParent, TILE_WINDOWS_HOW wHow, RECT* lpRect, DWORD cKids, HWND* lpKids) #uselib "USER32.dll" #cfunc global TileWindows "TileWindows" intptr, int, var, int, intptr ; res = TileWindows(hwndParent, wHow, lpRect, cKids, lpKids) ; hwndParent : HWND optional -> "intptr" ; wHow : TILE_WINDOWS_HOW -> "int" ; lpRect : RECT* optional -> "var" ; cKids : DWORD -> "int" ; lpKids : HWND* optional -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; WORD TileWindows(HWND hwndParent, TILE_WINDOWS_HOW wHow, RECT* lpRect, DWORD cKids, HWND* lpKids) #uselib "USER32.dll" #cfunc global TileWindows "TileWindows" intptr, int, intptr, int, intptr ; res = TileWindows(hwndParent, wHow, varptr(lpRect), cKids, lpKids) ; hwndParent : HWND optional -> "intptr" ; wHow : TILE_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")
procTileWindows = user32.NewProc("TileWindows")
)
// hwndParent (HWND optional), wHow (TILE_WINDOWS_HOW), lpRect (RECT* optional), cKids (DWORD), lpKids (HWND* optional)
r1, _, err := procTileWindows.Call(
uintptr(hwndParent),
uintptr(wHow),
uintptr(lpRect),
uintptr(cKids),
uintptr(lpKids),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WORDfunction TileWindows(
hwndParent: THandle; // HWND optional
wHow: DWORD; // TILE_WINDOWS_HOW
lpRect: Pointer; // RECT* optional
cKids: DWORD; // DWORD
lpKids: Pointer // HWND* optional
): Word; stdcall;
external 'USER32.dll' name 'TileWindows';result := DllCall("USER32\TileWindows"
, "Ptr", hwndParent ; HWND optional
, "UInt", wHow ; TILE_WINDOWS_HOW
, "Ptr", lpRect ; RECT* optional
, "UInt", cKids ; DWORD
, "Ptr", lpKids ; HWND* optional
, "UShort") ; return: WORD●TileWindows(hwndParent, wHow, lpRect, cKids, lpKids) = DLL("USER32.dll", "int TileWindows(void*, dword, void*, dword, void*)")
# 呼び出し: TileWindows(hwndParent, wHow, lpRect, cKids, lpKids)
# hwndParent : HWND optional -> "void*"
# wHow : TILE_WINDOWS_HOW -> "dword"
# lpRect : RECT* optional -> "void*"
# cKids : DWORD -> "dword"
# lpKids : HWND* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "user32" fn TileWindows(
hwndParent: ?*anyopaque, // HWND optional
wHow: u32, // TILE_WINDOWS_HOW
lpRect: [*c]RECT, // RECT* optional
cKids: u32, // DWORD
lpKids: ?*anyopaque // HWND* optional
) callconv(std.os.windows.WINAPI) u16;proc TileWindows(
hwndParent: pointer, # HWND optional
wHow: uint32, # TILE_WINDOWS_HOW
lpRect: ptr RECT, # RECT* optional
cKids: uint32, # DWORD
lpKids: pointer # HWND* optional
): uint16 {.importc: "TileWindows", stdcall, dynlib: "USER32.dll".}pragma(lib, "user32");
extern(Windows)
ushort TileWindows(
void* hwndParent, // HWND optional
uint wHow, // TILE_WINDOWS_HOW
RECT* lpRect, // RECT* optional
uint cKids, // DWORD
void* lpKids // HWND* optional
);ccall((:TileWindows, "USER32.dll"), stdcall, UInt16,
(Ptr{Cvoid}, UInt32, Ptr{RECT}, UInt32, Ptr{Cvoid}),
hwndParent, wHow, lpRect, cKids, lpKids)
# hwndParent : HWND optional -> Ptr{Cvoid}
# wHow : TILE_WINDOWS_HOW -> UInt32
# lpRect : RECT* optional -> Ptr{RECT}
# cKids : DWORD -> UInt32
# lpKids : HWND* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint16_t TileWindows(
void* hwndParent,
uint32_t wHow,
void* lpRect,
uint32_t cKids,
void* lpKids);
]]
local user32 = ffi.load("user32")
-- user32.TileWindows(hwndParent, wHow, lpRect, cKids, lpKids)
-- hwndParent : HWND optional
-- wHow : TILE_WINDOWS_HOW
-- lpRect : RECT* optional
-- cKids : DWORD
-- lpKids : HWND* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('USER32.dll');
const TileWindows = lib.func('__stdcall', 'TileWindows', 'uint16_t', ['void *', 'uint32_t', 'void *', 'uint32_t', 'void *']);
// TileWindows(hwndParent, wHow, lpRect, cKids, lpKids)
// hwndParent : HWND optional -> 'void *'
// wHow : TILE_WINDOWS_HOW -> 'uint32_t'
// lpRect : RECT* optional -> 'void *'
// cKids : DWORD -> 'uint32_t'
// lpKids : HWND* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("USER32.dll", {
TileWindows: { parameters: ["pointer", "u32", "pointer", "u32", "pointer"], result: "u16" },
});
// lib.symbols.TileWindows(hwndParent, wHow, lpRect, cKids, lpKids)
// hwndParent : HWND optional -> "pointer"
// wHow : TILE_WINDOWS_HOW -> "u32"
// lpRect : RECT* optional -> "pointer"
// cKids : DWORD -> "u32"
// lpKids : HWND* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint16_t TileWindows(
void* hwndParent,
uint32_t wHow,
void* lpRect,
uint32_t cKids,
void* lpKids);
C, "USER32.dll");
// $ffi->TileWindows(hwndParent, wHow, lpRect, cKids, lpKids);
// hwndParent : HWND optional
// wHow : TILE_WINDOWS_HOW
// lpRect : RECT* optional
// cKids : DWORD
// lpKids : HWND* optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface User32 extends StdCallLibrary {
User32 INSTANCE = Native.load("user32", User32.class);
short TileWindows(
Pointer hwndParent, // HWND optional
int wHow, // TILE_WINDOWS_HOW
Pointer lpRect, // RECT* optional
int cKids, // DWORD
Pointer lpKids // HWND* optional
);
}@[Link("user32")]
lib LibUSER32
fun TileWindows = TileWindows(
hwndParent : Void*, # HWND optional
wHow : UInt32, # TILE_WINDOWS_HOW
lpRect : RECT*, # RECT* optional
cKids : UInt32, # DWORD
lpKids : Void* # HWND* optional
) : UInt16
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef TileWindowsNative = Uint16 Function(Pointer<Void>, Uint32, Pointer<Void>, Uint32, Pointer<Void>);
typedef TileWindowsDart = int Function(Pointer<Void>, int, Pointer<Void>, int, Pointer<Void>);
final TileWindows = DynamicLibrary.open('USER32.dll')
.lookupFunction<TileWindowsNative, TileWindowsDart>('TileWindows');
// hwndParent : HWND optional -> Pointer<Void>
// wHow : TILE_WINDOWS_HOW -> Uint32
// lpRect : RECT* optional -> Pointer<Void>
// cKids : DWORD -> Uint32
// lpKids : HWND* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function TileWindows(
hwndParent: THandle; // HWND optional
wHow: DWORD; // TILE_WINDOWS_HOW
lpRect: Pointer; // RECT* optional
cKids: DWORD; // DWORD
lpKids: Pointer // HWND* optional
): Word; stdcall;
external 'USER32.dll' name 'TileWindows';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "TileWindows"
c_TileWindows :: Ptr () -> Word32 -> Ptr () -> Word32 -> Ptr () -> IO Word16
-- hwndParent : HWND optional -> Ptr ()
-- wHow : TILE_WINDOWS_HOW -> Word32
-- lpRect : RECT* optional -> Ptr ()
-- cKids : DWORD -> Word32
-- lpKids : HWND* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let tilewindows =
foreign "TileWindows"
((ptr void) @-> uint32_t @-> (ptr void) @-> uint32_t @-> (ptr void) @-> returning uint16_t)
(* hwndParent : HWND optional -> (ptr void) *)
(* wHow : TILE_WINDOWS_HOW -> uint32_t *)
(* lpRect : RECT* optional -> (ptr void) *)
(* cKids : DWORD -> uint32_t *)
(* lpKids : HWND* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library user32 (t "USER32.dll"))
(cffi:use-foreign-library user32)
(cffi:defcfun ("TileWindows" tile-windows :convention :stdcall) :uint16
(hwnd-parent :pointer) ; HWND optional
(w-how :uint32) ; TILE_WINDOWS_HOW
(lp-rect :pointer) ; RECT* optional
(c-kids :uint32) ; DWORD
(lp-kids :pointer)) ; HWND* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $TileWindows = Win32::API::More->new('USER32',
'WORD TileWindows(HANDLE hwndParent, DWORD wHow, LPVOID lpRect, DWORD cKids, HANDLE lpKids)');
# my $ret = $TileWindows->Call($hwndParent, $wHow, $lpRect, $cKids, $lpKids);
# hwndParent : HWND optional -> HANDLE
# wHow : TILE_WINDOWS_HOW -> DWORD
# lpRect : RECT* optional -> LPVOID
# cKids : DWORD -> DWORD
# lpKids : HWND* optional -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f CascadeWindows — 指定した子ウィンドウを重ねて段違いに配置する。