〜 オブジェクト 〜
オブジェクトタイプを取得 (要USER32.DLL)

モジュールで配置したオブジェクトを操作するときに、
指定されたオブジェクトが処理すべきオブジェクトなのかを判断しなければならないときもあります。
このサンプルモジュールでも呼び出しているAPI関数のGetClassNameを使えば、
インプットボックスなら「Edit」のように、Windowsに登録されているオブジェクト名で取得できます。
	

getobjtype オブジェクトID
オブジェクトID種類の確認をするオブジェクトIDを指定する。
尚、指定するオブジェクトIDが1000以上だと拡張オブジェクトとして処理する。
無事に取得できると、システム変数refstrに代入される。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
	ll_libload user, "user32.dll"
	ll_getproc GetClassName, "GetClassNameA", user

#module
#deffunc getobjtype int
	mref id, 0
	mref bmscr, 67
	if id < 1000 : id += 41 : id = bmscr.id
	mref result, 65
	ll_getptr result
	ll_ret sptr
	prm = id, sptr, 64
	ll_callfunc prm, 3, GetClassName@
	return
#global

	sdim data, 32, 4
	dim index, 2
	data = "Input内容", "L\ni\ns\nt\n内\n容", "C\no\nm\nb\no\n内\n容"
	objsize 100, 20
	pos  10, 50 : button "終了", *exit
	pos 120, 50 : input data
	pos 230, 50 : listbox index, 80, data.1
	pos 340, 50 : combox index.1, 80, data.2
	repeat 4
		getobjtype cnt
		pos cnt * 110 + 10, 10 : mes refstr
	loop
	stop

*exit
	end

タイプ = getobjtype(オブジェクトID)
タイプ取得したオブジェクトタイプの格納先を指定する。
オブジェクトID種類の確認をするオブジェクトIDを指定する。
尚、指定するオブジェクトIDが1000以上だと拡張オブジェクトとして処理する。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#uselib "user32.dll"
#func  global GetClassName "GetClassNameA" int, var, int

#module
#defcfunc getobjtype int id, local s, local i
	sdim s, 64
	if id < 1000 : i = objinfo(id, 2) : else : i = id
	GetClassName i, s, 64
	return s
#global

	sdim data, 32, 4
	dim index, 2
	data = "Input内容", "L\ni\ns\nt\n内\n容", "C\no\nm\nb\no\n内\n容"
	objsize 100, 20
	pos  10, 50 : button "終了", *exit
	pos 120, 50 : input data
	pos 230, 50 : listbox index, 50, data.1
	pos 340, 50 : combox index.1, 50, data.2
	repeat 4
		pos cnt * 110 + 10, 10 : mes getobjtype(cnt)
	loop
	stop

*exit
	end