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

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

  
/*
GUIBEGIN
STRING ListStrings
My string
Another string
One more
DEND

STRING TabStrings
One
Two
Three
DEND

WINDOW , 91, 221, 197, 199, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , TAB example
	FONT 8, 400, MS Shell Dlg
	TAB 5, 3, 187, 108, SINGLELINE|RIGHTJUSTIFY|NOFOCUS, , MyTab, , TabStrings
DEND
GUIEND
*/

/* This is an example of a Main Window Layout script. It contains a TAB
 * control with the labels "One", "Two", and "Three". When the user
 * selects "One", we create a ENTRY control and a PUSH button, and operate
 * it. When the user selects "Two", we create 4 check controls. When the
 * user selects "Three", we create a listbox containing some preset strings.
 */

/* Before opening the window, let's initialize the variables for our TAB
 * control, and each label's set of controls.
 */
mytab = "One"	/* Initially select this label. */
twocheck1 = 1	/* Initially check this box. */
myoldtab = "One"









/* Standard initialization and message loop, with one exception as regards
 * GuiCreateWindow below.
 */

LIBRARY rexxgui
guierr = "SYNTAX"
guiheading = 1

/* Normally, we call GuiCreateWindow('NORMAL'). This creates and displays
 * the window. But we don't want to display the window after it is created.
 * Why? Because we still have some more controls to add to it first. We
 * call AddTabCtls() to do that. Then we call GuiSetCtlPlacement to finally
 * display the window.
 */
guicreatewindow()
addtabctls()
guisetctlplacement(,,,,,,'NORMAL')

again:
DO FOREVER
	guigetmsg()

	/* None of our handlers below calls GuiWake(). Plus, we use no child window
	 * Layout scripts. So we omit any checks of GuiObject/GuiSignal.
	 */

	CATCH SYNTAX
		CONDITION('M')
		SIGNAL again
	CATCH HALT
	FINALLY
		guidestroywindow()
END
RETURN






/* Called by Reginald when the user clicks the "OnePush" PUSH control.
 * NOTE: This was manually added. Because the "OnePush" is created
 * via GuiAddCtl, we don't actually have it in any window when we
 * create this script. So we have no Properties dialog to click on
 * the "Add Event Handler" button.
 *
 * So, we just prepend WM_CLICK to the control's variable name.
 */

wm_click_onepush:
	guisay("Button clicked.")
	RETURN





/* Called by Reginald when the user selects a new TAB label. */

wm_selchange_mytab:
	/* Get the selected label's text (ie, "One", "Two" or "Three"). */
	guigetctlvalue("MyTab")

	/* Display a set of controls depending upon which TAB label
	 * has been selected. The variable "MyTab" has been set to
	 * the currently chosen label. "MyOldTab" has been set to
	 * the previously chosen label, or DROP'ed if there was no
	 * previously chosen label.
	 */

	/* First remove any controls that were displayed for the
	 * previously chosen TAB label, if any.
	 */
	removetabctls()

	/* Now add the set of controls for the new TAB label. */
	addtabctls()

	/* Save the current TAB label as the previous label too. */
	myoldtab = mytab

	RETURN





/* Called by WM_SELCHANGE_MyTab to remove a set of controls for a TAB label.
 * NOTE: Before we destroy the controls, we call GuiGetCtlValue to update
 * the control's associated variable. In this way, the next time we create
 * the control, its variable will have an updated value, and it will be
 * initialized to that.
 */

removetabctls:
	/* Which label was previously selected? */
	SELECT myoldtab
		WHEN "One" THEN DO
			guigetctlvalue("OneEntry")
			guigetctlvalue("OnePush")
			guiremovectl("OneEntry")
			guiremovectl("OnePush")
		END
		WHEN "Two" THEN DO
			guigetctlvalue("TwoCheck1")
			guigetctlvalue("TwoCheck2")
			guigetctlvalue("TwoCheck3")
			guigetctlvalue("TwoCheck4")
			guiremovectl("TwoCheck1")
			guiremovectl("TwoCheck2")
			guiremovectl("TwoCheck3")
			guiremovectl("TwoCheck4")
		END
		WHEN "Three" THEN DO
			guigetctlvalue("ThreeList")
			guiremovectl("ThreeList")
		END
		OTHERWISE	/* If no label was previously selected */
	END
	RETURN





/* Called by WM_SELCHANGE_MyTab to add a set of controls for a TAB label. */

addtabctls:
	/* Which label is selected? */
	SELECT mytab
		WHEN "One" THEN DO
			guiaddctl("ENTRY 10,20,176,14, TABSTOP, CLIENTEDGE|QUIET, OneEntry")
			guiaddctl("PUSH 76,40,50,16, DEFAULT|TABSTOP, , OnePush, , Ok")
		END
		WHEN "Two" THEN DO
			guiaddctl("CHECK 10,24,50,14, AUTO, QUIET, TwoCheck1, , Option 1")
			guiaddctl("CHECK 70,24,50,14, AUTO, QUIET, TwoCheck2, , Option 2")
			guiaddctl("CHECK 10,44,50,14, AUTO, QUIET, TwoCheck3, , Option 3")
			guiaddctl("CHECK 70,44,50,14, AUTO, QUIET, TwoCheck4, , Option 4")

		END
		WHEN "Three" THEN DO
			guiaddctl("LIST 10,20,176,90, TABS|BORDER, CLIENTEDGE|QUIET, ThreeList,, ListStrings")
		END
	END
	RETURN
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2024-4-27  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2010-07-16 20:45:30