ホーム › UI.Controls › BeginBufferedPaint
BeginBufferedPaint
関数オフスクリーンバッファへの描画を開始しバッファDCを取得する。
シグネチャ
// UXTHEME.dll
#include <windows.h>
INT_PTR BeginBufferedPaint(
HDC hdcTarget,
const RECT* prcTarget,
BP_BUFFERFORMAT dwFormat,
BP_PAINTPARAMS* pPaintParams, // optional
HDC* phdc
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hdcTarget | HDC | in | バッファの描画先となるターゲット DC のハンドル。 |
| prcTarget | RECT* | in | 描画を行うターゲット DC 内の領域を指定する RECT 構造体へのポインター。 |
| dwFormat | BP_BUFFERFORMAT | in | バッファの形式を指定する BP_BUFFERFORMAT 列挙体のメンバー。 |
| pPaintParams | BP_PAINTPARAMS* | inoptional | 描画操作のパラメーターを定義する BP_PAINTPARAMS 構造体へのポインター。この値は NULL にできます。 |
| phdc | HDC* | out | この関数が返るときに、新しいデバイスコンテキストのハンドルを指します。 |
戻り値の型: INT_PTR
公式ドキュメント
バッファリングされた描画操作を開始します。
戻り値
型: HPAINTBUFFER
バッファリングされた描画コンテキストへのハンドル。この関数が失敗した場合、戻り値は NULL となり、phdc も NULL になります。拡張エラー情報を取得するには、GetLastError を呼び出します。
返されたハンドルは、EndBufferedPaint が呼び出されると解放されます。
アプリケーションは、BeginBufferedPaint を呼び出す前に呼び出し元スレッドで BufferedPaintInit を呼び出し、スレッドが終了する前に BufferedPaintUnInit を呼び出す必要があります。BufferedPaintInit を呼び出さないと、バッファリングされた描画操作ごとに内部データが初期化および破棄されるため、パフォーマンスが低下する可能性があります。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// UXTHEME.dll
#include <windows.h>
INT_PTR BeginBufferedPaint(
HDC hdcTarget,
const RECT* prcTarget,
BP_BUFFERFORMAT dwFormat,
BP_PAINTPARAMS* pPaintParams, // optional
HDC* phdc
);[DllImport("UXTHEME.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr BeginBufferedPaint(
IntPtr hdcTarget, // HDC
IntPtr prcTarget, // RECT*
int dwFormat, // BP_BUFFERFORMAT
IntPtr pPaintParams, // BP_PAINTPARAMS* optional
IntPtr phdc // HDC* out
);<DllImport("UXTHEME.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function BeginBufferedPaint(
hdcTarget As IntPtr, ' HDC
prcTarget As IntPtr, ' RECT*
dwFormat As Integer, ' BP_BUFFERFORMAT
pPaintParams As IntPtr, ' BP_PAINTPARAMS* optional
phdc As IntPtr ' HDC* out
) As IntPtr
End Function' hdcTarget : HDC
' prcTarget : RECT*
' dwFormat : BP_BUFFERFORMAT
' pPaintParams : BP_PAINTPARAMS* optional
' phdc : HDC* out
Declare PtrSafe Function BeginBufferedPaint Lib "uxtheme" ( _
ByVal hdcTarget As LongPtr, _
ByVal prcTarget As LongPtr, _
ByVal dwFormat As Long, _
ByVal pPaintParams As LongPtr, _
ByVal phdc As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
BeginBufferedPaint = ctypes.windll.uxtheme.BeginBufferedPaint
BeginBufferedPaint.restype = ctypes.c_ssize_t
BeginBufferedPaint.argtypes = [
wintypes.HANDLE, # hdcTarget : HDC
ctypes.c_void_p, # prcTarget : RECT*
ctypes.c_int, # dwFormat : BP_BUFFERFORMAT
ctypes.c_void_p, # pPaintParams : BP_PAINTPARAMS* optional
ctypes.c_void_p, # phdc : HDC* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('UXTHEME.dll')
BeginBufferedPaint = Fiddle::Function.new(
lib['BeginBufferedPaint'],
[
Fiddle::TYPE_VOIDP, # hdcTarget : HDC
Fiddle::TYPE_VOIDP, # prcTarget : RECT*
Fiddle::TYPE_INT, # dwFormat : BP_BUFFERFORMAT
Fiddle::TYPE_VOIDP, # pPaintParams : BP_PAINTPARAMS* optional
Fiddle::TYPE_VOIDP, # phdc : HDC* out
],
Fiddle::TYPE_INTPTR_T)#[link(name = "uxtheme")]
extern "system" {
fn BeginBufferedPaint(
hdcTarget: *mut core::ffi::c_void, // HDC
prcTarget: *const RECT, // RECT*
dwFormat: i32, // BP_BUFFERFORMAT
pPaintParams: *mut BP_PAINTPARAMS, // BP_PAINTPARAMS* optional
phdc: *mut *mut core::ffi::c_void // HDC* out
) -> isize;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("UXTHEME.dll", SetLastError = true)]
public static extern IntPtr BeginBufferedPaint(IntPtr hdcTarget, IntPtr prcTarget, int dwFormat, IntPtr pPaintParams, IntPtr phdc);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UXTHEME_BeginBufferedPaint' -Namespace Win32 -PassThru
# $api::BeginBufferedPaint(hdcTarget, prcTarget, dwFormat, pPaintParams, phdc)#uselib "UXTHEME.dll"
#func global BeginBufferedPaint "BeginBufferedPaint" sptr, sptr, sptr, sptr, sptr
; BeginBufferedPaint hdcTarget, varptr(prcTarget), dwFormat, varptr(pPaintParams), phdc ; 戻り値は stat
; hdcTarget : HDC -> "sptr"
; prcTarget : RECT* -> "sptr"
; dwFormat : BP_BUFFERFORMAT -> "sptr"
; pPaintParams : BP_PAINTPARAMS* optional -> "sptr"
; phdc : HDC* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "UXTHEME.dll" #cfunc global BeginBufferedPaint "BeginBufferedPaint" sptr, var, int, var, sptr ; res = BeginBufferedPaint(hdcTarget, prcTarget, dwFormat, pPaintParams, phdc) ; hdcTarget : HDC -> "sptr" ; prcTarget : RECT* -> "var" ; dwFormat : BP_BUFFERFORMAT -> "int" ; pPaintParams : BP_PAINTPARAMS* optional -> "var" ; phdc : HDC* out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "UXTHEME.dll" #cfunc global BeginBufferedPaint "BeginBufferedPaint" sptr, sptr, int, sptr, sptr ; res = BeginBufferedPaint(hdcTarget, varptr(prcTarget), dwFormat, varptr(pPaintParams), phdc) ; hdcTarget : HDC -> "sptr" ; prcTarget : RECT* -> "sptr" ; dwFormat : BP_BUFFERFORMAT -> "int" ; pPaintParams : BP_PAINTPARAMS* optional -> "sptr" ; phdc : HDC* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT_PTR BeginBufferedPaint(HDC hdcTarget, RECT* prcTarget, BP_BUFFERFORMAT dwFormat, BP_PAINTPARAMS* pPaintParams, HDC* phdc) #uselib "UXTHEME.dll" #cfunc global BeginBufferedPaint "BeginBufferedPaint" intptr, var, int, var, intptr ; res = BeginBufferedPaint(hdcTarget, prcTarget, dwFormat, pPaintParams, phdc) ; hdcTarget : HDC -> "intptr" ; prcTarget : RECT* -> "var" ; dwFormat : BP_BUFFERFORMAT -> "int" ; pPaintParams : BP_PAINTPARAMS* optional -> "var" ; phdc : HDC* out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT_PTR BeginBufferedPaint(HDC hdcTarget, RECT* prcTarget, BP_BUFFERFORMAT dwFormat, BP_PAINTPARAMS* pPaintParams, HDC* phdc) #uselib "UXTHEME.dll" #cfunc global BeginBufferedPaint "BeginBufferedPaint" intptr, intptr, int, intptr, intptr ; res = BeginBufferedPaint(hdcTarget, varptr(prcTarget), dwFormat, varptr(pPaintParams), phdc) ; hdcTarget : HDC -> "intptr" ; prcTarget : RECT* -> "intptr" ; dwFormat : BP_BUFFERFORMAT -> "int" ; pPaintParams : BP_PAINTPARAMS* optional -> "intptr" ; phdc : HDC* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
uxtheme = windows.NewLazySystemDLL("UXTHEME.dll")
procBeginBufferedPaint = uxtheme.NewProc("BeginBufferedPaint")
)
// hdcTarget (HDC), prcTarget (RECT*), dwFormat (BP_BUFFERFORMAT), pPaintParams (BP_PAINTPARAMS* optional), phdc (HDC* out)
r1, _, err := procBeginBufferedPaint.Call(
uintptr(hdcTarget),
uintptr(prcTarget),
uintptr(dwFormat),
uintptr(pPaintParams),
uintptr(phdc),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INT_PTRfunction BeginBufferedPaint(
hdcTarget: THandle; // HDC
prcTarget: Pointer; // RECT*
dwFormat: Integer; // BP_BUFFERFORMAT
pPaintParams: Pointer; // BP_PAINTPARAMS* optional
phdc: Pointer // HDC* out
): NativeInt; stdcall;
external 'UXTHEME.dll' name 'BeginBufferedPaint';result := DllCall("UXTHEME\BeginBufferedPaint"
, "Ptr", hdcTarget ; HDC
, "Ptr", prcTarget ; RECT*
, "Int", dwFormat ; BP_BUFFERFORMAT
, "Ptr", pPaintParams ; BP_PAINTPARAMS* optional
, "Ptr", phdc ; HDC* out
, "Ptr") ; return: INT_PTR●BeginBufferedPaint(hdcTarget, prcTarget, dwFormat, pPaintParams, phdc) = DLL("UXTHEME.dll", "int BeginBufferedPaint(void*, void*, int, void*, void*)")
# 呼び出し: BeginBufferedPaint(hdcTarget, prcTarget, dwFormat, pPaintParams, phdc)
# hdcTarget : HDC -> "void*"
# prcTarget : RECT* -> "void*"
# dwFormat : BP_BUFFERFORMAT -> "int"
# pPaintParams : BP_PAINTPARAMS* optional -> "void*"
# phdc : HDC* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "uxtheme" fn BeginBufferedPaint(
hdcTarget: ?*anyopaque, // HDC
prcTarget: [*c]RECT, // RECT*
dwFormat: i32, // BP_BUFFERFORMAT
pPaintParams: [*c]BP_PAINTPARAMS, // BP_PAINTPARAMS* optional
phdc: ?*anyopaque // HDC* out
) callconv(std.os.windows.WINAPI) isize;proc BeginBufferedPaint(
hdcTarget: pointer, # HDC
prcTarget: ptr RECT, # RECT*
dwFormat: int32, # BP_BUFFERFORMAT
pPaintParams: ptr BP_PAINTPARAMS, # BP_PAINTPARAMS* optional
phdc: pointer # HDC* out
): int {.importc: "BeginBufferedPaint", stdcall, dynlib: "UXTHEME.dll".}pragma(lib, "uxtheme");
extern(Windows)
ptrdiff_t BeginBufferedPaint(
void* hdcTarget, // HDC
RECT* prcTarget, // RECT*
int dwFormat, // BP_BUFFERFORMAT
BP_PAINTPARAMS* pPaintParams, // BP_PAINTPARAMS* optional
void* phdc // HDC* out
);ccall((:BeginBufferedPaint, "UXTHEME.dll"), stdcall, Int,
(Ptr{Cvoid}, Ptr{RECT}, Int32, Ptr{BP_PAINTPARAMS}, Ptr{Cvoid}),
hdcTarget, prcTarget, dwFormat, pPaintParams, phdc)
# hdcTarget : HDC -> Ptr{Cvoid}
# prcTarget : RECT* -> Ptr{RECT}
# dwFormat : BP_BUFFERFORMAT -> Int32
# pPaintParams : BP_PAINTPARAMS* optional -> Ptr{BP_PAINTPARAMS}
# phdc : HDC* out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
intptr_t BeginBufferedPaint(
void* hdcTarget,
void* prcTarget,
int32_t dwFormat,
void* pPaintParams,
void* phdc);
]]
local uxtheme = ffi.load("uxtheme")
-- uxtheme.BeginBufferedPaint(hdcTarget, prcTarget, dwFormat, pPaintParams, phdc)
-- hdcTarget : HDC
-- prcTarget : RECT*
-- dwFormat : BP_BUFFERFORMAT
-- pPaintParams : BP_PAINTPARAMS* optional
-- phdc : HDC* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('UXTHEME.dll');
const BeginBufferedPaint = lib.func('__stdcall', 'BeginBufferedPaint', 'intptr_t', ['void *', 'void *', 'int32_t', 'void *', 'void *']);
// BeginBufferedPaint(hdcTarget, prcTarget, dwFormat, pPaintParams, phdc)
// hdcTarget : HDC -> 'void *'
// prcTarget : RECT* -> 'void *'
// dwFormat : BP_BUFFERFORMAT -> 'int32_t'
// pPaintParams : BP_PAINTPARAMS* optional -> 'void *'
// phdc : HDC* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("UXTHEME.dll", {
BeginBufferedPaint: { parameters: ["pointer", "pointer", "i32", "pointer", "pointer"], result: "isize" },
});
// lib.symbols.BeginBufferedPaint(hdcTarget, prcTarget, dwFormat, pPaintParams, phdc)
// hdcTarget : HDC -> "pointer"
// prcTarget : RECT* -> "pointer"
// dwFormat : BP_BUFFERFORMAT -> "i32"
// pPaintParams : BP_PAINTPARAMS* optional -> "pointer"
// phdc : HDC* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
intptr_t BeginBufferedPaint(
void* hdcTarget,
void* prcTarget,
int32_t dwFormat,
void* pPaintParams,
void* phdc);
C, "UXTHEME.dll");
// $ffi->BeginBufferedPaint(hdcTarget, prcTarget, dwFormat, pPaintParams, phdc);
// hdcTarget : HDC
// prcTarget : RECT*
// dwFormat : BP_BUFFERFORMAT
// pPaintParams : BP_PAINTPARAMS* optional
// phdc : HDC* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Uxtheme extends StdCallLibrary {
Uxtheme INSTANCE = Native.load("uxtheme", Uxtheme.class);
long BeginBufferedPaint(
Pointer hdcTarget, // HDC
Pointer prcTarget, // RECT*
int dwFormat, // BP_BUFFERFORMAT
Pointer pPaintParams, // BP_PAINTPARAMS* optional
Pointer phdc // HDC* out
);
}@[Link("uxtheme")]
lib LibUXTHEME
fun BeginBufferedPaint = BeginBufferedPaint(
hdcTarget : Void*, # HDC
prcTarget : RECT*, # RECT*
dwFormat : Int32, # BP_BUFFERFORMAT
pPaintParams : BP_PAINTPARAMS*, # BP_PAINTPARAMS* optional
phdc : Void* # HDC* out
) : LibC::SSizeT
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef BeginBufferedPaintNative = IntPtr Function(Pointer<Void>, Pointer<Void>, Int32, Pointer<Void>, Pointer<Void>);
typedef BeginBufferedPaintDart = int Function(Pointer<Void>, Pointer<Void>, int, Pointer<Void>, Pointer<Void>);
final BeginBufferedPaint = DynamicLibrary.open('UXTHEME.dll')
.lookupFunction<BeginBufferedPaintNative, BeginBufferedPaintDart>('BeginBufferedPaint');
// hdcTarget : HDC -> Pointer<Void>
// prcTarget : RECT* -> Pointer<Void>
// dwFormat : BP_BUFFERFORMAT -> Int32
// pPaintParams : BP_PAINTPARAMS* optional -> Pointer<Void>
// phdc : HDC* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function BeginBufferedPaint(
hdcTarget: THandle; // HDC
prcTarget: Pointer; // RECT*
dwFormat: Integer; // BP_BUFFERFORMAT
pPaintParams: Pointer; // BP_PAINTPARAMS* optional
phdc: Pointer // HDC* out
): NativeInt; stdcall;
external 'UXTHEME.dll' name 'BeginBufferedPaint';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "BeginBufferedPaint"
c_BeginBufferedPaint :: Ptr () -> Ptr () -> Int32 -> Ptr () -> Ptr () -> IO CIntPtr
-- hdcTarget : HDC -> Ptr ()
-- prcTarget : RECT* -> Ptr ()
-- dwFormat : BP_BUFFERFORMAT -> Int32
-- pPaintParams : BP_PAINTPARAMS* optional -> Ptr ()
-- phdc : HDC* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let beginbufferedpaint =
foreign "BeginBufferedPaint"
((ptr void) @-> (ptr void) @-> int32_t @-> (ptr void) @-> (ptr void) @-> returning intptr_t)
(* hdcTarget : HDC -> (ptr void) *)
(* prcTarget : RECT* -> (ptr void) *)
(* dwFormat : BP_BUFFERFORMAT -> int32_t *)
(* pPaintParams : BP_PAINTPARAMS* optional -> (ptr void) *)
(* phdc : HDC* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library uxtheme (t "UXTHEME.dll"))
(cffi:use-foreign-library uxtheme)
(cffi:defcfun ("BeginBufferedPaint" begin-buffered-paint :convention :stdcall) :int64
(hdc-target :pointer) ; HDC
(prc-target :pointer) ; RECT*
(dw-format :int32) ; BP_BUFFERFORMAT
(p-paint-params :pointer) ; BP_PAINTPARAMS* optional
(phdc :pointer)) ; HDC* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $BeginBufferedPaint = Win32::API::More->new('UXTHEME',
'LPARAM BeginBufferedPaint(HANDLE hdcTarget, LPVOID prcTarget, int dwFormat, LPVOID pPaintParams, HANDLE phdc)');
# my $ret = $BeginBufferedPaint->Call($hdcTarget, $prcTarget, $dwFormat, $pPaintParams, $phdc);
# hdcTarget : HDC -> HANDLE
# prcTarget : RECT* -> LPVOID
# dwFormat : BP_BUFFERFORMAT -> int
# pPaintParams : BP_PAINTPARAMS* optional -> LPVOID
# phdc : HDC* out -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。