〜 オブジェクト 〜
ボタンキャプションを複数行表示 (要USER32.DLL)

button命令で配置するボタンに表示するテキストは、一行のみで改行させたり、縦書きにはできません。
API関数SetWindowLongでボタンスタイルを変更すれば複数行表示や設定によって縦表示にできますので、
ここではそのやり方について載せておきます。
ボタンのオブジェクトハンドルと「BS_MULTILINE(=0x2000)パラメータを指定することで、
複数行スタイルに変更できますが、複数行設定以外のテキスト表示位置等の基本スタイルを継承する場合には、
SetWindowLongのスタイル値に、API関数GetWindowLongで取得した現在のスタイル値も指定しましょう。
さて、「オブジェクトのハンドルとは?」って説明はココでは省略するとして、
objinfo関数で取得できるHSP3はさておき、HSP2でどうやってハンドルを取得するかと言うと、
BMSCR構造体の要素41(hCld)から64要素分が各オブジェクトハンドルの保有領域となっているので
mref命令を使ってBMSCR構造体を取得し、該当オブジェクトのハンドル保有領域を取得すればOKです。 
	

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
	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


	objsize 100, 100
	pos  10, 10 : button "ココから\n終了する", *exit
	pos 200, 10 : button "終\n了\nす\nる", *exit	// 縦書きは1文字毎に改行を入れてるだけ…。
	objsetstyle 0, , 0x2000 // BS_MULTILINE
	objsetstyle 1, , 0x2000 // BS_MULTILINE
	stop

*exit

取得スタイル = 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
#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

	objsize 100, 100
	pos  10, 10 : button gosub "ココから\n終了する", *exit
	pos 200, 10 : button gosub "終\n\n了\n\nす\n\nる", *exit	// 縦書きは1文字毎に改行を入れてるだけ…。
	objsetstyle 0, , 0x2000 // BS_MULTILINE
	objsetstyle 1, , 0x2000 // BS_MULTILINE
	stop

*exit
	end