ホーム › Graphics.Gdi › DrawFrameControl
DrawFrameControl
関数ボタンやスクロールバーなどのフレームコントロールを描画する。
シグネチャ
// USER32.dll
#include <windows.h>
BOOL DrawFrameControl(
HDC hdc,
RECT* lprc,
DWORD uType,
DWORD uState
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| hdc | HDC | in | コントロールを描画するウィンドウのデバイスコンテキストへのハンドル。 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lprc | RECT* | inout | フレームコントロールの外接矩形の論理座標を格納する RECT 構造体へのポインター。 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uType | DWORD | in | 描画するフレームコントロールの種類。このパラメーターには次のいずれかの値を指定できます。
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uState | DWORD | in | フレームコントロールの初期状態。uType が DFC_BUTTON の場合、uState には次のいずれかの値を指定できます。
uType が DFC_CAPTION の場合、uState には次のいずれかの値を指定できます。
uType が DFC_MENU の場合、uState には次のいずれかの値を指定できます。
uType が DFC_SCROLL の場合、uState には次のいずれかの値を指定できます。
プッシュボタンの外接矩形を調整するには、次のスタイルを使用できます。
描画するコントロールの状態を設定するには、次の値を 1 つ以上使用できます。
|
戻り値の型: BOOL
公式ドキュメント
DrawFrameControl 関数は、指定された種類とスタイルのフレームコントロールを描画します。
戻り値
関数が成功すると、戻り値は 0 以外になります。
関数が失敗すると、戻り値は 0 になります。
解説(Remarks)
uType が DFC_MENU または DFC_BUTTON のいずれかであり、uState が DFCS_BUTTONPUSH でない場合、フレームコントロールは白地に黒のマスク (つまり、白い背景に黒のフレームコントロール) になります。このような場合、アプリケーションはビットマップメモリデバイスコントロールへのハンドルを渡す必要があります。アプリケーションは、関連付けられたビットマップを MaskBlt 関数の hbmMask パラメーターとして使用するか、あるいは SRCAND や SRCINVERT などの ROP を使用してそのデバイスコンテキストを BitBlt 関数のパラメーターとして使用できます。
DPI 仮想化
この API は DPI 仮想化に参加しません。入力は常に物理ピクセル単位で与えられ、呼び出し元のコンテキストとは関係ありません。出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
BOOL DrawFrameControl(
HDC hdc,
RECT* lprc,
DWORD uType,
DWORD uState
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", ExactSpelling = true)]
static extern bool DrawFrameControl(
IntPtr hdc, // HDC
IntPtr lprc, // RECT* in/out
uint uType, // DWORD
uint uState // DWORD
);<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function DrawFrameControl(
hdc As IntPtr, ' HDC
lprc As IntPtr, ' RECT* in/out
uType As UInteger, ' DWORD
uState As UInteger ' DWORD
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' hdc : HDC
' lprc : RECT* in/out
' uType : DWORD
' uState : DWORD
Declare PtrSafe Function DrawFrameControl Lib "user32" ( _
ByVal hdc As LongPtr, _
ByVal lprc As LongPtr, _
ByVal uType As Long, _
ByVal uState As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DrawFrameControl = ctypes.windll.user32.DrawFrameControl
DrawFrameControl.restype = wintypes.BOOL
DrawFrameControl.argtypes = [
wintypes.HANDLE, # hdc : HDC
ctypes.c_void_p, # lprc : RECT* in/out
wintypes.DWORD, # uType : DWORD
wintypes.DWORD, # uState : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
DrawFrameControl = Fiddle::Function.new(
lib['DrawFrameControl'],
[
Fiddle::TYPE_VOIDP, # hdc : HDC
Fiddle::TYPE_VOIDP, # lprc : RECT* in/out
-Fiddle::TYPE_INT, # uType : DWORD
-Fiddle::TYPE_INT, # uState : DWORD
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn DrawFrameControl(
hdc: *mut core::ffi::c_void, // HDC
lprc: *mut RECT, // RECT* in/out
uType: u32, // DWORD
uState: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll")]
public static extern bool DrawFrameControl(IntPtr hdc, IntPtr lprc, uint uType, uint uState);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_DrawFrameControl' -Namespace Win32 -PassThru
# $api::DrawFrameControl(hdc, lprc, uType, uState)#uselib "USER32.dll"
#func global DrawFrameControl "DrawFrameControl" sptr, sptr, sptr, sptr
; DrawFrameControl hdc, varptr(lprc), uType, uState ; 戻り値は stat
; hdc : HDC -> "sptr"
; lprc : RECT* in/out -> "sptr"
; uType : DWORD -> "sptr"
; uState : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USER32.dll" #cfunc global DrawFrameControl "DrawFrameControl" sptr, var, int, int ; res = DrawFrameControl(hdc, lprc, uType, uState) ; hdc : HDC -> "sptr" ; lprc : RECT* in/out -> "var" ; uType : DWORD -> "int" ; uState : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USER32.dll" #cfunc global DrawFrameControl "DrawFrameControl" sptr, sptr, int, int ; res = DrawFrameControl(hdc, varptr(lprc), uType, uState) ; hdc : HDC -> "sptr" ; lprc : RECT* in/out -> "sptr" ; uType : DWORD -> "int" ; uState : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL DrawFrameControl(HDC hdc, RECT* lprc, DWORD uType, DWORD uState) #uselib "USER32.dll" #cfunc global DrawFrameControl "DrawFrameControl" intptr, var, int, int ; res = DrawFrameControl(hdc, lprc, uType, uState) ; hdc : HDC -> "intptr" ; lprc : RECT* in/out -> "var" ; uType : DWORD -> "int" ; uState : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL DrawFrameControl(HDC hdc, RECT* lprc, DWORD uType, DWORD uState) #uselib "USER32.dll" #cfunc global DrawFrameControl "DrawFrameControl" intptr, intptr, int, int ; res = DrawFrameControl(hdc, varptr(lprc), uType, uState) ; hdc : HDC -> "intptr" ; lprc : RECT* in/out -> "intptr" ; uType : DWORD -> "int" ; uState : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procDrawFrameControl = user32.NewProc("DrawFrameControl")
)
// hdc (HDC), lprc (RECT* in/out), uType (DWORD), uState (DWORD)
r1, _, err := procDrawFrameControl.Call(
uintptr(hdc),
uintptr(lprc),
uintptr(uType),
uintptr(uState),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction DrawFrameControl(
hdc: THandle; // HDC
lprc: Pointer; // RECT* in/out
uType: DWORD; // DWORD
uState: DWORD // DWORD
): BOOL; stdcall;
external 'USER32.dll' name 'DrawFrameControl';result := DllCall("USER32\DrawFrameControl"
, "Ptr", hdc ; HDC
, "Ptr", lprc ; RECT* in/out
, "UInt", uType ; DWORD
, "UInt", uState ; DWORD
, "Int") ; return: BOOL●DrawFrameControl(hdc, lprc, uType, uState) = DLL("USER32.dll", "bool DrawFrameControl(void*, void*, dword, dword)")
# 呼び出し: DrawFrameControl(hdc, lprc, uType, uState)
# hdc : HDC -> "void*"
# lprc : RECT* in/out -> "void*"
# uType : DWORD -> "dword"
# uState : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "user32" fn DrawFrameControl(
hdc: ?*anyopaque, // HDC
lprc: [*c]RECT, // RECT* in/out
uType: u32, // DWORD
uState: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc DrawFrameControl(
hdc: pointer, # HDC
lprc: ptr RECT, # RECT* in/out
uType: uint32, # DWORD
uState: uint32 # DWORD
): int32 {.importc: "DrawFrameControl", stdcall, dynlib: "USER32.dll".}pragma(lib, "user32");
extern(Windows)
int DrawFrameControl(
void* hdc, // HDC
RECT* lprc, // RECT* in/out
uint uType, // DWORD
uint uState // DWORD
);ccall((:DrawFrameControl, "USER32.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{RECT}, UInt32, UInt32),
hdc, lprc, uType, uState)
# hdc : HDC -> Ptr{Cvoid}
# lprc : RECT* in/out -> Ptr{RECT}
# uType : DWORD -> UInt32
# uState : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DrawFrameControl(
void* hdc,
void* lprc,
uint32_t uType,
uint32_t uState);
]]
local user32 = ffi.load("user32")
-- user32.DrawFrameControl(hdc, lprc, uType, uState)
-- hdc : HDC
-- lprc : RECT* in/out
-- uType : DWORD
-- uState : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('USER32.dll');
const DrawFrameControl = lib.func('__stdcall', 'DrawFrameControl', 'int32_t', ['void *', 'void *', 'uint32_t', 'uint32_t']);
// DrawFrameControl(hdc, lprc, uType, uState)
// hdc : HDC -> 'void *'
// lprc : RECT* in/out -> 'void *'
// uType : DWORD -> 'uint32_t'
// uState : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("USER32.dll", {
DrawFrameControl: { parameters: ["pointer", "pointer", "u32", "u32"], result: "i32" },
});
// lib.symbols.DrawFrameControl(hdc, lprc, uType, uState)
// hdc : HDC -> "pointer"
// lprc : RECT* in/out -> "pointer"
// uType : DWORD -> "u32"
// uState : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DrawFrameControl(
void* hdc,
void* lprc,
uint32_t uType,
uint32_t uState);
C, "USER32.dll");
// $ffi->DrawFrameControl(hdc, lprc, uType, uState);
// hdc : HDC
// lprc : RECT* in/out
// uType : DWORD
// uState : DWORD
// 構造体/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 User32 extends StdCallLibrary {
User32 INSTANCE = Native.load("user32", User32.class);
boolean DrawFrameControl(
Pointer hdc, // HDC
Pointer lprc, // RECT* in/out
int uType, // DWORD
int uState // DWORD
);
}@[Link("user32")]
lib LibUSER32
fun DrawFrameControl = DrawFrameControl(
hdc : Void*, # HDC
lprc : RECT*, # RECT* in/out
uType : UInt32, # DWORD
uState : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DrawFrameControlNative = Int32 Function(Pointer<Void>, Pointer<Void>, Uint32, Uint32);
typedef DrawFrameControlDart = int Function(Pointer<Void>, Pointer<Void>, int, int);
final DrawFrameControl = DynamicLibrary.open('USER32.dll')
.lookupFunction<DrawFrameControlNative, DrawFrameControlDart>('DrawFrameControl');
// hdc : HDC -> Pointer<Void>
// lprc : RECT* in/out -> Pointer<Void>
// uType : DWORD -> Uint32
// uState : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DrawFrameControl(
hdc: THandle; // HDC
lprc: Pointer; // RECT* in/out
uType: DWORD; // DWORD
uState: DWORD // DWORD
): BOOL; stdcall;
external 'USER32.dll' name 'DrawFrameControl';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DrawFrameControl"
c_DrawFrameControl :: Ptr () -> Ptr () -> Word32 -> Word32 -> IO CInt
-- hdc : HDC -> Ptr ()
-- lprc : RECT* in/out -> Ptr ()
-- uType : DWORD -> Word32
-- uState : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let drawframecontrol =
foreign "DrawFrameControl"
((ptr void) @-> (ptr void) @-> uint32_t @-> uint32_t @-> returning int32_t)
(* hdc : HDC -> (ptr void) *)
(* lprc : RECT* in/out -> (ptr void) *)
(* uType : DWORD -> uint32_t *)
(* uState : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library user32 (t "USER32.dll"))
(cffi:use-foreign-library user32)
(cffi:defcfun ("DrawFrameControl" draw-frame-control :convention :stdcall) :int32
(hdc :pointer) ; HDC
(lprc :pointer) ; RECT* in/out
(u-type :uint32) ; DWORD
(u-state :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DrawFrameControl = Win32::API::More->new('USER32',
'BOOL DrawFrameControl(HANDLE hdc, LPVOID lprc, DWORD uType, DWORD uState)');
# my $ret = $DrawFrameControl->Call($hdc, $lprc, $uType, $uState);
# hdc : HDC -> HANDLE
# lprc : RECT* in/out -> LPVOID
# uType : DWORD -> DWORD
# uState : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型