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