きたないサンプルですが、良ければどうぞ。
一応、HSP標準命令で設置できるオブジェクトには対応しているはずです。
// オブジェクトIDからオブジェクトの種類を取得するサンプル
#module
#uselib "user32.dll"
#func GetClassName "GetClassNameA" sptr,sptr,sptr
#func GetWindowLong "GetWindowLongA" sptr,sptr
; p1 = オブジェクトのID
; p2 = オブジェクトの種類を代入する変数
; p3 = 取得するクラス名の長さ
#deffunc GetObjType int objId, var ClassName, int nMaxCount
objHwnd = objinfo_hwnd(objId) // IDをハンドルに変換
// クラス名取得
sdim ClassName,nMaxCount
GetClassName objHwnd,varptr(ClassName),nMaxCount
// chkbox判定
if ClassName=="Button"{
; スタイルに BS_AUTOCHECKBOX が含まれているなら chkbox
GetWindowLong objHwnd,-16
if (stat & 0x00000003){
ClassName = "Chkbox"
}
}
// mesbox input判定
if ClassName=="Edit"{
; スタイルに ES_MULTILINE が含まれているなら mesbox
GetWindowLong objHwnd,-16
if (stat & 0x0004){
ClassName = "mesbox"
}else{
ClassName = "input"
}
}
return
#global
title "オブジェクトIDからオブジェクトの種類を取得"
color 0,0,255: boxf
// オブジェクト設置
objsize ginfo_winx,25
; button
pos ,ginfo_cy+10
button "button",*hoge
id_button = stat
; chkbox
pos ,ginfo_cy+10
dim x
chkbox "chkbox",x
id_chkbox = stat
; input
pos ,ginfo_cy+10
x = "input"
input x
id_input = stat
; mesbox
pos ,ginfo_cy+10
x = "mesbox"
mesbox x
id_mesbox = stat
; combox
pos ,ginfo_cy+10
dim x
combox x,,"combox \ncombox"
id_combox = stat
; listbox
pos ,ginfo_cy+10
listbox x,0,"listbox"
id_listbox = stat
// 結果
sdim sClassN,256
color 255,255,255
repeat 6
GetObjType cnt, sClassN, 256
mes str(cnt)+":"+sClassN
loop
stop
*hoge