Win32 API 日本語リファレンス
ホームUI.Controls › GetBufferedPaintDC

GetBufferedPaintDC

関数
バッファ描画用のデバイスコンテキストを取得する。
DLLUXTHEME.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HDC GetBufferedPaintDC(
    INT_PTR hBufferedPaint
);

パラメーター

名前方向説明
hBufferedPaintINT_PTRinバッファー付きペイントコンテキストのハンドル。BeginBufferedPaint を通じて取得します。

戻り値の型: HDC

公式ドキュメント

ペイントデバイスコンテキスト (DC) を取得します。これは BeginBufferedPaint によって取得される値と同じです。

戻り値

種類: HDC

要求された DC のハンドル。これは BeginBufferedPaint が返す DC と同じです。失敗した場合は NULL を返します。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

HDC GetBufferedPaintDC(
    INT_PTR hBufferedPaint
);
[DllImport("UXTHEME.dll", ExactSpelling = true)]
static extern IntPtr GetBufferedPaintDC(
    IntPtr hBufferedPaint   // INT_PTR
);
<DllImport("UXTHEME.dll", ExactSpelling:=True)>
Public Shared Function GetBufferedPaintDC(
    hBufferedPaint As IntPtr   ' INT_PTR
) As IntPtr
End Function
' hBufferedPaint : INT_PTR
Declare PtrSafe Function GetBufferedPaintDC Lib "uxtheme" ( _
    ByVal hBufferedPaint As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetBufferedPaintDC = ctypes.windll.uxtheme.GetBufferedPaintDC
GetBufferedPaintDC.restype = ctypes.c_void_p
GetBufferedPaintDC.argtypes = [
    ctypes.c_ssize_t,  # hBufferedPaint : INT_PTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('UXTHEME.dll')
GetBufferedPaintDC = Fiddle::Function.new(
  lib['GetBufferedPaintDC'],
  [
    Fiddle::TYPE_INTPTR_T,  # hBufferedPaint : INT_PTR
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "uxtheme")]
extern "system" {
    fn GetBufferedPaintDC(
        hBufferedPaint: isize  // INT_PTR
    ) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("UXTHEME.dll")]
public static extern IntPtr GetBufferedPaintDC(IntPtr hBufferedPaint);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UXTHEME_GetBufferedPaintDC' -Namespace Win32 -PassThru
# $api::GetBufferedPaintDC(hBufferedPaint)
#uselib "UXTHEME.dll"
#func global GetBufferedPaintDC "GetBufferedPaintDC" sptr
; GetBufferedPaintDC hBufferedPaint   ; 戻り値は stat
; hBufferedPaint : INT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "UXTHEME.dll"
#cfunc global GetBufferedPaintDC "GetBufferedPaintDC" sptr
; res = GetBufferedPaintDC(hBufferedPaint)
; hBufferedPaint : INT_PTR -> "sptr"
; HDC GetBufferedPaintDC(INT_PTR hBufferedPaint)
#uselib "UXTHEME.dll"
#cfunc global GetBufferedPaintDC "GetBufferedPaintDC" intptr
; res = GetBufferedPaintDC(hBufferedPaint)
; hBufferedPaint : INT_PTR -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	uxtheme = windows.NewLazySystemDLL("UXTHEME.dll")
	procGetBufferedPaintDC = uxtheme.NewProc("GetBufferedPaintDC")
)

// hBufferedPaint (INT_PTR)
r1, _, err := procGetBufferedPaintDC.Call(
	uintptr(hBufferedPaint),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HDC
function GetBufferedPaintDC(
  hBufferedPaint: NativeInt   // INT_PTR
): THandle; stdcall;
  external 'UXTHEME.dll' name 'GetBufferedPaintDC';
result := DllCall("UXTHEME\GetBufferedPaintDC"
    , "Ptr", hBufferedPaint   ; INT_PTR
    , "Ptr")   ; return: HDC
●GetBufferedPaintDC(hBufferedPaint) = DLL("UXTHEME.dll", "void* GetBufferedPaintDC(int)")
# 呼び出し: GetBufferedPaintDC(hBufferedPaint)
# hBufferedPaint : INT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "uxtheme" fn GetBufferedPaintDC(
    hBufferedPaint: isize // INT_PTR
) callconv(std.os.windows.WINAPI) ?*anyopaque;
proc GetBufferedPaintDC(
    hBufferedPaint: int  # INT_PTR
): pointer {.importc: "GetBufferedPaintDC", stdcall, dynlib: "UXTHEME.dll".}
pragma(lib, "uxtheme");
extern(Windows)
void* GetBufferedPaintDC(
    ptrdiff_t hBufferedPaint   // INT_PTR
);
ccall((:GetBufferedPaintDC, "UXTHEME.dll"), stdcall, Ptr{Cvoid},
      (Int,),
      hBufferedPaint)
# hBufferedPaint : INT_PTR -> Int
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
void* GetBufferedPaintDC(
    intptr_t hBufferedPaint);
]]
local uxtheme = ffi.load("uxtheme")
-- uxtheme.GetBufferedPaintDC(hBufferedPaint)
-- hBufferedPaint : INT_PTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('UXTHEME.dll');
const GetBufferedPaintDC = lib.func('__stdcall', 'GetBufferedPaintDC', 'void *', ['intptr_t']);
// GetBufferedPaintDC(hBufferedPaint)
// hBufferedPaint : INT_PTR -> 'intptr_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("UXTHEME.dll", {
  GetBufferedPaintDC: { parameters: ["isize"], result: "pointer" },
});
// lib.symbols.GetBufferedPaintDC(hBufferedPaint)
// hBufferedPaint : INT_PTR -> "isize"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
void* GetBufferedPaintDC(
    intptr_t hBufferedPaint);
C, "UXTHEME.dll");
// $ffi->GetBufferedPaintDC(hBufferedPaint);
// hBufferedPaint : INT_PTR
// 構造体/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);
    Pointer GetBufferedPaintDC(
        long hBufferedPaint   // INT_PTR
    );
}
@[Link("uxtheme")]
lib LibUXTHEME
  fun GetBufferedPaintDC = GetBufferedPaintDC(
    hBufferedPaint : LibC::SSizeT   # INT_PTR
  ) : Void*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef GetBufferedPaintDCNative = Pointer<Void> Function(IntPtr);
typedef GetBufferedPaintDCDart = Pointer<Void> Function(int);
final GetBufferedPaintDC = DynamicLibrary.open('UXTHEME.dll')
    .lookupFunction<GetBufferedPaintDCNative, GetBufferedPaintDCDart>('GetBufferedPaintDC');
// hBufferedPaint : INT_PTR -> IntPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function GetBufferedPaintDC(
  hBufferedPaint: NativeInt   // INT_PTR
): THandle; stdcall;
  external 'UXTHEME.dll' name 'GetBufferedPaintDC';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GetBufferedPaintDC"
  c_GetBufferedPaintDC :: CIntPtr -> IO (Ptr ())
-- hBufferedPaint : INT_PTR -> CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let getbufferedpaintdc =
  foreign "GetBufferedPaintDC"
    (intptr_t @-> returning (ptr void))
(* hBufferedPaint : INT_PTR -> intptr_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library uxtheme (t "UXTHEME.dll"))
(cffi:use-foreign-library uxtheme)

(cffi:defcfun ("GetBufferedPaintDC" get-buffered-paint-dc :convention :stdcall) :pointer
  (h-buffered-paint :int64))   ; INT_PTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GetBufferedPaintDC = Win32::API::More->new('UXTHEME',
    'HANDLE GetBufferedPaintDC(LPARAM hBufferedPaint)');
# my $ret = $GetBufferedPaintDC->Call($hBufferedPaint);
# hBufferedPaint : INT_PTR -> LPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。