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

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

  
/*
GUIBEGIN
WINDOW , 53, 175, 241, 123, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , Popup menu demo
	FONT 8, 400, MS Shell Dlg
	PUSH 9, 9, 40, 14, TABSTOP, , MyButton, , Push
	LIST 89, 7, 48, 40, NOTIFY|BORDER|VSCROLL|TABSTOP, , MyList
DEND

MENU Window
	HEADING &Window
		ITEM &Item 1
		HEADING &Item 2
			ITEM Subitem 1
			ITEM SubItem 2
		<
	<
DEND

MENU Button
	HEADING &Button
		ITEM &Item 1
		ITEM &Item 2
	<
DEND

MENU List
	HEADING &List
		ITEM &Item 1
		ITEM &Item 2
	<
DEND
GUIEND
*/

/* This script demonstrates adding a CONTEXTMENU event handler for our window.
 * This event happens when the user clicks the right mouse button while the
 * pointer is inside our window, or some control inside our window. Typically,
 * this is used to present a popup menu pertinent to the window or control.
 * Our example window has two controls -- a button and a list box. We define
 * 3 menus, and name the definitions "Window", "Button", and "List". (You can
 * choose any names you prefer). When the user right-clicks on our button control,
 * we'll call GuiMenuAdd to popup the "Button" menu. When the user right-clicks
 * on our list control, we'll call GuiMenuAdd to popup the "List" menu. And when
 * the user right-clicks on our window, we'll call GuiMenuAdd to popup the
 * "Window" menu.
 *
 * And just for illustration, we've added event handlers for all the menu items
 * in these menus. The event handler simply presents a message box stating what
 * menu and item was selected.
 *
 * NOTE: A popup menu can have only one heading. But it may have as many items
 * and sub-items as you like.
 */

LIBRARY rexxgui
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 when the user clicks the right mouse button
 * over our window (or perhaps some control in the window).
 */

wm_contextmenu:
	/* ARG(1) is a handle to our window if he clicked on that.
	 * Otherwise, it is the handle to some control he clicked
	 * upon.
	 */

	/* Did he click on our window itself? */
	IF guiwindow == ARG(1) THEN

		/* Present our popup menu named "Window" at the position
		 * where the user clicked in the window.
		 */
		guiaddmenu("Window")

	/* He clicked on one of our controls. */
	ELSE DO

		/* First let's get the REXX variable associated with the control handle. NOTE:
		 * The returned variable name is upper-cased.
		 */
		variable = guiinfo("VARIABLE", ARG(1))

		/* Now figure out which menu to popup. */
		SELECT variable

			/* If it was "MyButton" control, present our "Button" popup menu. */
			WHEN "MYBUTTON" THEN guiaddmenu("Button")

			/* If it was "MyList" control, present our "List" popup menu. */
			WHEN "MYLIST" THEN guiaddmenu("List")

			/* Let the OS handle any context menu for other controls. */
			OTHERWISE RETURN ""
		END

	END

	/* Don't let Rexx Gui process this event. */
	RETURN ""

/* Event handlers for all the menu items. */

windowitem1:
	guisay('"Window -> Item 1" was selected')
	RETURN

windowitem2subitem1:
	guisay('"Window -> Item 2 -> Sub Item 1" was selected')
	RETURN
	
windowitem2subitem2:
	guisay('"Window -> Item 2 -> Sub Item 2" was selected')
	RETURN

buttonitem1:
	guisay('"Button -> Item 1" was selected')
	RETURN

buttonitem2:
	guisay('"Button -> Item 2" was selected')
	RETURN

listitem1:
	guisay('"List -> Item 1" was selected')
	RETURN

listitem2:
	guisay('"List -> Item 2" was selected')
	RETURN
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2024-4-26  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2010-07-16 20:45:23