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