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