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

DrawShadowText

関数
影付きのテキストを指定矩形に描画する。
DLLCOMCTL32.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

INT DrawShadowText(
    HDC hdc,
    LPCWSTR pszText,
    DWORD cch,
    RECT* prc,
    DWORD dwFlags,
    COLORREF crText,
    COLORREF crShadow,
    INT ixOffset,
    INT iyOffset
);

パラメーター

名前方向
hdcHDCin
pszTextLPCWSTRin
cchDWORDin
prcRECT*in
dwFlagsDWORDin
crTextCOLORREFin
crShadowCOLORREFin
ixOffsetINTin
iyOffsetINTin

戻り値の型: INT

各言語での呼び出し定義

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

INT DrawShadowText(
    HDC hdc,
    LPCWSTR pszText,
    DWORD cch,
    RECT* prc,
    DWORD dwFlags,
    COLORREF crText,
    COLORREF crShadow,
    INT ixOffset,
    INT iyOffset
);
[DllImport("COMCTL32.dll", ExactSpelling = true)]
static extern int DrawShadowText(
    IntPtr hdc,   // HDC
    [MarshalAs(UnmanagedType.LPWStr)] string pszText,   // LPCWSTR
    uint cch,   // DWORD
    IntPtr prc,   // RECT*
    uint dwFlags,   // DWORD
    uint crText,   // COLORREF
    uint crShadow,   // COLORREF
    int ixOffset,   // INT
    int iyOffset   // INT
);
<DllImport("COMCTL32.dll", ExactSpelling:=True)>
Public Shared Function DrawShadowText(
    hdc As IntPtr,   ' HDC
    <MarshalAs(UnmanagedType.LPWStr)> pszText As String,   ' LPCWSTR
    cch As UInteger,   ' DWORD
    prc As IntPtr,   ' RECT*
    dwFlags As UInteger,   ' DWORD
    crText As UInteger,   ' COLORREF
    crShadow As UInteger,   ' COLORREF
    ixOffset As Integer,   ' INT
    iyOffset As Integer   ' INT
) As Integer
End Function
' hdc : HDC
' pszText : LPCWSTR
' cch : DWORD
' prc : RECT*
' dwFlags : DWORD
' crText : COLORREF
' crShadow : COLORREF
' ixOffset : INT
' iyOffset : INT
Declare PtrSafe Function DrawShadowText Lib "comctl32" ( _
    ByVal hdc As LongPtr, _
    ByVal pszText As LongPtr, _
    ByVal cch As Long, _
    ByVal prc As LongPtr, _
    ByVal dwFlags As Long, _
    ByVal crText As Long, _
    ByVal crShadow As Long, _
    ByVal ixOffset As Long, _
    ByVal iyOffset As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DrawShadowText = ctypes.windll.comctl32.DrawShadowText
DrawShadowText.restype = ctypes.c_int
DrawShadowText.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    wintypes.LPCWSTR,  # pszText : LPCWSTR
    wintypes.DWORD,  # cch : DWORD
    ctypes.c_void_p,  # prc : RECT*
    wintypes.DWORD,  # dwFlags : DWORD
    wintypes.DWORD,  # crText : COLORREF
    wintypes.DWORD,  # crShadow : COLORREF
    ctypes.c_int,  # ixOffset : INT
    ctypes.c_int,  # iyOffset : INT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('COMCTL32.dll')
DrawShadowText = Fiddle::Function.new(
  lib['DrawShadowText'],
  [
    Fiddle::TYPE_VOIDP,  # hdc : HDC
    Fiddle::TYPE_VOIDP,  # pszText : LPCWSTR
    -Fiddle::TYPE_INT,  # cch : DWORD
    Fiddle::TYPE_VOIDP,  # prc : RECT*
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
    -Fiddle::TYPE_INT,  # crText : COLORREF
    -Fiddle::TYPE_INT,  # crShadow : COLORREF
    Fiddle::TYPE_INT,  # ixOffset : INT
    Fiddle::TYPE_INT,  # iyOffset : INT
  ],
  Fiddle::TYPE_INT)
#[link(name = "comctl32")]
extern "system" {
    fn DrawShadowText(
        hdc: *mut core::ffi::c_void,  // HDC
        pszText: *const u16,  // LPCWSTR
        cch: u32,  // DWORD
        prc: *mut RECT,  // RECT*
        dwFlags: u32,  // DWORD
        crText: u32,  // COLORREF
        crShadow: u32,  // COLORREF
        ixOffset: i32,  // INT
        iyOffset: i32  // INT
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("COMCTL32.dll")]
public static extern int DrawShadowText(IntPtr hdc, [MarshalAs(UnmanagedType.LPWStr)] string pszText, uint cch, IntPtr prc, uint dwFlags, uint crText, uint crShadow, int ixOffset, int iyOffset);
"@
$api = Add-Type -MemberDefinition $sig -Name 'COMCTL32_DrawShadowText' -Namespace Win32 -PassThru
# $api::DrawShadowText(hdc, pszText, cch, prc, dwFlags, crText, crShadow, ixOffset, iyOffset)
#uselib "COMCTL32.dll"
#func global DrawShadowText "DrawShadowText" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; DrawShadowText hdc, pszText, cch, varptr(prc), dwFlags, crText, crShadow, ixOffset, iyOffset   ; 戻り値は stat
; hdc : HDC -> "sptr"
; pszText : LPCWSTR -> "sptr"
; cch : DWORD -> "sptr"
; prc : RECT* -> "sptr"
; dwFlags : DWORD -> "sptr"
; crText : COLORREF -> "sptr"
; crShadow : COLORREF -> "sptr"
; ixOffset : INT -> "sptr"
; iyOffset : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "COMCTL32.dll"
#cfunc global DrawShadowText "DrawShadowText" sptr, wstr, int, var, int, int, int, int, int
; res = DrawShadowText(hdc, pszText, cch, prc, dwFlags, crText, crShadow, ixOffset, iyOffset)
; hdc : HDC -> "sptr"
; pszText : LPCWSTR -> "wstr"
; cch : DWORD -> "int"
; prc : RECT* -> "var"
; dwFlags : DWORD -> "int"
; crText : COLORREF -> "int"
; crShadow : COLORREF -> "int"
; ixOffset : INT -> "int"
; iyOffset : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT DrawShadowText(HDC hdc, LPCWSTR pszText, DWORD cch, RECT* prc, DWORD dwFlags, COLORREF crText, COLORREF crShadow, INT ixOffset, INT iyOffset)
#uselib "COMCTL32.dll"
#cfunc global DrawShadowText "DrawShadowText" intptr, wstr, int, var, int, int, int, int, int
; res = DrawShadowText(hdc, pszText, cch, prc, dwFlags, crText, crShadow, ixOffset, iyOffset)
; hdc : HDC -> "intptr"
; pszText : LPCWSTR -> "wstr"
; cch : DWORD -> "int"
; prc : RECT* -> "var"
; dwFlags : DWORD -> "int"
; crText : COLORREF -> "int"
; crShadow : COLORREF -> "int"
; ixOffset : INT -> "int"
; iyOffset : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	comctl32 = windows.NewLazySystemDLL("COMCTL32.dll")
	procDrawShadowText = comctl32.NewProc("DrawShadowText")
)

// hdc (HDC), pszText (LPCWSTR), cch (DWORD), prc (RECT*), dwFlags (DWORD), crText (COLORREF), crShadow (COLORREF), ixOffset (INT), iyOffset (INT)
r1, _, err := procDrawShadowText.Call(
	uintptr(hdc),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszText))),
	uintptr(cch),
	uintptr(prc),
	uintptr(dwFlags),
	uintptr(crText),
	uintptr(crShadow),
	uintptr(ixOffset),
	uintptr(iyOffset),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function DrawShadowText(
  hdc: THandle;   // HDC
  pszText: PWideChar;   // LPCWSTR
  cch: DWORD;   // DWORD
  prc: Pointer;   // RECT*
  dwFlags: DWORD;   // DWORD
  crText: DWORD;   // COLORREF
  crShadow: DWORD;   // COLORREF
  ixOffset: Integer;   // INT
  iyOffset: Integer   // INT
): Integer; stdcall;
  external 'COMCTL32.dll' name 'DrawShadowText';
result := DllCall("COMCTL32\DrawShadowText"
    , "Ptr", hdc   ; HDC
    , "WStr", pszText   ; LPCWSTR
    , "UInt", cch   ; DWORD
    , "Ptr", prc   ; RECT*
    , "UInt", dwFlags   ; DWORD
    , "UInt", crText   ; COLORREF
    , "UInt", crShadow   ; COLORREF
    , "Int", ixOffset   ; INT
    , "Int", iyOffset   ; INT
    , "Int")   ; return: INT
●DrawShadowText(hdc, pszText, cch, prc, dwFlags, crText, crShadow, ixOffset, iyOffset) = DLL("COMCTL32.dll", "int DrawShadowText(void*, char*, dword, void*, dword, dword, dword, int, int)")
# 呼び出し: DrawShadowText(hdc, pszText, cch, prc, dwFlags, crText, crShadow, ixOffset, iyOffset)
# hdc : HDC -> "void*"
# pszText : LPCWSTR -> "char*"
# cch : DWORD -> "dword"
# prc : RECT* -> "void*"
# dwFlags : DWORD -> "dword"
# crText : COLORREF -> "dword"
# crShadow : COLORREF -> "dword"
# ixOffset : INT -> "int"
# iyOffset : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。