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