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

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

  
/*
GUIBEGIN
WINDOW , 146, 188, 165, 63, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , User abort example
	FONT 8, 400, MS Shell Dlg
	PUSH 21, 18, 40, 14, TABSTOP, , StartLoop, , Start loop
DEND
GUIEND
*/

/* An example of allowing the user to abort a lengthy loop. */

OPTIONS "C_CALL LABELCHECK"
NUMERIC DIGITS 10
LIBRARY rexxgui
guierr = "SYNTAX"
guiheading = 1
guicreatewindow('NORMAL')
again:
DO FOREVER
	guigetmsg()
	CATCH SYNTAX
			CONDITION('M')
			SIGNAL again
	FINALLY
		guidestroywindow()
END
RETURN

/* Called by Reginald when the user clicks on our "Start Loop" button */
wm_click_startloop:

	/* Let's do a lengthy loop. In fact, we'll just do a forever loop.
	 * In order to let the user abort this, we're going to pop open a
	 * child window (using the child layout script, childabort.rex). It
	 * has a TEXT control to which we can display status messages. We'll
	 * just display a count of every 100 loops. It also has a Cancel button
	 * the user can click upon to abort this loop. When the user clicks
	 * this button, the child script calls GuiWake with the signal "ABORT".
	 */

	/* First, let's open the child window as a modal window. */
	createobject("ChildAbort.rex",,, "My title")

	/* Initially, the child window has not set GUISIGNAL yet */
	guisignal = ""

	count = 0
	DO FOREVER
		/* Update the status message if 100 loops have passed */
		IF count // 100 == 0 THEN childabort~showmessage(count "loops have passed.")
		count = count + 1

		/* Call GuiGetMsg to allow us to check if the user has interacted
		 * with the window. But use a "CLEAR" operation, so GuiGetMsg doesn't
		 * pause our script if he hasn't done anything.
		 */
		guigetmsg("CLEAR")

		/* Did he click on the "Cancel" button? If so, the child script
		 * called GuiWake, and so GuiSignal was set to "ABORT".
		 */
		IF guisignal == "ABORT" THEN LEAVE

	END

	/* DROP the child script to close its window, and free the object */
	DROP childabort

	RETURN
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2024-4-27  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2010-07-16 20:45:19