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

DrawCaption

関数
ウィンドウのタイトルバー(キャプション)を描画する。
DLLUSER32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL DrawCaption(
    HWND hwnd,
    HDC hdc,
    const RECT* lprect,
    DRAW_CAPTION_FLAGS flags
);

パラメーター

名前方向
hwndHWNDin
hdcHDCin
lprectRECT*in
flagsDRAW_CAPTION_FLAGSin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL DrawCaption(
    HWND hwnd,
    HDC hdc,
    const RECT* lprect,
    DRAW_CAPTION_FLAGS flags
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", ExactSpelling = true)]
static extern bool DrawCaption(
    IntPtr hwnd,   // HWND
    IntPtr hdc,   // HDC
    IntPtr lprect,   // RECT*
    uint flags   // DRAW_CAPTION_FLAGS
);
<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function DrawCaption(
    hwnd As IntPtr,   ' HWND
    hdc As IntPtr,   ' HDC
    lprect As IntPtr,   ' RECT*
    flags As UInteger   ' DRAW_CAPTION_FLAGS
) As Boolean
End Function
' hwnd : HWND
' hdc : HDC
' lprect : RECT*
' flags : DRAW_CAPTION_FLAGS
Declare PtrSafe Function DrawCaption Lib "user32" ( _
    ByVal hwnd As LongPtr, _
    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

DrawCaption = ctypes.windll.user32.DrawCaption
DrawCaption.restype = wintypes.BOOL
DrawCaption.argtypes = [
    wintypes.HANDLE,  # hwnd : HWND
    wintypes.HANDLE,  # hdc : HDC
    ctypes.c_void_p,  # lprect : RECT*
    wintypes.DWORD,  # flags : DRAW_CAPTION_FLAGS
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
DrawCaption = Fiddle::Function.new(
  lib['DrawCaption'],
  [
    Fiddle::TYPE_VOIDP,  # hwnd : HWND
    Fiddle::TYPE_VOIDP,  # hdc : HDC
    Fiddle::TYPE_VOIDP,  # lprect : RECT*
    -Fiddle::TYPE_INT,  # flags : DRAW_CAPTION_FLAGS
  ],
  Fiddle::TYPE_INT)
#[link(name = "user32")]
extern "system" {
    fn DrawCaption(
        hwnd: *mut core::ffi::c_void,  // HWND
        hdc: *mut core::ffi::c_void,  // HDC
        lprect: *const RECT,  // RECT*
        flags: u32  // DRAW_CAPTION_FLAGS
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll")]
public static extern bool DrawCaption(IntPtr hwnd, IntPtr hdc, IntPtr lprect, uint flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_DrawCaption' -Namespace Win32 -PassThru
# $api::DrawCaption(hwnd, hdc, lprect, flags)
#uselib "USER32.dll"
#func global DrawCaption "DrawCaption" sptr, sptr, sptr, sptr
; DrawCaption hwnd, hdc, varptr(lprect), flags   ; 戻り値は stat
; hwnd : HWND -> "sptr"
; hdc : HDC -> "sptr"
; lprect : RECT* -> "sptr"
; flags : DRAW_CAPTION_FLAGS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "USER32.dll"
#cfunc global DrawCaption "DrawCaption" sptr, sptr, var, int
; res = DrawCaption(hwnd, hdc, lprect, flags)
; hwnd : HWND -> "sptr"
; hdc : HDC -> "sptr"
; lprect : RECT* -> "var"
; flags : DRAW_CAPTION_FLAGS -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL DrawCaption(HWND hwnd, HDC hdc, RECT* lprect, DRAW_CAPTION_FLAGS flags)
#uselib "USER32.dll"
#cfunc global DrawCaption "DrawCaption" intptr, intptr, var, int
; res = DrawCaption(hwnd, hdc, lprect, flags)
; hwnd : HWND -> "intptr"
; hdc : HDC -> "intptr"
; lprect : RECT* -> "var"
; flags : DRAW_CAPTION_FLAGS -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procDrawCaption = user32.NewProc("DrawCaption")
)

// hwnd (HWND), hdc (HDC), lprect (RECT*), flags (DRAW_CAPTION_FLAGS)
r1, _, err := procDrawCaption.Call(
	uintptr(hwnd),
	uintptr(hdc),
	uintptr(lprect),
	uintptr(flags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function DrawCaption(
  hwnd: THandle;   // HWND
  hdc: THandle;   // HDC
  lprect: Pointer;   // RECT*
  flags: DWORD   // DRAW_CAPTION_FLAGS
): BOOL; stdcall;
  external 'USER32.dll' name 'DrawCaption';
result := DllCall("USER32\DrawCaption"
    , "Ptr", hwnd   ; HWND
    , "Ptr", hdc   ; HDC
    , "Ptr", lprect   ; RECT*
    , "UInt", flags   ; DRAW_CAPTION_FLAGS
    , "Int")   ; return: BOOL
●DrawCaption(hwnd, hdc, lprect, flags) = DLL("USER32.dll", "bool DrawCaption(void*, void*, void*, dword)")
# 呼び出し: DrawCaption(hwnd, hdc, lprect, flags)
# hwnd : HWND -> "void*"
# hdc : HDC -> "void*"
# lprect : RECT* -> "void*"
# flags : DRAW_CAPTION_FLAGS -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。