Guidance
指路人
g.yi.org
Software / Reginald / Examples / colors.rex

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
/*
GUIBEGIN
WINDOW , 31, 131, 252, 68, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , CTLCOLORSTATIC example
	FONT 8, 400, MS Shell Dlg
	TEXT 14, 13, 17, 8, GROUP, , , , Hello
	TEXT 122, 13, 55, 8, GROUP, , , , This is some text.
	TEXT 122, 32, 26, 8, GROUP, , , , Entry 4
	TEXT 13, 31, 26, 8, GROUP, , , , Entry 3
DEND
GUIEND
*/

/*
 * An example of handling the CTLCOLORSTATIC event of a
 * REXX GUI window to set the color of TEXT controls.
 */
OPTIONS "C_CALL LABELCHECK WINFUNC NOSOURCE"
LIBRARY rexxgui

DO
	/* Register GetStockObject so we can grab one of the preset brushes for drawing text. */
	FUNCDEF("GetStockObject", "void, 32u", "gdi32")

	/* Register SetBkColor so we can change the background color for text. */
	FUNCDEF("SetBkColor", "32u, void, 32u", "gdi32")

	/* Register SetTextColor so we can change the foreground color for text. */
	FUNCDEF("SetTextColor", "32u, void, 32u", "gdi32")

	CATCH FAILURE

		CONDITION("M")
		RETURN
END

guierr = "SYNTAX"
guiheading = 1
guicreatewindow('NORMAL')

again:
DO FOREVER

	guigetmsg()

	CATCH SYNTAX
		CONDITION('M')
		SIGNAL again

	CATCH HALT
	FINALLY
		guidestroywindow()
END
RETURN

/* ================== WM_CTLCOLORSTATIC ==================
 * This handles the CTLCOLORSTATIC event for my window.
 *
 * This event happens when REXX GUI wants us to return
 * a "brush" used for drawing TEXT controls.
 *
 * ARG(1) is our device context handle.
 * ARG(2) is the handle to the entry control (window).
 */

wm_ctlcolorstatic:

   /*
	* For CTLCOLORSTATIC, we need to return a handle
	* to the brush we want to use for drawing TEXT controls.
	* We'll just get one of the preset brushes using
	* GetStockObject(). That way we don't need to
	* do CreateSolidBrush() ahead of time, and then
	* DeleteObject that when we're done with it.
	* When we handle CTLCOLORSTATIC here, we return
	* the brush we want.
	*
	* The first arg to SetTextColor or SetBkColor is the
	* device context handle for the control whose color
	* is to change. Windows passed that to our windows
	* procedure as the 3rd arg.
	*
	* The second arg is a numeric value which is a
	* combination of Red, Green, and Blue values for the
	* desired color. Each value can be from 0 to 255,
	* with the brightest intensity as 255. For example
	* if you set the green value to 0, the red value
	* to 0 and the blue value to 255, you'll get a very
	* pronounced, light blue. If you set green to 40,
	* red to 40, and blue to 40, you may get a grey.
	* Different combinations of the 3 values will yield
	* different colors. When you pass the 3 values to
	* SetTextColor or SetBkColor, you must multiply the
	* blue value by 65536, and multiply the green value by
	* 256. Then you add up the red, green, and blue
	* values. For example, here's how we would set the
	* background color with blue = 100, green = 40, and
	* red = 60.
	*
	* SetBkColor(ARG(1), (100 * 65536) + (40 * 256) + 60)
	*
	* Of course, if a particular component is 0, then you
	* can just leave it out. (If all 3 components are 0,
	* then just pass a 0).
	*/
	settextcolor(ARG(1), 125 * 256 /* medium green */)
 	setbkcolor(ARG(1), 255 /* bright red */)
	RETURN getstockobject(5 /* NULL_BRUSH */)
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Thu 2024-4-25  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-18 23:34:55