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

DPtoLP

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

シグネチャ

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

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

パラメーター

名前方向
hdcHDCin
lpptPOINT*inout
cINTin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL DPtoLP(
    HDC hdc,
    POINT* lppt,
    INT c
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern bool DPtoLP(
    IntPtr hdc,   // HDC
    IntPtr lppt,   // POINT* in/out
    int c   // INT
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function DPtoLP(
    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 DPtoLP 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

DPtoLP = ctypes.windll.gdi32.DPtoLP
DPtoLP.restype = wintypes.BOOL
DPtoLP.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')
DPtoLP = Fiddle::Function.new(
  lib['DPtoLP'],
  [
    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 DPtoLP(
        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 DPtoLP(IntPtr hdc, IntPtr lppt, int c);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_DPtoLP' -Namespace Win32 -PassThru
# $api::DPtoLP(hdc, lppt, c)
#uselib "GDI32.dll"
#func global DPtoLP "DPtoLP" sptr, sptr, sptr
; DPtoLP 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 DPtoLP "DPtoLP" sptr, var, int
; res = DPtoLP(hdc, lppt, c)
; hdc : HDC -> "sptr"
; lppt : POINT* in/out -> "var"
; c : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL DPtoLP(HDC hdc, POINT* lppt, INT c)
#uselib "GDI32.dll"
#cfunc global DPtoLP "DPtoLP" intptr, var, int
; res = DPtoLP(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")
	procDPtoLP = gdi32.NewProc("DPtoLP")
)

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