Win32 API 日本語リファレンス
ホームGraphics.Gdi › CreateFontIndirectA

CreateFontIndirectA

関数
LOGFONT構造体の指定に基づき論理フォントを作成する(ANSI版)。
DLLGDI32.dll文字セットANSI (-A)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// GDI32.dll  (ANSI / -A)
#include <windows.h>

HFONT CreateFontIndirectA(
    const LOGFONTA* lplf
);

パラメーター

名前方向
lplfLOGFONTA*in

戻り値の型: HFONT

各言語での呼び出し定義

// GDI32.dll  (ANSI / -A)
#include <windows.h>

HFONT CreateFontIndirectA(
    const LOGFONTA* lplf
);
[DllImport("GDI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern IntPtr CreateFontIndirectA(
    IntPtr lplf   // LOGFONTA*
);
<DllImport("GDI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function CreateFontIndirectA(
    lplf As IntPtr   ' LOGFONTA*
) As IntPtr
End Function
' lplf : LOGFONTA*
Declare PtrSafe Function CreateFontIndirectA Lib "gdi32" ( _
    ByVal lplf As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CreateFontIndirectA = ctypes.windll.gdi32.CreateFontIndirectA
CreateFontIndirectA.restype = ctypes.c_void_p
CreateFontIndirectA.argtypes = [
    ctypes.c_void_p,  # lplf : LOGFONTA*
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
CreateFontIndirectA = Fiddle::Function.new(
  lib['CreateFontIndirectA'],
  [
    Fiddle::TYPE_VOIDP,  # lplf : LOGFONTA*
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "gdi32")]
extern "system" {
    fn CreateFontIndirectA(
        lplf: *const LOGFONTA  // LOGFONTA*
    ) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("GDI32.dll", CharSet = CharSet.Ansi)]
public static extern IntPtr CreateFontIndirectA(IntPtr lplf);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_CreateFontIndirectA' -Namespace Win32 -PassThru
# $api::CreateFontIndirectA(lplf)
#uselib "GDI32.dll"
#func global CreateFontIndirectA "CreateFontIndirectA" sptr
; CreateFontIndirectA varptr(lplf)   ; 戻り値は stat
; lplf : LOGFONTA* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "GDI32.dll"
#cfunc global CreateFontIndirectA "CreateFontIndirectA" var
; res = CreateFontIndirectA(lplf)
; lplf : LOGFONTA* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HFONT CreateFontIndirectA(LOGFONTA* lplf)
#uselib "GDI32.dll"
#cfunc global CreateFontIndirectA "CreateFontIndirectA" var
; res = CreateFontIndirectA(lplf)
; lplf : LOGFONTA* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procCreateFontIndirectA = gdi32.NewProc("CreateFontIndirectA")
)

// lplf (LOGFONTA*)
r1, _, err := procCreateFontIndirectA.Call(
	uintptr(lplf),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HFONT
function CreateFontIndirectA(
  lplf: Pointer   // LOGFONTA*
): THandle; stdcall;
  external 'GDI32.dll' name 'CreateFontIndirectA';
result := DllCall("GDI32\CreateFontIndirectA"
    , "Ptr", lplf   ; LOGFONTA*
    , "Ptr")   ; return: HFONT
●CreateFontIndirectA(lplf) = DLL("GDI32.dll", "void* CreateFontIndirectA(void*)")
# 呼び出し: CreateFontIndirectA(lplf)
# lplf : LOGFONTA* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。