ホーム › UI.Controls › GetEffectiveClientRect
GetEffectiveClientRect
関数指定コントロールを除いた有効クライアント領域を計算する。
シグネチャ
// COMCTL32.dll
#include <windows.h>
void GetEffectiveClientRect(
HWND hWnd,
RECT* lprc,
const INT* lpInfo
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hWnd | HWND | in | 対象となるクライアント領域を持つウィンドウへのハンドル。 |
| lprc | RECT* | out | 矩形の寸法を受け取る RECT 構造体へのポインター。 |
| lpInfo | INT* | in | クライアント領域内のコントロールを識別する、null 終端の整数配列へのポインター。各コントロールには連続する 2 つの要素のペアが必要です。ペアの最初の要素は 0 以外でなければならず、2 番目の要素はコントロール識別子でなければなりません。最初のペアはメニューを表し、無視されます。配列の終端を示すため、最後の要素は 0 でなければなりません。 |
戻り値の型: void
公式ドキュメント
指定したすべてのコントロールを含む、クライアント領域内の矩形の寸法を計算します。
解説(Remarks)
lprc 配列内のウィンドウが表示されている場合、または親ウィンドウが表示されたときに表示される場合、そのウィンドウの矩形は実効クライアント矩形から差し引かれます。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// COMCTL32.dll
#include <windows.h>
void GetEffectiveClientRect(
HWND hWnd,
RECT* lprc,
const INT* lpInfo
);[DllImport("COMCTL32.dll", ExactSpelling = true)]
static extern void GetEffectiveClientRect(
IntPtr hWnd, // HWND
IntPtr lprc, // RECT* out
ref int lpInfo // INT*
);<DllImport("COMCTL32.dll", ExactSpelling:=True)>
Public Shared Sub GetEffectiveClientRect(
hWnd As IntPtr, ' HWND
lprc As IntPtr, ' RECT* out
ByRef lpInfo As Integer ' INT*
)
End Sub' hWnd : HWND
' lprc : RECT* out
' lpInfo : INT*
Declare PtrSafe Sub GetEffectiveClientRect Lib "comctl32" ( _
ByVal hWnd As LongPtr, _
ByVal lprc As LongPtr, _
ByRef lpInfo As Long)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetEffectiveClientRect = ctypes.windll.comctl32.GetEffectiveClientRect
GetEffectiveClientRect.restype = None
GetEffectiveClientRect.argtypes = [
wintypes.HANDLE, # hWnd : HWND
ctypes.c_void_p, # lprc : RECT* out
ctypes.POINTER(ctypes.c_int), # lpInfo : INT*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('COMCTL32.dll')
GetEffectiveClientRect = Fiddle::Function.new(
lib['GetEffectiveClientRect'],
[
Fiddle::TYPE_VOIDP, # hWnd : HWND
Fiddle::TYPE_VOIDP, # lprc : RECT* out
Fiddle::TYPE_VOIDP, # lpInfo : INT*
],
Fiddle::TYPE_VOID)#[link(name = "comctl32")]
extern "system" {
fn GetEffectiveClientRect(
hWnd: *mut core::ffi::c_void, // HWND
lprc: *mut RECT, // RECT* out
lpInfo: *const i32 // INT*
);
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("COMCTL32.dll")]
public static extern void GetEffectiveClientRect(IntPtr hWnd, IntPtr lprc, ref int lpInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'COMCTL32_GetEffectiveClientRect' -Namespace Win32 -PassThru
# $api::GetEffectiveClientRect(hWnd, lprc, lpInfo)#uselib "COMCTL32.dll"
#func global GetEffectiveClientRect "GetEffectiveClientRect" sptr, sptr, sptr
; GetEffectiveClientRect hWnd, varptr(lprc), varptr(lpInfo)
; hWnd : HWND -> "sptr"
; lprc : RECT* out -> "sptr"
; lpInfo : INT* -> "sptr"出力引数:
#uselib "COMCTL32.dll" #func global GetEffectiveClientRect "GetEffectiveClientRect" sptr, var, var ; GetEffectiveClientRect hWnd, lprc, lpInfo ; hWnd : HWND -> "sptr" ; lprc : RECT* out -> "var" ; lpInfo : INT* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "COMCTL32.dll" #func global GetEffectiveClientRect "GetEffectiveClientRect" sptr, sptr, sptr ; GetEffectiveClientRect hWnd, varptr(lprc), varptr(lpInfo) ; hWnd : HWND -> "sptr" ; lprc : RECT* out -> "sptr" ; lpInfo : INT* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void GetEffectiveClientRect(HWND hWnd, RECT* lprc, INT* lpInfo) #uselib "COMCTL32.dll" #func global GetEffectiveClientRect "GetEffectiveClientRect" intptr, var, var ; GetEffectiveClientRect hWnd, lprc, lpInfo ; hWnd : HWND -> "intptr" ; lprc : RECT* out -> "var" ; lpInfo : INT* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; void GetEffectiveClientRect(HWND hWnd, RECT* lprc, INT* lpInfo) #uselib "COMCTL32.dll" #func global GetEffectiveClientRect "GetEffectiveClientRect" intptr, intptr, intptr ; GetEffectiveClientRect hWnd, varptr(lprc), varptr(lpInfo) ; hWnd : HWND -> "intptr" ; lprc : RECT* out -> "intptr" ; lpInfo : INT* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
comctl32 = windows.NewLazySystemDLL("COMCTL32.dll")
procGetEffectiveClientRect = comctl32.NewProc("GetEffectiveClientRect")
)
// hWnd (HWND), lprc (RECT* out), lpInfo (INT*)
r1, _, err := procGetEffectiveClientRect.Call(
uintptr(hWnd),
uintptr(lprc),
uintptr(lpInfo),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // voidprocedure GetEffectiveClientRect(
hWnd: THandle; // HWND
lprc: Pointer; // RECT* out
lpInfo: Pointer // INT*
); stdcall;
external 'COMCTL32.dll' name 'GetEffectiveClientRect';result := DllCall("COMCTL32\GetEffectiveClientRect"
, "Ptr", hWnd ; HWND
, "Ptr", lprc ; RECT* out
, "Ptr", lpInfo ; INT*
, "Int") ; return: void●GetEffectiveClientRect(hWnd, lprc, lpInfo) = DLL("COMCTL32.dll", "int GetEffectiveClientRect(void*, void*, void*)")
# 呼び出し: GetEffectiveClientRect(hWnd, lprc, lpInfo)
# hWnd : HWND -> "void*"
# lprc : RECT* out -> "void*"
# lpInfo : INT* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "comctl32" fn GetEffectiveClientRect(
hWnd: ?*anyopaque, // HWND
lprc: [*c]RECT, // RECT* out
lpInfo: [*c]i32 // INT*
) callconv(std.os.windows.WINAPI) void;proc GetEffectiveClientRect(
hWnd: pointer, # HWND
lprc: ptr RECT, # RECT* out
lpInfo: ptr int32 # INT*
) {.importc: "GetEffectiveClientRect", stdcall, dynlib: "COMCTL32.dll".}pragma(lib, "comctl32");
extern(Windows)
void GetEffectiveClientRect(
void* hWnd, // HWND
RECT* lprc, // RECT* out
int* lpInfo // INT*
);ccall((:GetEffectiveClientRect, "COMCTL32.dll"), stdcall, Cvoid,
(Ptr{Cvoid}, Ptr{RECT}, Ptr{Int32}),
hWnd, lprc, lpInfo)
# hWnd : HWND -> Ptr{Cvoid}
# lprc : RECT* out -> Ptr{RECT}
# lpInfo : INT* -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void GetEffectiveClientRect(
void* hWnd,
void* lprc,
int32_t* lpInfo);
]]
local comctl32 = ffi.load("comctl32")
-- comctl32.GetEffectiveClientRect(hWnd, lprc, lpInfo)
-- hWnd : HWND
-- lprc : RECT* out
-- lpInfo : INT*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('COMCTL32.dll');
const GetEffectiveClientRect = lib.func('__stdcall', 'GetEffectiveClientRect', 'void', ['void *', 'void *', 'int32_t *']);
// GetEffectiveClientRect(hWnd, lprc, lpInfo)
// hWnd : HWND -> 'void *'
// lprc : RECT* out -> 'void *'
// lpInfo : INT* -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("COMCTL32.dll", {
GetEffectiveClientRect: { parameters: ["pointer", "pointer", "pointer"], result: "void" },
});
// lib.symbols.GetEffectiveClientRect(hWnd, lprc, lpInfo)
// hWnd : HWND -> "pointer"
// lprc : RECT* out -> "pointer"
// lpInfo : INT* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void GetEffectiveClientRect(
void* hWnd,
void* lprc,
int32_t* lpInfo);
C, "COMCTL32.dll");
// $ffi->GetEffectiveClientRect(hWnd, lprc, lpInfo);
// hWnd : HWND
// lprc : RECT* out
// lpInfo : INT*
// 構造体/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 Comctl32 extends StdCallLibrary {
Comctl32 INSTANCE = Native.load("comctl32", Comctl32.class);
void GetEffectiveClientRect(
Pointer hWnd, // HWND
Pointer lprc, // RECT* out
IntByReference lpInfo // INT*
);
}@[Link("comctl32")]
lib LibCOMCTL32
fun GetEffectiveClientRect = GetEffectiveClientRect(
hWnd : Void*, # HWND
lprc : RECT*, # RECT* out
lpInfo : Int32* # INT*
) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetEffectiveClientRectNative = Void Function(Pointer<Void>, Pointer<Void>, Pointer<Int32>);
typedef GetEffectiveClientRectDart = void Function(Pointer<Void>, Pointer<Void>, Pointer<Int32>);
final GetEffectiveClientRect = DynamicLibrary.open('COMCTL32.dll')
.lookupFunction<GetEffectiveClientRectNative, GetEffectiveClientRectDart>('GetEffectiveClientRect');
// hWnd : HWND -> Pointer<Void>
// lprc : RECT* out -> Pointer<Void>
// lpInfo : INT* -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
procedure GetEffectiveClientRect(
hWnd: THandle; // HWND
lprc: Pointer; // RECT* out
lpInfo: Pointer // INT*
); stdcall;
external 'COMCTL32.dll' name 'GetEffectiveClientRect';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetEffectiveClientRect"
c_GetEffectiveClientRect :: Ptr () -> Ptr () -> Ptr Int32 -> IO ()
-- hWnd : HWND -> Ptr ()
-- lprc : RECT* out -> Ptr ()
-- lpInfo : INT* -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let geteffectiveclientrect =
foreign "GetEffectiveClientRect"
((ptr void) @-> (ptr void) @-> (ptr int32_t) @-> returning void)
(* hWnd : HWND -> (ptr void) *)
(* lprc : RECT* out -> (ptr void) *)
(* lpInfo : INT* -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library comctl32 (t "COMCTL32.dll"))
(cffi:use-foreign-library comctl32)
(cffi:defcfun ("GetEffectiveClientRect" get-effective-client-rect :convention :stdcall) :void
(h-wnd :pointer) ; HWND
(lprc :pointer) ; RECT* out
(lp-info :pointer)) ; INT*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetEffectiveClientRect = Win32::API::More->new('COMCTL32',
'void GetEffectiveClientRect(HANDLE hWnd, LPVOID lprc, LPVOID lpInfo)');
# my $ret = $GetEffectiveClientRect->Call($hWnd, $lprc, $lpInfo);
# hWnd : HWND -> HANDLE
# lprc : RECT* out -> LPVOID
# lpInfo : INT* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f ShowHideMenuCtl — メニュー項目に応じてコントロールの表示を切り替える。
使用する型