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

LPtoDP

関数
論理座標をデバイス座標に変換する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL LPtoDP(
    HDC hdc,
    POINT* lppt,
    INT c
);

パラメーター

名前方向
hdcHDCin
lpptPOINT*inout
cINTin

戻り値の型: BOOL

各言語での呼び出し定義

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

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

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

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

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procLPtoDP = gdi32.NewProc("LPtoDP")
)

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