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

RoundRect

関数
角が丸い矩形を描画する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL RoundRect(
    HDC hdc,
    INT left,
    INT top,
    INT right,
    INT bottom,
    INT width,
    INT height
);

パラメーター

名前方向
hdcHDCin
leftINTin
topINTin
rightINTin
bottomINTin
widthINTin
heightINTin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL RoundRect(
    HDC hdc,
    INT left,
    INT top,
    INT right,
    INT bottom,
    INT width,
    INT height
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern bool RoundRect(
    IntPtr hdc,   // HDC
    int left,   // INT
    int top,   // INT
    int right,   // INT
    int bottom,   // INT
    int width,   // INT
    int height   // INT
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function RoundRect(
    hdc As IntPtr,   ' HDC
    left As Integer,   ' INT
    top As Integer,   ' INT
    right As Integer,   ' INT
    bottom As Integer,   ' INT
    width As Integer,   ' INT
    height As Integer   ' INT
) As Boolean
End Function
' hdc : HDC
' left : INT
' top : INT
' right : INT
' bottom : INT
' width : INT
' height : INT
Declare PtrSafe Function RoundRect Lib "gdi32" ( _
    ByVal hdc As LongPtr, _
    ByVal left As Long, _
    ByVal top As Long, _
    ByVal right As Long, _
    ByVal bottom As Long, _
    ByVal width As Long, _
    ByVal height As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RoundRect = ctypes.windll.gdi32.RoundRect
RoundRect.restype = wintypes.BOOL
RoundRect.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    ctypes.c_int,  # left : INT
    ctypes.c_int,  # top : INT
    ctypes.c_int,  # right : INT
    ctypes.c_int,  # bottom : INT
    ctypes.c_int,  # width : INT
    ctypes.c_int,  # height : INT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
RoundRect = Fiddle::Function.new(
  lib['RoundRect'],
  [
    Fiddle::TYPE_VOIDP,  # hdc : HDC
    Fiddle::TYPE_INT,  # left : INT
    Fiddle::TYPE_INT,  # top : INT
    Fiddle::TYPE_INT,  # right : INT
    Fiddle::TYPE_INT,  # bottom : INT
    Fiddle::TYPE_INT,  # width : INT
    Fiddle::TYPE_INT,  # height : INT
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdi32")]
extern "system" {
    fn RoundRect(
        hdc: *mut core::ffi::c_void,  // HDC
        left: i32,  // INT
        top: i32,  // INT
        right: i32,  // INT
        bottom: i32,  // INT
        width: i32,  // INT
        height: i32  // INT
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll")]
public static extern bool RoundRect(IntPtr hdc, int left, int top, int right, int bottom, int width, int height);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_RoundRect' -Namespace Win32 -PassThru
# $api::RoundRect(hdc, left, top, right, bottom, width, height)
#uselib "GDI32.dll"
#func global RoundRect "RoundRect" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; RoundRect hdc, left, top, right, bottom, width, height   ; 戻り値は stat
; hdc : HDC -> "sptr"
; left : INT -> "sptr"
; top : INT -> "sptr"
; right : INT -> "sptr"
; bottom : INT -> "sptr"
; width : INT -> "sptr"
; height : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "GDI32.dll"
#cfunc global RoundRect "RoundRect" sptr, int, int, int, int, int, int
; res = RoundRect(hdc, left, top, right, bottom, width, height)
; hdc : HDC -> "sptr"
; left : INT -> "int"
; top : INT -> "int"
; right : INT -> "int"
; bottom : INT -> "int"
; width : INT -> "int"
; height : INT -> "int"
; BOOL RoundRect(HDC hdc, INT left, INT top, INT right, INT bottom, INT width, INT height)
#uselib "GDI32.dll"
#cfunc global RoundRect "RoundRect" intptr, int, int, int, int, int, int
; res = RoundRect(hdc, left, top, right, bottom, width, height)
; hdc : HDC -> "intptr"
; left : INT -> "int"
; top : INT -> "int"
; right : INT -> "int"
; bottom : INT -> "int"
; width : INT -> "int"
; height : INT -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procRoundRect = gdi32.NewProc("RoundRect")
)

// hdc (HDC), left (INT), top (INT), right (INT), bottom (INT), width (INT), height (INT)
r1, _, err := procRoundRect.Call(
	uintptr(hdc),
	uintptr(left),
	uintptr(top),
	uintptr(right),
	uintptr(bottom),
	uintptr(width),
	uintptr(height),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function RoundRect(
  hdc: THandle;   // HDC
  left: Integer;   // INT
  top: Integer;   // INT
  right: Integer;   // INT
  bottom: Integer;   // INT
  width: Integer;   // INT
  height: Integer   // INT
): BOOL; stdcall;
  external 'GDI32.dll' name 'RoundRect';
result := DllCall("GDI32\RoundRect"
    , "Ptr", hdc   ; HDC
    , "Int", left   ; INT
    , "Int", top   ; INT
    , "Int", right   ; INT
    , "Int", bottom   ; INT
    , "Int", width   ; INT
    , "Int", height   ; INT
    , "Int")   ; return: BOOL
●RoundRect(hdc, left, top, right, bottom, width, height) = DLL("GDI32.dll", "bool RoundRect(void*, int, int, int, int, int, int)")
# 呼び出し: RoundRect(hdc, left, top, right, bottom, width, height)
# hdc : HDC -> "void*"
# left : INT -> "int"
# top : INT -> "int"
# right : INT -> "int"
# bottom : INT -> "int"
# width : INT -> "int"
# height : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。