ホーム › Graphics.Gdi › SetViewportOrgEx
SetViewportOrgEx
関数ビューポートの原点を設定する。
シグネチャ
// GDI32.dll
#include <windows.h>
BOOL SetViewportOrgEx(
HDC hdc,
INT x,
INT y,
POINT* lppt // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hdc | HDC | in | デバイスコンテキストへのハンドル。 |
| x | INT | in | 新しいビューポート原点の x 座標(デバイス単位)。 |
| y | INT | in | 新しいビューポート原点の y 座標(デバイス単位)。 |
| lppt | POINT* | outoptional | 以前のビューポート原点をデバイス座標で受け取る POINT 構造体へのポインター。lpPoint が NULL の場合、このパラメーターは使用されません。 |
戻り値の型: BOOL
公式ドキュメント
SetViewportOrgEx 関数は、どのデバイス座標上の点がウィンドウ原点 (0,0) にマップされるかを指定します。
戻り値
関数が成功した場合、戻り値は 0 以外の値です。
関数が失敗した場合、戻り値は 0 です。
解説(Remarks)
この関数は(SetViewportExtEx および SetWindowExtEx とともに)、論理座標空間(ウィンドウとも呼ばれます)からデバイス座標空間(ビューポート)へのマッピングを定義するのに役立ちます。SetViewportOrgEx は、どのデバイス座標上の点が論理座標 (0,0) にマップされるかを指定します。これは、論理座標 (0,0) が左上隅を指さないように軸を移動する効果があります。
//map the logical point (0,0) to the device point (xViewOrg, yViewOrg)
SetViewportOrgEx ( hdc, xViewOrg, yViewOrg, NULL)
これは SetWindowOrgEx 関数に関連しています。通常は、どちらか一方の関数を使用し、両方を使用することはありません。SetWindowOrgEx と SetViewportOrgEx の使用に関わらず、デバイス座標 (0,0) は常に左上隅です。
例
例については、Redrawing in the Update Region を参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// GDI32.dll
#include <windows.h>
BOOL SetViewportOrgEx(
HDC hdc,
INT x,
INT y,
POINT* lppt // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern bool SetViewportOrgEx(
IntPtr hdc, // HDC
int x, // INT
int y, // INT
IntPtr lppt // POINT* optional, out
);<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function SetViewportOrgEx(
hdc As IntPtr, ' HDC
x As Integer, ' INT
y As Integer, ' INT
lppt As IntPtr ' POINT* optional, out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' hdc : HDC
' x : INT
' y : INT
' lppt : POINT* optional, out
Declare PtrSafe Function SetViewportOrgEx 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
SetViewportOrgEx = ctypes.windll.gdi32.SetViewportOrgEx
SetViewportOrgEx.restype = wintypes.BOOL
SetViewportOrgEx.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')
SetViewportOrgEx = Fiddle::Function.new(
lib['SetViewportOrgEx'],
[
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 SetViewportOrgEx(
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 SetViewportOrgEx(IntPtr hdc, int x, int y, IntPtr lppt);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_SetViewportOrgEx' -Namespace Win32 -PassThru
# $api::SetViewportOrgEx(hdc, x, y, lppt)#uselib "GDI32.dll"
#func global SetViewportOrgEx "SetViewportOrgEx" sptr, sptr, sptr, sptr
; SetViewportOrgEx 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 SetViewportOrgEx "SetViewportOrgEx" sptr, int, int, var ; res = SetViewportOrgEx(hdc, x, y, lppt) ; hdc : HDC -> "sptr" ; x : INT -> "int" ; y : INT -> "int" ; lppt : POINT* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "GDI32.dll" #cfunc global SetViewportOrgEx "SetViewportOrgEx" sptr, int, int, sptr ; res = SetViewportOrgEx(hdc, x, y, varptr(lppt)) ; hdc : HDC -> "sptr" ; x : INT -> "int" ; y : INT -> "int" ; lppt : POINT* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL SetViewportOrgEx(HDC hdc, INT x, INT y, POINT* lppt) #uselib "GDI32.dll" #cfunc global SetViewportOrgEx "SetViewportOrgEx" intptr, int, int, var ; res = SetViewportOrgEx(hdc, x, y, lppt) ; hdc : HDC -> "intptr" ; x : INT -> "int" ; y : INT -> "int" ; lppt : POINT* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL SetViewportOrgEx(HDC hdc, INT x, INT y, POINT* lppt) #uselib "GDI32.dll" #cfunc global SetViewportOrgEx "SetViewportOrgEx" intptr, int, int, intptr ; res = SetViewportOrgEx(hdc, x, y, varptr(lppt)) ; hdc : HDC -> "intptr" ; x : INT -> "int" ; y : INT -> "int" ; lppt : POINT* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdi32 = windows.NewLazySystemDLL("GDI32.dll")
procSetViewportOrgEx = gdi32.NewProc("SetViewportOrgEx")
)
// hdc (HDC), x (INT), y (INT), lppt (POINT* optional, out)
r1, _, err := procSetViewportOrgEx.Call(
uintptr(hdc),
uintptr(x),
uintptr(y),
uintptr(lppt),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetViewportOrgEx(
hdc: THandle; // HDC
x: Integer; // INT
y: Integer; // INT
lppt: Pointer // POINT* optional, out
): BOOL; stdcall;
external 'GDI32.dll' name 'SetViewportOrgEx';result := DllCall("GDI32\SetViewportOrgEx"
, "Ptr", hdc ; HDC
, "Int", x ; INT
, "Int", y ; INT
, "Ptr", lppt ; POINT* optional, out
, "Int") ; return: BOOL●SetViewportOrgEx(hdc, x, y, lppt) = DLL("GDI32.dll", "bool SetViewportOrgEx(void*, int, int, void*)")
# 呼び出し: SetViewportOrgEx(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)。const std = @import("std");
extern "gdi32" fn SetViewportOrgEx(
hdc: ?*anyopaque, // HDC
x: i32, // INT
y: i32, // INT
lppt: [*c]POINT // POINT* optional, out
) callconv(std.os.windows.WINAPI) i32;proc SetViewportOrgEx(
hdc: pointer, # HDC
x: int32, # INT
y: int32, # INT
lppt: ptr POINT # POINT* optional, out
): int32 {.importc: "SetViewportOrgEx", stdcall, dynlib: "GDI32.dll".}pragma(lib, "gdi32");
extern(Windows)
int SetViewportOrgEx(
void* hdc, // HDC
int x, // INT
int y, // INT
POINT* lppt // POINT* optional, out
);ccall((:SetViewportOrgEx, "GDI32.dll"), stdcall, Int32,
(Ptr{Cvoid}, Int32, Int32, Ptr{POINT}),
hdc, x, y, lppt)
# hdc : HDC -> Ptr{Cvoid}
# x : INT -> Int32
# y : INT -> Int32
# lppt : POINT* optional, out -> Ptr{POINT}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SetViewportOrgEx(
void* hdc,
int32_t x,
int32_t y,
void* lppt);
]]
local gdi32 = ffi.load("gdi32")
-- gdi32.SetViewportOrgEx(hdc, x, y, lppt)
-- hdc : HDC
-- x : INT
-- y : INT
-- lppt : POINT* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('GDI32.dll');
const SetViewportOrgEx = lib.func('__stdcall', 'SetViewportOrgEx', 'int32_t', ['void *', 'int32_t', 'int32_t', 'void *']);
// SetViewportOrgEx(hdc, x, y, lppt)
// hdc : HDC -> 'void *'
// x : INT -> 'int32_t'
// y : INT -> 'int32_t'
// lppt : POINT* optional, out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("GDI32.dll", {
SetViewportOrgEx: { parameters: ["pointer", "i32", "i32", "pointer"], result: "i32" },
});
// lib.symbols.SetViewportOrgEx(hdc, x, y, lppt)
// hdc : HDC -> "pointer"
// x : INT -> "i32"
// y : INT -> "i32"
// lppt : POINT* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SetViewportOrgEx(
void* hdc,
int32_t x,
int32_t y,
void* lppt);
C, "GDI32.dll");
// $ffi->SetViewportOrgEx(hdc, x, y, lppt);
// hdc : HDC
// x : INT
// y : INT
// lppt : POINT* optional, out
// 構造体/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 Gdi32 extends StdCallLibrary {
Gdi32 INSTANCE = Native.load("gdi32", Gdi32.class);
boolean SetViewportOrgEx(
Pointer hdc, // HDC
int x, // INT
int y, // INT
Pointer lppt // POINT* optional, out
);
}@[Link("gdi32")]
lib LibGDI32
fun SetViewportOrgEx = SetViewportOrgEx(
hdc : Void*, # HDC
x : Int32, # INT
y : Int32, # INT
lppt : POINT* # POINT* optional, out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SetViewportOrgExNative = Int32 Function(Pointer<Void>, Int32, Int32, Pointer<Void>);
typedef SetViewportOrgExDart = int Function(Pointer<Void>, int, int, Pointer<Void>);
final SetViewportOrgEx = DynamicLibrary.open('GDI32.dll')
.lookupFunction<SetViewportOrgExNative, SetViewportOrgExDart>('SetViewportOrgEx');
// hdc : HDC -> Pointer<Void>
// x : INT -> Int32
// y : INT -> Int32
// lppt : POINT* optional, out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SetViewportOrgEx(
hdc: THandle; // HDC
x: Integer; // INT
y: Integer; // INT
lppt: Pointer // POINT* optional, out
): BOOL; stdcall;
external 'GDI32.dll' name 'SetViewportOrgEx';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetViewportOrgEx"
c_SetViewportOrgEx :: Ptr () -> Int32 -> Int32 -> Ptr () -> IO CInt
-- hdc : HDC -> Ptr ()
-- x : INT -> Int32
-- y : INT -> Int32
-- lppt : POINT* optional, out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setviewportorgex =
foreign "SetViewportOrgEx"
((ptr void) @-> int32_t @-> int32_t @-> (ptr void) @-> returning int32_t)
(* hdc : HDC -> (ptr void) *)
(* x : INT -> int32_t *)
(* y : INT -> int32_t *)
(* lppt : POINT* optional, out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library gdi32 (t "GDI32.dll"))
(cffi:use-foreign-library gdi32)
(cffi:defcfun ("SetViewportOrgEx" set-viewport-org-ex :convention :stdcall) :int32
(hdc :pointer) ; HDC
(x :int32) ; INT
(y :int32) ; INT
(lppt :pointer)) ; POINT* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetViewportOrgEx = Win32::API::More->new('GDI32',
'BOOL SetViewportOrgEx(HANDLE hdc, int x, int y, LPVOID lppt)');
# my $ret = $SetViewportOrgEx->Call($hdc, $x, $y, $lppt);
# hdc : HDC -> HANDLE
# x : INT -> int
# y : INT -> int
# lppt : POINT* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f GetViewportOrgEx — DCのビューポートの原点を取得する。
- f SetWindowOrgEx — ウィンドウの原点を設定する。
使用する型