ホーム › Graphics.Gdi › GetCurrentPositionEx
GetCurrentPositionEx
関数DCの現在の描画位置を取得する。
シグネチャ
// GDI32.dll
#include <windows.h>
BOOL GetCurrentPositionEx(
HDC hdc,
POINT* lppt
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hdc | HDC | in |
| lppt | POINT* | out |
戻り値の型: BOOL
各言語での呼び出し定義
// GDI32.dll
#include <windows.h>
BOOL GetCurrentPositionEx(
HDC hdc,
POINT* lppt
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern bool GetCurrentPositionEx(
IntPtr hdc, // HDC
IntPtr lppt // POINT* out
);<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function GetCurrentPositionEx(
hdc As IntPtr, ' HDC
lppt As IntPtr ' POINT* out
) As Boolean
End Function' hdc : HDC
' lppt : POINT* out
Declare PtrSafe Function GetCurrentPositionEx Lib "gdi32" ( _
ByVal hdc As LongPtr, _
ByVal lppt As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetCurrentPositionEx = ctypes.windll.gdi32.GetCurrentPositionEx
GetCurrentPositionEx.restype = wintypes.BOOL
GetCurrentPositionEx.argtypes = [
wintypes.HANDLE, # hdc : HDC
ctypes.c_void_p, # lppt : POINT* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GDI32.dll')
GetCurrentPositionEx = Fiddle::Function.new(
lib['GetCurrentPositionEx'],
[
Fiddle::TYPE_VOIDP, # hdc : HDC
Fiddle::TYPE_VOIDP, # lppt : POINT* out
],
Fiddle::TYPE_INT)#[link(name = "gdi32")]
extern "system" {
fn GetCurrentPositionEx(
hdc: *mut core::ffi::c_void, // HDC
lppt: *mut POINT // POINT* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll")]
public static extern bool GetCurrentPositionEx(IntPtr hdc, IntPtr lppt);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_GetCurrentPositionEx' -Namespace Win32 -PassThru
# $api::GetCurrentPositionEx(hdc, lppt)#uselib "GDI32.dll"
#func global GetCurrentPositionEx "GetCurrentPositionEx" sptr, sptr
; GetCurrentPositionEx hdc, varptr(lppt) ; 戻り値は stat
; hdc : HDC -> "sptr"
; lppt : POINT* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "GDI32.dll" #cfunc global GetCurrentPositionEx "GetCurrentPositionEx" sptr, var ; res = GetCurrentPositionEx(hdc, lppt) ; hdc : HDC -> "sptr" ; lppt : POINT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "GDI32.dll" #cfunc global GetCurrentPositionEx "GetCurrentPositionEx" sptr, sptr ; res = GetCurrentPositionEx(hdc, varptr(lppt)) ; hdc : HDC -> "sptr" ; lppt : POINT* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GetCurrentPositionEx(HDC hdc, POINT* lppt) #uselib "GDI32.dll" #cfunc global GetCurrentPositionEx "GetCurrentPositionEx" intptr, var ; res = GetCurrentPositionEx(hdc, lppt) ; hdc : HDC -> "intptr" ; lppt : POINT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetCurrentPositionEx(HDC hdc, POINT* lppt) #uselib "GDI32.dll" #cfunc global GetCurrentPositionEx "GetCurrentPositionEx" intptr, intptr ; res = GetCurrentPositionEx(hdc, varptr(lppt)) ; hdc : HDC -> "intptr" ; lppt : POINT* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdi32 = windows.NewLazySystemDLL("GDI32.dll")
procGetCurrentPositionEx = gdi32.NewProc("GetCurrentPositionEx")
)
// hdc (HDC), lppt (POINT* out)
r1, _, err := procGetCurrentPositionEx.Call(
uintptr(hdc),
uintptr(lppt),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetCurrentPositionEx(
hdc: THandle; // HDC
lppt: Pointer // POINT* out
): BOOL; stdcall;
external 'GDI32.dll' name 'GetCurrentPositionEx';result := DllCall("GDI32\GetCurrentPositionEx"
, "Ptr", hdc ; HDC
, "Ptr", lppt ; POINT* out
, "Int") ; return: BOOL●GetCurrentPositionEx(hdc, lppt) = DLL("GDI32.dll", "bool GetCurrentPositionEx(void*, void*)")
# 呼び出し: GetCurrentPositionEx(hdc, lppt)
# hdc : HDC -> "void*"
# lppt : POINT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。