Win32 API 日本語リファレンス
ホームGraphics.GdiPlus › GdipDrawRectangles

GdipDrawRectangles

関数
指定ペンで複数の矩形枠線を描画する。
DLLgdiplus.dll呼出規約winapi

シグネチャ

// gdiplus.dll
#include <windows.h>

Status GdipDrawRectangles(
    GpGraphics* graphics,
    GpPen* pen,
    const RectF* rects,
    INT count
);

パラメーター

名前方向
graphicsGpGraphics*inout
penGpPen*inout
rectsRectF*in
countINTin

戻り値の型: Status

各言語での呼び出し定義

// gdiplus.dll
#include <windows.h>

Status GdipDrawRectangles(
    GpGraphics* graphics,
    GpPen* pen,
    const RectF* rects,
    INT count
);
[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipDrawRectangles(
    IntPtr graphics,   // GpGraphics* in/out
    IntPtr pen,   // GpPen* in/out
    IntPtr rects,   // RectF*
    int count   // INT
);
<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipDrawRectangles(
    graphics As IntPtr,   ' GpGraphics* in/out
    pen As IntPtr,   ' GpPen* in/out
    rects As IntPtr,   ' RectF*
    count As Integer   ' INT
) As Integer
End Function
' graphics : GpGraphics* in/out
' pen : GpPen* in/out
' rects : RectF*
' count : INT
Declare PtrSafe Function GdipDrawRectangles Lib "gdiplus" ( _
    ByVal graphics As LongPtr, _
    ByVal pen As LongPtr, _
    ByVal rects As LongPtr, _
    ByVal count As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GdipDrawRectangles = ctypes.windll.gdiplus.GdipDrawRectangles
GdipDrawRectangles.restype = ctypes.c_int
GdipDrawRectangles.argtypes = [
    ctypes.c_void_p,  # graphics : GpGraphics* in/out
    ctypes.c_void_p,  # pen : GpPen* in/out
    ctypes.c_void_p,  # rects : RectF*
    ctypes.c_int,  # count : INT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('gdiplus.dll')
GdipDrawRectangles = Fiddle::Function.new(
  lib['GdipDrawRectangles'],
  [
    Fiddle::TYPE_VOIDP,  # graphics : GpGraphics* in/out
    Fiddle::TYPE_VOIDP,  # pen : GpPen* in/out
    Fiddle::TYPE_VOIDP,  # rects : RectF*
    Fiddle::TYPE_INT,  # count : INT
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdiplus")]
extern "system" {
    fn GdipDrawRectangles(
        graphics: *mut GpGraphics,  // GpGraphics* in/out
        pen: *mut GpPen,  // GpPen* in/out
        rects: *const RectF,  // RectF*
        count: i32  // INT
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("gdiplus.dll")]
public static extern int GdipDrawRectangles(IntPtr graphics, IntPtr pen, IntPtr rects, int count);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipDrawRectangles' -Namespace Win32 -PassThru
# $api::GdipDrawRectangles(graphics, pen, rects, count)
#uselib "gdiplus.dll"
#func global GdipDrawRectangles "GdipDrawRectangles" sptr, sptr, sptr, sptr
; GdipDrawRectangles varptr(graphics), varptr(pen), varptr(rects), count   ; 戻り値は stat
; graphics : GpGraphics* in/out -> "sptr"
; pen : GpPen* in/out -> "sptr"
; rects : RectF* -> "sptr"
; count : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "gdiplus.dll"
#cfunc global GdipDrawRectangles "GdipDrawRectangles" var, var, var, int
; res = GdipDrawRectangles(graphics, pen, rects, count)
; graphics : GpGraphics* in/out -> "var"
; pen : GpPen* in/out -> "var"
; rects : RectF* -> "var"
; count : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; Status GdipDrawRectangles(GpGraphics* graphics, GpPen* pen, RectF* rects, INT count)
#uselib "gdiplus.dll"
#cfunc global GdipDrawRectangles "GdipDrawRectangles" var, var, var, int
; res = GdipDrawRectangles(graphics, pen, rects, count)
; graphics : GpGraphics* in/out -> "var"
; pen : GpPen* in/out -> "var"
; rects : RectF* -> "var"
; count : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
	procGdipDrawRectangles = gdiplus.NewProc("GdipDrawRectangles")
)

// graphics (GpGraphics* in/out), pen (GpPen* in/out), rects (RectF*), count (INT)
r1, _, err := procGdipDrawRectangles.Call(
	uintptr(graphics),
	uintptr(pen),
	uintptr(rects),
	uintptr(count),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // Status
function GdipDrawRectangles(
  graphics: Pointer;   // GpGraphics* in/out
  pen: Pointer;   // GpPen* in/out
  rects: Pointer;   // RectF*
  count: Integer   // INT
): Integer; stdcall;
  external 'gdiplus.dll' name 'GdipDrawRectangles';
result := DllCall("gdiplus\GdipDrawRectangles"
    , "Ptr", graphics   ; GpGraphics* in/out
    , "Ptr", pen   ; GpPen* in/out
    , "Ptr", rects   ; RectF*
    , "Int", count   ; INT
    , "Int")   ; return: Status
●GdipDrawRectangles(graphics, pen, rects, count) = DLL("gdiplus.dll", "int GdipDrawRectangles(void*, void*, void*, int)")
# 呼び出し: GdipDrawRectangles(graphics, pen, rects, count)
# graphics : GpGraphics* in/out -> "void*"
# pen : GpPen* in/out -> "void*"
# rects : RectF* -> "void*"
# count : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。