ホーム › Graphics.Gdi › GetWindowRgnBox
GetWindowRgnBox
関数ウィンドウリージョンの外接矩形を取得する。
シグネチャ
// USER32.dll
#include <windows.h>
GDI_REGION_TYPE GetWindowRgnBox(
HWND hWnd,
RECT* lprc
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hWnd | HWND | in |
| lprc | RECT* | out |
戻り値の型: GDI_REGION_TYPE
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
GDI_REGION_TYPE GetWindowRgnBox(
HWND hWnd,
RECT* lprc
);[DllImport("USER32.dll", ExactSpelling = true)]
static extern int GetWindowRgnBox(
IntPtr hWnd, // HWND
IntPtr lprc // RECT* out
);<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function GetWindowRgnBox(
hWnd As IntPtr, ' HWND
lprc As IntPtr ' RECT* out
) As Integer
End Function' hWnd : HWND
' lprc : RECT* out
Declare PtrSafe Function GetWindowRgnBox Lib "user32" ( _
ByVal hWnd As LongPtr, _
ByVal lprc As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetWindowRgnBox = ctypes.windll.user32.GetWindowRgnBox
GetWindowRgnBox.restype = ctypes.c_int
GetWindowRgnBox.argtypes = [
wintypes.HANDLE, # hWnd : HWND
ctypes.c_void_p, # lprc : RECT* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
GetWindowRgnBox = Fiddle::Function.new(
lib['GetWindowRgnBox'],
[
Fiddle::TYPE_VOIDP, # hWnd : HWND
Fiddle::TYPE_VOIDP, # lprc : RECT* out
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn GetWindowRgnBox(
hWnd: *mut core::ffi::c_void, // HWND
lprc: *mut RECT // RECT* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("USER32.dll")]
public static extern int GetWindowRgnBox(IntPtr hWnd, IntPtr lprc);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_GetWindowRgnBox' -Namespace Win32 -PassThru
# $api::GetWindowRgnBox(hWnd, lprc)#uselib "USER32.dll"
#func global GetWindowRgnBox "GetWindowRgnBox" sptr, sptr
; GetWindowRgnBox hWnd, varptr(lprc) ; 戻り値は stat
; hWnd : HWND -> "sptr"
; lprc : RECT* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USER32.dll" #cfunc global GetWindowRgnBox "GetWindowRgnBox" sptr, var ; res = GetWindowRgnBox(hWnd, lprc) ; hWnd : HWND -> "sptr" ; lprc : RECT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USER32.dll" #cfunc global GetWindowRgnBox "GetWindowRgnBox" sptr, sptr ; res = GetWindowRgnBox(hWnd, varptr(lprc)) ; hWnd : HWND -> "sptr" ; lprc : RECT* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; GDI_REGION_TYPE GetWindowRgnBox(HWND hWnd, RECT* lprc) #uselib "USER32.dll" #cfunc global GetWindowRgnBox "GetWindowRgnBox" intptr, var ; res = GetWindowRgnBox(hWnd, lprc) ; hWnd : HWND -> "intptr" ; lprc : RECT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; GDI_REGION_TYPE GetWindowRgnBox(HWND hWnd, RECT* lprc) #uselib "USER32.dll" #cfunc global GetWindowRgnBox "GetWindowRgnBox" intptr, intptr ; res = GetWindowRgnBox(hWnd, varptr(lprc)) ; hWnd : HWND -> "intptr" ; lprc : RECT* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procGetWindowRgnBox = user32.NewProc("GetWindowRgnBox")
)
// hWnd (HWND), lprc (RECT* out)
r1, _, err := procGetWindowRgnBox.Call(
uintptr(hWnd),
uintptr(lprc),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // GDI_REGION_TYPEfunction GetWindowRgnBox(
hWnd: THandle; // HWND
lprc: Pointer // RECT* out
): Integer; stdcall;
external 'USER32.dll' name 'GetWindowRgnBox';result := DllCall("USER32\GetWindowRgnBox"
, "Ptr", hWnd ; HWND
, "Ptr", lprc ; RECT* out
, "Int") ; return: GDI_REGION_TYPE●GetWindowRgnBox(hWnd, lprc) = DLL("USER32.dll", "int GetWindowRgnBox(void*, void*)")
# 呼び出し: GetWindowRgnBox(hWnd, lprc)
# hWnd : HWND -> "void*"
# lprc : RECT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。