ホーム › Graphics.Gdi › SetBoundsRect
SetBoundsRect
関数DCの境界矩形の累積動作を制御する。
シグネチャ
// GDI32.dll
#include <windows.h>
DWORD SetBoundsRect(
HDC hdc,
const RECT* lprect, // optional
SET_BOUNDS_RECT_FLAGS flags
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| hdc | HDC | in | バウンディング矩形を累積する対象のデバイスコンテキストへのハンドル。 | ||||||||||
| lprect | RECT* | inoptional | バウンディング矩形を設定するために使用する RECT 構造体へのポインター。矩形の寸法は論理座標で指定します。このパラメーターには NULL を指定できます。 | ||||||||||
| flags | SET_BOUNDS_RECT_FLAGS | in | 新しい矩形を累積された矩形とどのように組み合わせるかを指定します。このパラメーターには、次の値のうち 1 つ以上を指定できます。
|
戻り値の型: DWORD
公式ドキュメント
SetBoundsRect 関数は、指定されたデバイスコンテキストに対するバウンディング矩形情報の累積を制御します。
戻り値
関数が成功した場合、戻り値はバウンディング矩形の以前の状態を示します。この状態は、次の値の組み合わせになることがあります。
| 値 | 意味 |
|---|---|
| DCB_DISABLE | 境界の累積がオフです。 |
| DCB_ENABLE | 境界の累積がオンです。DCB_ENABLE と DCB_DISABLE は相互に排他的です。 |
| DCB_RESET | バウンディング矩形が空です。 |
| DCB_SET | バウンディング矩形が空ではありません。DCB_SET と DCB_RESET は相互に排他的です。 |
関数が失敗した場合、戻り値は 0 です。
解説(Remarks)
DCB_SET 値は、ビット値 DCB_ACCUMULATE と DCB_RESET を組み合わせたものです。DCB_RESET ビットを確認してバウンディング矩形が空かどうかを判断するアプリケーションは、DCB_ACCUMULATE ビットも確認する必要があります。バウンディング矩形が空であるのは、DCB_RESET ビットが 1 かつ DCB_ACCUMULATE ビットが 0 の場合のみです。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// GDI32.dll
#include <windows.h>
DWORD SetBoundsRect(
HDC hdc,
const RECT* lprect, // optional
SET_BOUNDS_RECT_FLAGS flags
);[DllImport("GDI32.dll", ExactSpelling = true)]
static extern uint SetBoundsRect(
IntPtr hdc, // HDC
IntPtr lprect, // RECT* optional
uint flags // SET_BOUNDS_RECT_FLAGS
);<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function SetBoundsRect(
hdc As IntPtr, ' HDC
lprect As IntPtr, ' RECT* optional
flags As UInteger ' SET_BOUNDS_RECT_FLAGS
) As UInteger
End Function' hdc : HDC
' lprect : RECT* optional
' flags : SET_BOUNDS_RECT_FLAGS
Declare PtrSafe Function SetBoundsRect Lib "gdi32" ( _
ByVal hdc As LongPtr, _
ByVal lprect As LongPtr, _
ByVal flags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetBoundsRect = ctypes.windll.gdi32.SetBoundsRect
SetBoundsRect.restype = wintypes.DWORD
SetBoundsRect.argtypes = [
wintypes.HANDLE, # hdc : HDC
ctypes.c_void_p, # lprect : RECT* optional
wintypes.DWORD, # flags : SET_BOUNDS_RECT_FLAGS
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GDI32.dll')
SetBoundsRect = Fiddle::Function.new(
lib['SetBoundsRect'],
[
Fiddle::TYPE_VOIDP, # hdc : HDC
Fiddle::TYPE_VOIDP, # lprect : RECT* optional
-Fiddle::TYPE_INT, # flags : SET_BOUNDS_RECT_FLAGS
],
-Fiddle::TYPE_INT)#[link(name = "gdi32")]
extern "system" {
fn SetBoundsRect(
hdc: *mut core::ffi::c_void, // HDC
lprect: *const RECT, // RECT* optional
flags: u32 // SET_BOUNDS_RECT_FLAGS
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("GDI32.dll")]
public static extern uint SetBoundsRect(IntPtr hdc, IntPtr lprect, uint flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_SetBoundsRect' -Namespace Win32 -PassThru
# $api::SetBoundsRect(hdc, lprect, flags)#uselib "GDI32.dll"
#func global SetBoundsRect "SetBoundsRect" sptr, sptr, sptr
; SetBoundsRect hdc, varptr(lprect), flags ; 戻り値は stat
; hdc : HDC -> "sptr"
; lprect : RECT* optional -> "sptr"
; flags : SET_BOUNDS_RECT_FLAGS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "GDI32.dll" #cfunc global SetBoundsRect "SetBoundsRect" sptr, var, int ; res = SetBoundsRect(hdc, lprect, flags) ; hdc : HDC -> "sptr" ; lprect : RECT* optional -> "var" ; flags : SET_BOUNDS_RECT_FLAGS -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "GDI32.dll" #cfunc global SetBoundsRect "SetBoundsRect" sptr, sptr, int ; res = SetBoundsRect(hdc, varptr(lprect), flags) ; hdc : HDC -> "sptr" ; lprect : RECT* optional -> "sptr" ; flags : SET_BOUNDS_RECT_FLAGS -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD SetBoundsRect(HDC hdc, RECT* lprect, SET_BOUNDS_RECT_FLAGS flags) #uselib "GDI32.dll" #cfunc global SetBoundsRect "SetBoundsRect" intptr, var, int ; res = SetBoundsRect(hdc, lprect, flags) ; hdc : HDC -> "intptr" ; lprect : RECT* optional -> "var" ; flags : SET_BOUNDS_RECT_FLAGS -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD SetBoundsRect(HDC hdc, RECT* lprect, SET_BOUNDS_RECT_FLAGS flags) #uselib "GDI32.dll" #cfunc global SetBoundsRect "SetBoundsRect" intptr, intptr, int ; res = SetBoundsRect(hdc, varptr(lprect), flags) ; hdc : HDC -> "intptr" ; lprect : RECT* optional -> "intptr" ; flags : SET_BOUNDS_RECT_FLAGS -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdi32 = windows.NewLazySystemDLL("GDI32.dll")
procSetBoundsRect = gdi32.NewProc("SetBoundsRect")
)
// hdc (HDC), lprect (RECT* optional), flags (SET_BOUNDS_RECT_FLAGS)
r1, _, err := procSetBoundsRect.Call(
uintptr(hdc),
uintptr(lprect),
uintptr(flags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction SetBoundsRect(
hdc: THandle; // HDC
lprect: Pointer; // RECT* optional
flags: DWORD // SET_BOUNDS_RECT_FLAGS
): DWORD; stdcall;
external 'GDI32.dll' name 'SetBoundsRect';result := DllCall("GDI32\SetBoundsRect"
, "Ptr", hdc ; HDC
, "Ptr", lprect ; RECT* optional
, "UInt", flags ; SET_BOUNDS_RECT_FLAGS
, "UInt") ; return: DWORD●SetBoundsRect(hdc, lprect, flags) = DLL("GDI32.dll", "dword SetBoundsRect(void*, void*, dword)")
# 呼び出し: SetBoundsRect(hdc, lprect, flags)
# hdc : HDC -> "void*"
# lprect : RECT* optional -> "void*"
# flags : SET_BOUNDS_RECT_FLAGS -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "gdi32" fn SetBoundsRect(
hdc: ?*anyopaque, // HDC
lprect: [*c]RECT, // RECT* optional
flags: u32 // SET_BOUNDS_RECT_FLAGS
) callconv(std.os.windows.WINAPI) u32;proc SetBoundsRect(
hdc: pointer, # HDC
lprect: ptr RECT, # RECT* optional
flags: uint32 # SET_BOUNDS_RECT_FLAGS
): uint32 {.importc: "SetBoundsRect", stdcall, dynlib: "GDI32.dll".}pragma(lib, "gdi32");
extern(Windows)
uint SetBoundsRect(
void* hdc, // HDC
RECT* lprect, // RECT* optional
uint flags // SET_BOUNDS_RECT_FLAGS
);ccall((:SetBoundsRect, "GDI32.dll"), stdcall, UInt32,
(Ptr{Cvoid}, Ptr{RECT}, UInt32),
hdc, lprect, flags)
# hdc : HDC -> Ptr{Cvoid}
# lprect : RECT* optional -> Ptr{RECT}
# flags : SET_BOUNDS_RECT_FLAGS -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t SetBoundsRect(
void* hdc,
void* lprect,
uint32_t flags);
]]
local gdi32 = ffi.load("gdi32")
-- gdi32.SetBoundsRect(hdc, lprect, flags)
-- hdc : HDC
-- lprect : RECT* optional
-- flags : SET_BOUNDS_RECT_FLAGS
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('GDI32.dll');
const SetBoundsRect = lib.func('__stdcall', 'SetBoundsRect', 'uint32_t', ['void *', 'void *', 'uint32_t']);
// SetBoundsRect(hdc, lprect, flags)
// hdc : HDC -> 'void *'
// lprect : RECT* optional -> 'void *'
// flags : SET_BOUNDS_RECT_FLAGS -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("GDI32.dll", {
SetBoundsRect: { parameters: ["pointer", "pointer", "u32"], result: "u32" },
});
// lib.symbols.SetBoundsRect(hdc, lprect, flags)
// hdc : HDC -> "pointer"
// lprect : RECT* optional -> "pointer"
// flags : SET_BOUNDS_RECT_FLAGS -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t SetBoundsRect(
void* hdc,
void* lprect,
uint32_t flags);
C, "GDI32.dll");
// $ffi->SetBoundsRect(hdc, lprect, flags);
// hdc : HDC
// lprect : RECT* optional
// flags : SET_BOUNDS_RECT_FLAGS
// 構造体/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 Gdi32 extends StdCallLibrary {
Gdi32 INSTANCE = Native.load("gdi32", Gdi32.class);
int SetBoundsRect(
Pointer hdc, // HDC
Pointer lprect, // RECT* optional
int flags // SET_BOUNDS_RECT_FLAGS
);
}@[Link("gdi32")]
lib LibGDI32
fun SetBoundsRect = SetBoundsRect(
hdc : Void*, # HDC
lprect : RECT*, # RECT* optional
flags : UInt32 # SET_BOUNDS_RECT_FLAGS
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SetBoundsRectNative = Uint32 Function(Pointer<Void>, Pointer<Void>, Uint32);
typedef SetBoundsRectDart = int Function(Pointer<Void>, Pointer<Void>, int);
final SetBoundsRect = DynamicLibrary.open('GDI32.dll')
.lookupFunction<SetBoundsRectNative, SetBoundsRectDart>('SetBoundsRect');
// hdc : HDC -> Pointer<Void>
// lprect : RECT* optional -> Pointer<Void>
// flags : SET_BOUNDS_RECT_FLAGS -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SetBoundsRect(
hdc: THandle; // HDC
lprect: Pointer; // RECT* optional
flags: DWORD // SET_BOUNDS_RECT_FLAGS
): DWORD; stdcall;
external 'GDI32.dll' name 'SetBoundsRect';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetBoundsRect"
c_SetBoundsRect :: Ptr () -> Ptr () -> Word32 -> IO Word32
-- hdc : HDC -> Ptr ()
-- lprect : RECT* optional -> Ptr ()
-- flags : SET_BOUNDS_RECT_FLAGS -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setboundsrect =
foreign "SetBoundsRect"
((ptr void) @-> (ptr void) @-> uint32_t @-> returning uint32_t)
(* hdc : HDC -> (ptr void) *)
(* lprect : RECT* optional -> (ptr void) *)
(* flags : SET_BOUNDS_RECT_FLAGS -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library gdi32 (t "GDI32.dll"))
(cffi:use-foreign-library gdi32)
(cffi:defcfun ("SetBoundsRect" set-bounds-rect :convention :stdcall) :uint32
(hdc :pointer) ; HDC
(lprect :pointer) ; RECT* optional
(flags :uint32)) ; SET_BOUNDS_RECT_FLAGS
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetBoundsRect = Win32::API::More->new('GDI32',
'DWORD SetBoundsRect(HANDLE hdc, LPVOID lprect, DWORD flags)');
# my $ret = $SetBoundsRect->Call($hdc, $lprect, $flags);
# hdc : HDC -> HANDLE
# lprect : RECT* optional -> LPVOID
# flags : SET_BOUNDS_RECT_FLAGS -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f GetBoundsRect — DCの累積描画境界矩形を取得する。