GetWindowSubclass
関数ウィンドウのサブクラス参照データを取得する。
シグネチャ
// COMCTL32.dll
#include <windows.h>
BOOL GetWindowSubclass(
HWND hWnd,
SUBCLASSPROC pfnSubclass,
UINT_PTR uIdSubclass,
UINT_PTR* pdwRefData // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hWnd | HWND | in |
| pfnSubclass | SUBCLASSPROC | in |
| uIdSubclass | UINT_PTR | in |
| pdwRefData | UINT_PTR* | outoptional |
戻り値の型: BOOL
各言語での呼び出し定義
// COMCTL32.dll
#include <windows.h>
BOOL GetWindowSubclass(
HWND hWnd,
SUBCLASSPROC pfnSubclass,
UINT_PTR uIdSubclass,
UINT_PTR* pdwRefData // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("COMCTL32.dll", ExactSpelling = true)]
static extern bool GetWindowSubclass(
IntPtr hWnd, // HWND
IntPtr pfnSubclass, // SUBCLASSPROC
UIntPtr uIdSubclass, // UINT_PTR
IntPtr pdwRefData // UINT_PTR* optional, out
);<DllImport("COMCTL32.dll", ExactSpelling:=True)>
Public Shared Function GetWindowSubclass(
hWnd As IntPtr, ' HWND
pfnSubclass As IntPtr, ' SUBCLASSPROC
uIdSubclass As UIntPtr, ' UINT_PTR
pdwRefData As IntPtr ' UINT_PTR* optional, out
) As Boolean
End Function' hWnd : HWND
' pfnSubclass : SUBCLASSPROC
' uIdSubclass : UINT_PTR
' pdwRefData : UINT_PTR* optional, out
Declare PtrSafe Function GetWindowSubclass Lib "comctl32" ( _
ByVal hWnd As LongPtr, _
ByVal pfnSubclass As LongPtr, _
ByVal uIdSubclass As LongPtr, _
ByVal pdwRefData As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetWindowSubclass = ctypes.windll.comctl32.GetWindowSubclass
GetWindowSubclass.restype = wintypes.BOOL
GetWindowSubclass.argtypes = [
wintypes.HANDLE, # hWnd : HWND
ctypes.c_void_p, # pfnSubclass : SUBCLASSPROC
ctypes.c_size_t, # uIdSubclass : UINT_PTR
ctypes.POINTER(ctypes.c_size_t), # pdwRefData : UINT_PTR* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('COMCTL32.dll')
GetWindowSubclass = Fiddle::Function.new(
lib['GetWindowSubclass'],
[
Fiddle::TYPE_VOIDP, # hWnd : HWND
Fiddle::TYPE_VOIDP, # pfnSubclass : SUBCLASSPROC
Fiddle::TYPE_UINTPTR_T, # uIdSubclass : UINT_PTR
Fiddle::TYPE_VOIDP, # pdwRefData : UINT_PTR* optional, out
],
Fiddle::TYPE_INT)#[link(name = "comctl32")]
extern "system" {
fn GetWindowSubclass(
hWnd: *mut core::ffi::c_void, // HWND
pfnSubclass: *const core::ffi::c_void, // SUBCLASSPROC
uIdSubclass: usize, // UINT_PTR
pdwRefData: *mut usize // UINT_PTR* optional, out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("COMCTL32.dll")]
public static extern bool GetWindowSubclass(IntPtr hWnd, IntPtr pfnSubclass, UIntPtr uIdSubclass, IntPtr pdwRefData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'COMCTL32_GetWindowSubclass' -Namespace Win32 -PassThru
# $api::GetWindowSubclass(hWnd, pfnSubclass, uIdSubclass, pdwRefData)#uselib "COMCTL32.dll"
#func global GetWindowSubclass "GetWindowSubclass" sptr, sptr, sptr, sptr
; GetWindowSubclass hWnd, pfnSubclass, uIdSubclass, varptr(pdwRefData) ; 戻り値は stat
; hWnd : HWND -> "sptr"
; pfnSubclass : SUBCLASSPROC -> "sptr"
; uIdSubclass : UINT_PTR -> "sptr"
; pdwRefData : UINT_PTR* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "COMCTL32.dll" #cfunc global GetWindowSubclass "GetWindowSubclass" sptr, sptr, sptr, var ; res = GetWindowSubclass(hWnd, pfnSubclass, uIdSubclass, pdwRefData) ; hWnd : HWND -> "sptr" ; pfnSubclass : SUBCLASSPROC -> "sptr" ; uIdSubclass : UINT_PTR -> "sptr" ; pdwRefData : UINT_PTR* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "COMCTL32.dll" #cfunc global GetWindowSubclass "GetWindowSubclass" sptr, sptr, sptr, sptr ; res = GetWindowSubclass(hWnd, pfnSubclass, uIdSubclass, varptr(pdwRefData)) ; hWnd : HWND -> "sptr" ; pfnSubclass : SUBCLASSPROC -> "sptr" ; uIdSubclass : UINT_PTR -> "sptr" ; pdwRefData : UINT_PTR* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GetWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uIdSubclass, UINT_PTR* pdwRefData) #uselib "COMCTL32.dll" #cfunc global GetWindowSubclass "GetWindowSubclass" intptr, intptr, intptr, var ; res = GetWindowSubclass(hWnd, pfnSubclass, uIdSubclass, pdwRefData) ; hWnd : HWND -> "intptr" ; pfnSubclass : SUBCLASSPROC -> "intptr" ; uIdSubclass : UINT_PTR -> "intptr" ; pdwRefData : UINT_PTR* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uIdSubclass, UINT_PTR* pdwRefData) #uselib "COMCTL32.dll" #cfunc global GetWindowSubclass "GetWindowSubclass" intptr, intptr, intptr, intptr ; res = GetWindowSubclass(hWnd, pfnSubclass, uIdSubclass, varptr(pdwRefData)) ; hWnd : HWND -> "intptr" ; pfnSubclass : SUBCLASSPROC -> "intptr" ; uIdSubclass : UINT_PTR -> "intptr" ; pdwRefData : UINT_PTR* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
comctl32 = windows.NewLazySystemDLL("COMCTL32.dll")
procGetWindowSubclass = comctl32.NewProc("GetWindowSubclass")
)
// hWnd (HWND), pfnSubclass (SUBCLASSPROC), uIdSubclass (UINT_PTR), pdwRefData (UINT_PTR* optional, out)
r1, _, err := procGetWindowSubclass.Call(
uintptr(hWnd),
uintptr(pfnSubclass),
uintptr(uIdSubclass),
uintptr(pdwRefData),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetWindowSubclass(
hWnd: THandle; // HWND
pfnSubclass: Pointer; // SUBCLASSPROC
uIdSubclass: NativeUInt; // UINT_PTR
pdwRefData: Pointer // UINT_PTR* optional, out
): BOOL; stdcall;
external 'COMCTL32.dll' name 'GetWindowSubclass';result := DllCall("COMCTL32\GetWindowSubclass"
, "Ptr", hWnd ; HWND
, "Ptr", pfnSubclass ; SUBCLASSPROC
, "UPtr", uIdSubclass ; UINT_PTR
, "Ptr", pdwRefData ; UINT_PTR* optional, out
, "Int") ; return: BOOL●GetWindowSubclass(hWnd, pfnSubclass, uIdSubclass, pdwRefData) = DLL("COMCTL32.dll", "bool GetWindowSubclass(void*, void*, int, void*)")
# 呼び出し: GetWindowSubclass(hWnd, pfnSubclass, uIdSubclass, pdwRefData)
# hWnd : HWND -> "void*"
# pfnSubclass : SUBCLASSPROC -> "void*"
# uIdSubclass : UINT_PTR -> "int"
# pdwRefData : UINT_PTR* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。