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

GdipSetPageScale

関数
Graphicsのページスケールを設定する。
DLLgdiplus.dll呼出規約winapi

シグネチャ

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

Status GdipSetPageScale(
    GpGraphics* graphics,
    FLOAT scale
);

パラメーター

名前方向
graphicsGpGraphics*inout
scaleFLOATin

戻り値の型: Status

各言語での呼び出し定義

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

Status GdipSetPageScale(
    GpGraphics* graphics,
    FLOAT scale
);
[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipSetPageScale(
    IntPtr graphics,   // GpGraphics* in/out
    float scale   // FLOAT
);
<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipSetPageScale(
    graphics As IntPtr,   ' GpGraphics* in/out
    scale As Single   ' FLOAT
) As Integer
End Function
' graphics : GpGraphics* in/out
' scale : FLOAT
Declare PtrSafe Function GdipSetPageScale Lib "gdiplus" ( _
    ByVal graphics As LongPtr, _
    ByVal scale As Single) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GdipSetPageScale = ctypes.windll.gdiplus.GdipSetPageScale
GdipSetPageScale.restype = ctypes.c_int
GdipSetPageScale.argtypes = [
    ctypes.c_void_p,  # graphics : GpGraphics* in/out
    ctypes.c_float,  # scale : FLOAT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('gdiplus.dll')
GdipSetPageScale = Fiddle::Function.new(
  lib['GdipSetPageScale'],
  [
    Fiddle::TYPE_VOIDP,  # graphics : GpGraphics* in/out
    Fiddle::TYPE_FLOAT,  # scale : FLOAT
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdiplus")]
extern "system" {
    fn GdipSetPageScale(
        graphics: *mut GpGraphics,  // GpGraphics* in/out
        scale: f32  // FLOAT
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("gdiplus.dll")]
public static extern int GdipSetPageScale(IntPtr graphics, float scale);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipSetPageScale' -Namespace Win32 -PassThru
# $api::GdipSetPageScale(graphics, scale)
#uselib "gdiplus.dll"
#func global GdipSetPageScale "GdipSetPageScale" sptr, float
; GdipSetPageScale varptr(graphics), scale   ; 戻り値は stat
; graphics : GpGraphics* in/out -> "sptr"
; scale : FLOAT -> "float"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "gdiplus.dll"
#cfunc global GdipSetPageScale "GdipSetPageScale" var, float
; res = GdipSetPageScale(graphics, scale)
; graphics : GpGraphics* in/out -> "var"
; scale : FLOAT -> "float"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; Status GdipSetPageScale(GpGraphics* graphics, FLOAT scale)
#uselib "gdiplus.dll"
#cfunc global GdipSetPageScale "GdipSetPageScale" var, float
; res = GdipSetPageScale(graphics, scale)
; graphics : GpGraphics* in/out -> "var"
; scale : FLOAT -> "float"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"math"
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
	procGdipSetPageScale = gdiplus.NewProc("GdipSetPageScale")
)

// graphics (GpGraphics* in/out), scale (FLOAT)
r1, _, err := procGdipSetPageScale.Call(
	uintptr(graphics),
	uintptr(math.Float32bits(scale)),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // Status
// 注意: float/double 引数は proc.Call では XMM レジスタに渡せません。
// windows.SyscallN(proc.Addr(), math.Float64bits(x), ...) もしくは cgo を使用してください。
function GdipSetPageScale(
  graphics: Pointer;   // GpGraphics* in/out
  scale: Single   // FLOAT
): Integer; stdcall;
  external 'gdiplus.dll' name 'GdipSetPageScale';
result := DllCall("gdiplus\GdipSetPageScale"
    , "Ptr", graphics   ; GpGraphics* in/out
    , "Float", scale   ; FLOAT
    , "Int")   ; return: Status
●GdipSetPageScale(graphics, scale) = DLL("gdiplus.dll", "int GdipSetPageScale(void*, float)")
# 呼び出し: GdipSetPageScale(graphics, scale)
# graphics : GpGraphics* in/out -> "void*"
# scale : FLOAT -> "float"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。