Win32 API 日本語リファレンス
ホームUI.HiDpi › LogicalToPhysicalPointForPerMonitorDPI

LogicalToPhysicalPointForPerMonitorDPI

関数
モニターごとDPI環境で論理座標を物理座標へ変換する。
DLLUSER32.dll呼出規約winapi対応OSWindows 8.1 以降

シグネチャ

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

BOOL LogicalToPhysicalPointForPerMonitorDPI(
    HWND hWnd,   // optional
    POINT* lpPoint
);

パラメーター

名前方向
hWndHWNDinoptional
lpPointPOINT*inout

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL LogicalToPhysicalPointForPerMonitorDPI(
    HWND hWnd,   // optional
    POINT* lpPoint
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", ExactSpelling = true)]
static extern bool LogicalToPhysicalPointForPerMonitorDPI(
    IntPtr hWnd,   // HWND optional
    IntPtr lpPoint   // POINT* in/out
);
<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function LogicalToPhysicalPointForPerMonitorDPI(
    hWnd As IntPtr,   ' HWND optional
    lpPoint As IntPtr   ' POINT* in/out
) As Boolean
End Function
' hWnd : HWND optional
' lpPoint : POINT* in/out
Declare PtrSafe Function LogicalToPhysicalPointForPerMonitorDPI Lib "user32" ( _
    ByVal hWnd As LongPtr, _
    ByVal lpPoint As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

LogicalToPhysicalPointForPerMonitorDPI = ctypes.windll.user32.LogicalToPhysicalPointForPerMonitorDPI
LogicalToPhysicalPointForPerMonitorDPI.restype = wintypes.BOOL
LogicalToPhysicalPointForPerMonitorDPI.argtypes = [
    wintypes.HANDLE,  # hWnd : HWND optional
    ctypes.c_void_p,  # lpPoint : POINT* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procLogicalToPhysicalPointForPerMonitorDPI = user32.NewProc("LogicalToPhysicalPointForPerMonitorDPI")
)

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