HSP Tips / HSPモジュール

inputの背景の色を変更


説明

inputボックスの背景の色を塗り替えます。



HSPスクリプト


//Created by As<akicansoft@gmail.com>
	//背景の色を塗り替える
#module mod_brush
	#uselib "gdi32"
	#cfunc  GetStockObject "GetStockObject" sptr
	#func  SetBkColor "SetBkColor" sptr,sptr
	

	#uselib "user32"
	#func  SetClassLongA "SetClassLongA" sptr,sptr,sptr
	#cfunc GetForegroundWindow "GetForegroundWindow"


/* Stock Logical Objects */
#define 	global	WHITE_BRUSH         0		//ホワイトブラシ
#define 	global	 LTGRAY_BRUSH        1		//
#define 	global	 GRAY_BRUSH          2
#define 	global	 DKGRAY_BRUSH        3
#define 		global BLACK_BRUSH         4
#define 	global	 NULL_BRUSH          5
#define 	global	 HOLLOW_BRUSH        NULL_BRUSH



//ストックブラシのロード p1 = ブラシ名
//モジュール内部の変数にブラシハンドルが代入されます
#deffunc stockbrushload int _brush

	switch _brush

	case WHITE_BRUSH
		brush(WHITE_BRUSH) = GetStockObject(WHITE_BRUSH)
	swbreak

	case LTGRAY_BRUSH
		brush(LTGRAY_BRUSH) = GetStockObject(LTGRAY_BRUSH)
	swbreak

	case GRAY_BRUSH
		brush(GRAY_BRUSH) = GetStockObject(GRAY_BRUSH)
	swbreak

	case DKGRAY_BRUSH
		brush(DKGRAY_BRUSH) = GetStockObject(DKGRAY_BRUSH)
	swbreak


	case BLACK_BRUSH
		brush(BLACK_BRUSH) = GetStockObject(BLACK_BRUSH)
	swbreak

	case NULL_BRUSH
		brush(NULL_BRUSH) = GetStockObject(NULL_BRUSH)
	swbreak



swend


return



//背景色処理
#define 	global  WM_CTLCOLORMSGBOX               0x0132	//メッセージボックスmsnbox
#define 	global	  WM_CTLCOLOREDIT                 0x0133	//エディットボックスinput
#define 		global  WM_CTLCOLORLISTBOX              0x0134	//listbox
#define 	 	global WM_CTLCOLORBTN                  0x0135	//btn?
#define 		global  WM_CTLCOLORDLG                  0x0136	//ダイアログ
#define 		global  WM_CTLCOLORSCROLLBAR            0x0137	//スクロールバー
#define 		global  WM_CTLCOLORSTATIC               0x0138	//スタティック

#define GCL_HBRBACKGROUND	$FFFFFFF6

#define ctype crgb(%1,%2,%3)			(%1|(%2<<8)|(%3<<16))


#deffunc onbrush int _brush, int _msg

SetClassLongA hwnd,GCL_HBRBACKGROUND,brush(_brush)

switch _brush

	case WHITE_BRUSH
		if brush(WHITE_BRUSH)!0{
			oncmd gosub *L_WHITE_BRUSH, _msg
		}
	swbreak


	case LTGRAY_BRUSH
		if brush(LTGRAY_BRUSH)!0{
			oncmd gosub *L_LTGRAY_BRUSH, _msg
		}
	swbreak


	case GRAY_BRUSH
		if brush(GRAY_BRUSH)!0{
			
			oncmd gosub *L_GRAY_BRUSH, _msg
		}
	swbreak


	case DKGRAY_BRUSH
		if brush(DKGRAY_BRUSH)!0{
			oncmd gosub *L_DKGRAY_BRUSH, _msg
		}
	swbreak


	case BLACK_BRUSH
		if brush(BLACK_BRUSH)!0{
			oncmd gosub *L_BLACK_BRUSH, _msg
		}
	swbreak


	case NULL_BRUSH
		if brush(NULL_BRUSH)!0{
			oncmd gosub *L_NULL_BRUSH, _msg
		}
	swbreak

swend

return



*L_WHITE_BRUSH
	mouse
	SetBkColor wparam,crgb(255,255,255)
	return brush(WHITE_BRUSH)

*L_LTGRAY_BRUSH
	mouse
	SetBkColor wparam,crgb(192,192,192)
	return brush(LTGRAY_BRUSH)

*L_GRAY_BRUSH
	mouse
	SetBkColor wparam,crgb(128,128,128)
	return brush(GRAY_BRUSH)

*L_DKGRAY_BRUSH
	mouse	
	SetBkColor wparam,crgb(64,64,64)
	return brush(DKGRAY_BRUSH)

*L_BLACK_BRUSH
	mouse
	SetBkColor wparam,crgb(0,0,0)
	return brush(BLACK_BRUSH)

*L_NULL_BRUSH
	mouse
	SetBkColor wparam,crgb(255,255,255)
	return brush(NULL_BRUSH)
#global

dim brush@mod_brush,6

#if 1

stockbrushload LTGRAY_BRUSH
onbrush LTGRAY_BRUSH,WM_CTLCOLOREDIT
input aaa
input bbb
input ccc


stop

#endif