〜 オブジェクト 〜
入力ボックスの外枠を除去 (要USER32.DLL)

inputboxやmesboxlistboxオブジェクトの外枠線をなくすサンプルです。
オブジェクトの外枠は、オブジェクトの拡張ウィンドウスタイルに設定されているので、
オブジェクトスタイルを再設定するAPI関数SetWindowLongWS_EX_CLIENTEDGE(=0x0200)を外しますが、
今回変更するようなオブジェクトの見た目(ウィンドウフレーム)を変更する場合は、
スタイルデータがキャッシュされているためにAPI関数SetWindowLongだけでは不十分です。
オブジェクトの位置やサイズを設定するAPI関数SetWindowPosSWP_FRAMECHANGED(=0x0020)を併用し、
スタイルデータキャッシュを更新してください。
その際、オブジェクトの位置やサイズは変更する必要ないので、SWP_NOSIZE(=0x0001)のサイズ維持、
SWP_NOMOVE(=0x0002)の位置を維持、SWP_NOZORDER(=0x0004)のZオーダー維持フラグを加算しましょう。
尚、上記のオブジェクトタイプの中にcomboxが入っていないのは、
元々WS_EX_CLIENTEDGEによる外枠が設定されていないため、外そうとすれば表示がおかしくなるからです。
	

setobjinfo オブジェクトID, 位置X, 位置Y, 横幅, 高さ, フラグ
オブジェクトID変更対象オブジェクトID指定する。
位置X変更後のX座標を指定する。尚、フラグに2を指定していると位置Xは無視される。
位置Y変更後のY座標を指定する。尚、フラグに2を指定していると位置Yは無視される。
横幅変更後の横幅を指定する。尚、フラグに1を指定していると横幅は無視される。
高さ変更後の高さを指定する。尚、フラグに1を指定していると高さは無視される。
フラグ動作フラグ(-1:スタイル変更時に使用 1:サイズ変更なし 2:位置変更なし)を指定する。

objgetstyle オブジェクトID, 拡張スタイルフラグ
オブジェクトIDスタイルの確認をするオブジェクトIDを指定する。
尚、1000以上だとオブジェクトハンドルとして拡張オブジェクトにも対応。
取得したスタイルはstatに代入する。
拡張スタイルフラグ0又は省略すると標準スタイル、
それ以外を指定すると拡張スタイル値を取得する。

objsetstyle オブジェクトID, 拡張スタイルフラグ, 追加スタイル, 削除スタイル
オブジェクトIDスタイルの変更をするオブジェクトIDを指定する。
尚、1000以上だとオブジェクトハンドルとして拡張オブジェクトにも対応。
拡張スタイルフラグ現在の操作対象ウィンドウのうち、0又は省略すると標準ウィンドウスタイル、
それ以外を指定すると拡張ウィンドウスタイル値を設定する。
追加スタイル現在のスタイルのほかに追加したいスタイル値を指定する。
削除スタイル現在のスタイルのうちで削除したいスタイル値を指定する。

 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
33
34
35
36
37
38
39
40
41
42
43
44
45
	ll_libload user, "user32.dll"
	ll_getproc SetWindowPos, "SetWindowPos", user
	ll_getproc GetWindowLong, "GetWindowLongA", user
	ll_getproc SetWindowLong, "SetWindowLongA", user

#module
#deffunc setobjinfo int, int, int, int, int, int
	mref id, 0 : mref px, 1 : mref py, 2 : mref sx, 3 : mref sy, 4 : mref flg, 5
	mref bmscr, 67
	if id < 1000 : i = id + 41 : i = bmscr.i : else : i = id
	prm = i, 0, px, py, sx, sy, flg = -1 * 0x0027 + (flg ! -1 * flg)
	ll_callfunc prm, 7, SetWindowPos@
	return

#deffunc objgetstyle int, int
	mref id, 0 : mref extflg, 1
	mref stt, 64
	mref bmscr, 67
	if id < 1000 : i = id + 41 : i = bmscr.i : else : i = id
	prm = i, -4 * (extflg ! 0) - 16
	ll_callfunc prm, 2, GetWindowLong@
	ll_ret i : stt = i
	return

#deffunc objsetstyle int, int, int, int
	mref id, 0 : mref extflg, 1 : mref aprm, 2 : mref dprm, 3
	mref bmscr, 67
	objgetstyle id, extflg
	if id < 1000 : i = id + 41 : i = bmscr.i : else : i = id
	prm = i, -4 * (extflg ! 0) - 16, stat | aprm & (stat | aprm ^ dprm)
	ll_callfunc prm, 3, SetWindowLong@
	setobjinfo id, , , , , -1 // 位置・サイズは変更せずにスタイルのみ変更
	return
#global

	color 250, 250, 230 : boxf
	sdim buf, 24, 3
	buf = "Input Box", "Multi Line\nEdit Box", "List\nBox"
	pos 50,  30 : input buf.0, 200, 20
	pos 50,  80 : mesbox buf.1, 150, 100, 1
	pos 50, 200 : listbox index, , buf.2
	objsetstyle 0, 1, , 0x0200 // WS_EX_CLIENTEDGE
	objsetstyle 1, 1, , 0x0200 // WS_EX_CLIENTEDGE
	objsetstyle 2, 1, , 0x0200 // WS_EX_CLIENTEDGE
	stop

取得スタイル = objgetstyle(オブジェクトID, 拡張スタイルフラグ)
取得スタイル取得したスタイル値の受取先を指定する。
オブジェクトIDスタイルの確認をするオブジェクトIDを指定する。
尚、1000以上だとオブジェクトハンドルとして拡張オブジェクトにも対応。
拡張スタイルフラグ0又は省略すると標準スタイル、
それ以外を指定すると拡張スタイル値を取得する。

objsetstyle オブジェクトID, 拡張スタイルフラグ, 追加スタイル, 削除スタイル
オブジェクトIDスタイルの変更をするオブジェクトIDを指定する。
尚、1000以上だとオブジェクトハンドルとして拡張オブジェクトにも対応。
拡張スタイルフラグ現在の操作対象ウィンドウのうち、0又は省略すると標準ウィンドウスタイル、
それ以外を指定すると拡張ウィンドウスタイル値を設定する。
追加スタイル現在のスタイルのほかに追加したいスタイル値を指定する。
削除スタイル現在のスタイルのうちで削除したいスタイル値を指定する。

 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"
#cfunc global GetWindowLong "GetWindowLongA" int, int
#func  global SetWindowLong "SetWindowLongA" int, int, int
#func  global SetWindowPos "SetWindowPos" int, int, int, int, int, int, int

#module
#defcfunc objgetstyle int id, int extflg, local i
	if id < 1000 : i = objinfo(id, 2) : else : i = id
	return GetWindowLong( i, -4 * (extflg ! 0) - 16 )

#deffunc objsetstyle int id, int extflg, int aprm, int dprm, local i
	if id < 1000 : i = objinfo(id, 2) : else : i = id
	SetWindowLong i, -4 * (extflg ! 0) - 16, objgetstyle(id, extflg) | aprm & (objgetstyle(id, extflg) | aprm ^ dprm)
	SetWindowPos i, , , , , , 0x0027 // SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED
	return
#global

	syscolor 15 : boxf
	sdim buf, 24, 3
	buf = "Input Box", "Multi Line\nEdit Box", "List\nBox"
	pos 50,  30 : input buf.0, 200, 20
	pos 50,  80 : mesbox buf.1, 150, 100
	pos 50, 200 : listbox index, , buf.2
	objsetstyle 0, 1, , 0x0200 // WS_EX_CLIENTEDGE
	objsetstyle 1, 1, , 0x0200 // WS_EX_CLIENTEDGE
	objsetstyle 2, 1, , 0x0200 // WS_EX_CLIENTEDGE