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

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

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

/* An example of using the RxGDI Add-on DLL to do our own text drawing
 * in a window.
 */

/* Load REXX GUI, and also the RxGdi Add-on libraries */
LIBRARY rexxgui, rxgdi

/* Raise SYNTAX condition for any error that happens with a RxGdi function */
gdierr = "SYNTAX"
gdiheading = 1

guierr = "SYNTAX"
guiheading = 1

guicreatewindow('NORMAL')

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

	CATCH HALT
	FINALLY
		guidestroywindow()
END
RETURN


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

wm_paint:
	/* Begin our drawing by calling GdiPaint. Pass the handle to our
	 * window where the drawing is to take place. GuiCreateWindow set
	 * the GuiWindow variable to this. We also pass the name of a
	 * variable where we want the Paint handle to be returned. Here
	 * we pass a variable name of "Paint". GdiPaint will also append a
	 * "1" to this name, and set that variable to a Device Context
	 * (which we may need to pass to our Gdi functions).
	 */
	gdipaint('Paint', guiwindow)

	/* If any error happens below, let's have a FINALLY so that we
	 * can call GdiPaint to end painting.
	 */
	DO
		/* Get GUI font */
		gdistockobj("GUI_FONT", "FontHandle")

		/* Select this font into our Device Context */
		gdisetobj(paint1, fonthandle)

		/* Get the width and height of some typical text given our font */
		gditext(paint1, "Ij", 'Width', 'Height', 'CALCRECT') 

		/* Set background drawing mode to TRANSPARENT. The background color isn't used */
		gdibkmode(paint1)

		/* Draw some text at a position of 10, 10 */
		gditext(paint1, "This is my text", 10, 10) 

		/* Set the text color to Red = 200, Green = 70, Blue = 40. NOTE: The
		 * highest individual value is 255.
		 */
		gditextcolor(paint1, gdicolorvalue(200, 70, 40))

		/* Draw some text at a position of 10, 10 + Height */
		gditext(paint1, "This is more text", 10, 10 + height) 

		/* Set background drawing mode to OPAQUE. This means the background color is used */
		gdibkmode(paint1, 'OPAQUE')

		/* Set the background color to Red = 255, Green = 255, Blue = 255 (ie, white). */
		gditextcolor(paint1, gdicolorvalue(255, 255, 255), 1)

		/* Draw some text at a position of 10, 10 + Height * 2 */
		gditext(paint1, "Colored background text", 10, 10 + (height * 2)) 

		CATCH SYNTAX
			/* This beep is here to alert us if any of the above calls fail. But
			 * we should NOT display a message box here. Never create another
			 * window or message box within a PAINT handler. If we need to inform
			 * another part of our program about this error, we can do a GuiWake()
			 * with some signal that our main message loop will deduce.
			 */
			BEEP()
		FINALLY
			/* End our painting */
			gdipaint(paint)
	END

	/* Don't let Rexx Gui process this event. */
	RETURN ""
掌柜推荐
 
 
¥900.00 ·
 
 
¥880.00 ·
 
 
¥497.00 ·
 
 
¥380.00 ·
 
 
¥980.00 ·
 
 
¥1,080.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2010-07-16 20:45:36