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