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

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
/*
GUIBEGIN
WINDOW , 0, 0, 400, 200, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , Custom Background Color
	FONT 8, 400, MS Shell Dlg
DEND
GUIEND
*/

/* An example of a custom background color for the window. */

LIBRARY rexxgui

guierr = "SYNTAX"
guiheading = 1

/* FUNCDEF some stuff */
DO
	FUNCDEF("CreateSolidBrush", "32u, 32u", "gdi32")
	FUNCDEF("SelectObject", "32u, 32u, 32u", "gdi32")
	rect = "32u, 32u, 32u, 32u"
	FUNCDEF("FillRect", ", 32u, struct RECT, 32u", "user32")
	FUNCDEF("DeleteBrush", ", 32u", "gdi32", "DeleteObject")

	CATCH FAILURE
		CONDITION('M')
		RETURN
END

/* Get a custom brush with an RGB color of  100, 175, 150 */
color = (100 * 65536) + (175 * 256) + 150
brush = createsolidbrush(color)

/* Since we'll be doing our own painting of windows, then don't let the
 * operating system automatically erase the window background. We also
 * need our PAINT handler called whenever the window is resized, so we
 * specify the VREDRAW|HREDRAW styles
 */
guiwindowdefaults(, , 0, 'VREDRAW|HREDRAW')

guicreatewindow('NORMAL')

again:
DO FOREVER
	guigetmsg()
	CATCH SYNTAX
			CONDITION('M')
			SIGNAL again

	CATCH HALT
	FINALLY
		guidestroywindow()

		/* Destroy our custom brush */
		deletebrush(brush)
END
RETURN


/* Called by Reginald whenever our window needs its background drawn. This
 * handler is tricky. It should never, never create another window nor display a
 * message box. All it should ever do is draw our window background. And that's it.
 */

wm_erasebkgnd:
	context = ARG(1)

	/* Get the window's width/height */
	guigetctlplacement(guiwindow, , , 'Width', 'Height')

	/* Use our custom brush */
	temp = selectobject(context, brush)

	/* Fill in the window */
	rect.1 = 0
	rect.2 = 0
	rect.3 = width
	rect.4 = height
	fillrect(context, rect, brush)

	/* Restore orig brush */
	selectobject(context, temp)

	/* Indicate we did the background */
	RETURN 1
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Mon 2017-11-20  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2010-07-16 20:46:06