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

OffsetViewportOrgEx

関数
ビューポート原点を相対的に移動する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL OffsetViewportOrgEx(
    HDC hdc,
    INT x,
    INT y,
    POINT* lppt   // optional
);

パラメーター

名前方向
hdcHDCin
xINTin
yINTin
lpptPOINT*outoptional

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL OffsetViewportOrgEx(
    HDC hdc,
    INT x,
    INT y,
    POINT* lppt   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern bool OffsetViewportOrgEx(
    IntPtr hdc,   // HDC
    int x,   // INT
    int y,   // INT
    IntPtr lppt   // POINT* optional, out
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function OffsetViewportOrgEx(
    hdc As IntPtr,   ' HDC
    x As Integer,   ' INT
    y As Integer,   ' INT
    lppt As IntPtr   ' POINT* optional, out
) As Boolean
End Function
' hdc : HDC
' x : INT
' y : INT
' lppt : POINT* optional, out
Declare PtrSafe Function OffsetViewportOrgEx Lib "gdi32" ( _
    ByVal hdc As LongPtr, _
    ByVal x As Long, _
    ByVal y As Long, _
    ByVal lppt As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

OffsetViewportOrgEx = ctypes.windll.gdi32.OffsetViewportOrgEx
OffsetViewportOrgEx.restype = wintypes.BOOL
OffsetViewportOrgEx.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    ctypes.c_int,  # x : INT
    ctypes.c_int,  # y : INT
    ctypes.c_void_p,  # lppt : POINT* optional, out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procOffsetViewportOrgEx = gdi32.NewProc("OffsetViewportOrgEx")
)

// hdc (HDC), x (INT), y (INT), lppt (POINT* optional, out)
r1, _, err := procOffsetViewportOrgEx.Call(
	uintptr(hdc),
	uintptr(x),
	uintptr(y),
	uintptr(lppt),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function OffsetViewportOrgEx(
  hdc: THandle;   // HDC
  x: Integer;   // INT
  y: Integer;   // INT
  lppt: Pointer   // POINT* optional, out
): BOOL; stdcall;
  external 'GDI32.dll' name 'OffsetViewportOrgEx';
result := DllCall("GDI32\OffsetViewportOrgEx"
    , "Ptr", hdc   ; HDC
    , "Int", x   ; INT
    , "Int", y   ; INT
    , "Ptr", lppt   ; POINT* optional, out
    , "Int")   ; return: BOOL
●OffsetViewportOrgEx(hdc, x, y, lppt) = DLL("GDI32.dll", "bool OffsetViewportOrgEx(void*, int, int, void*)")
# 呼び出し: OffsetViewportOrgEx(hdc, x, y, lppt)
# hdc : HDC -> "void*"
# x : INT -> "int"
# y : INT -> "int"
# lppt : POINT* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。