Guidance
指路人
g.yi.org
Guidance Forums / Reginald Rexx / Specify an ID for a menu

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

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Specify an ID for a menu
#6534
Posted by: Jeff Glatt 2005-08-17 07:11:29 Last edited by: Jeff Glatt 2007-06-19 14:02:50 (Total edited 2 times)
There's a menu option called "ID". When you specify the "ID" option for a menu item, then when the user selects it, Reginald calls your window's MENUID event handler. (This is an event handler that you'll find in your window's Event list).

Your WM_MENUID subroutine is passed 2 args. ARG(1) is the ID number for the menu item selected, and ARG(2) is the menu caption. This can be useful for implementing an MRU list.

Also, I changed GuiGetMenuOpts so that the caption you specify does not have backslashes "expanded". WARNING: I will likely change GuiAddCtl to do the same.

Here's an example script that demos the ID option for menu items.
/*
GUIBEGIN
WINDOW , 53, 175, 363, 138,  POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK,  , Menu demo
  FONT 8, 400, MS Shell Dlg
  MENU
  PUSH 9, 7, 55, 17, TABSTOP, , AddFname, , Add filename
DEND

MENU
  HEADING &Test
    ITEM C:\\MyDir\\MyFile, , , ID
    ITEM E:\\MyDir\\My Directory\\MyFile2, , , ID
  <
DEND
GUIEND
*/

/* This example demonstrates the ID option for a menu item. When it has the
 * ID option, then whenever the user selects the item, then the window's
 * WM_MENUID event handler is called. ARG(1) is the ID (number of the
 * item selected. (This number depends upon when the item was added to the
 * menu. Items added last have the highest ID numbers). ARG(2) is the menu
 * caption.
 */
LIBRARY rexxgui
guierr = "SYNTAX"
guiheading = 1
guicreatewindow('NORMAL')
again:
DO FOREVER
  guigetmsg()
  CATCH SYNTAX
    CONDITION('M')
    SIGNAL again
  FINALLY
    guidestroywindow()
END
RETURN

wm_menuid:
  guisay("ID =" ARG(1) || '0D0A'x || ARG(2))
  RETURN

wm_click_addfname:
  /* Add an item at a position of 1 3.
   *
   * The item has a caption of "A:\MyDir\My Floppy File", and has the
   * ID option.
   */
  guiaddmenu("A:\MyDir\My Floppy File, , , ID", "ITEM", "1 3")

  /* Disable the button so he can't click it again. */
  guisetctlplacement("AddFname", , , , , "DISABLE")
  RETURN
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Wed 2024-2-21  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0