Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide to Clip-4-Win version 3.0 - <b>menuitem</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
MENUITEM
Create a menu item
------------------------------------------------------------------------------

Syntax
#include "windows.ch"
#include "topclass.ch"   --or--   #define  NO_C4WCLASS
#include "commands.ch"
MENUITEM  [ <oMenuItem> | <aMenu>  TEXT ]  <cText>
     [ COMMAND <cCmd> ]
     [ ACTION <bAction> ]
     [ HELP <oHelp> ]
     [ CHECKED ]  [ DISABLED ]  [ GRAYED ]
     [ ID <cnId> ]
     [ IN [ MENU ]  <oMenu> | <aMenu> ]

OR:

MENUITEM SEPARATOR
     [ IN [ MENU ]  <oMenu> | <aMenu> ]

Arguments
<oMenuItem> | <aMenu> is an optional variable to receive the
menu item object (for an OO application) or menu (if NO_C4WCLASS
is defined).  Because this is rarely specified, you need to also
use the TEXT keyword if you use it.

<cText> is the title of the popup menu.  You can use an
ampersand ("&") to make the next character an accelerator
(keyboard short-cut), which will then be underlined when
displayed.

COMMAND <cCmd> is a message (method) name (for an OO
application) or a function name (if NO_C4WCLASS is defined).
If this item is chosen, Clip-4-Win will either search for the
specified message (if OO) or call the function.

The search starts in the window which owns the menu, and works
upwards through its parents (owners), as far as the
application, if not found sooner.  If found, the object
concerned is then sent the <cCmd> message, with the menu item
object as a parameter.  If not found, the default (in
APPBASE.PRG) is to raise a serious error.  This mechanism
allows child windows to define just the messages they want to
handle; the rest are automatically passed higher up.  This
mechanism can be described as "smart windows, dumb menus".  If
you want to change this, refer to the OnCommand() method in
MENUBASE.PRG.

ACTION <bAction> specifies an optional code block (instead of
a COMMAND) to execute if the user chooses this menu item.

HELP <oHelp> can be used to specify help information.

CHECKED means the menu item will be initialised with a check
mark.

DISABLED means the menu item starts off disabled.

GRAYED means the menu item starts off grayed.

ID <cnId> is an optional ID for the item.  You don't usually
specify this for an OO application (where only a numeric is
allowed); instead, you can keep the <oMenuItem>, e.g. to use
its :Enabled() method later.  For a non-OO application, you
might specify the id for use with e.g. EnableMenuItem().

IN [ MENU ] <oMenu> | <aMenu>  specifies the parent (owner)
menu object or menu array of the popup or bar menu to contain
the menu item.

Description
This command can be used to create a menu item in either a non-
OO application (by defining NO_C4WCLASS) or an OO application.
A number of clauses may be ignored, to make it easier to
convert from non-OO to OO.

Example
POPUP "&File"
     MENUITEM "&Browse..."    COMMAND Browse                     ;
          HELP WHelp{"Browse a file..."}
     MENUITEM SEPARATOR
     MENUITEM "E&xit"         COMMAND Exit                       ;
          HELP WHelp{"Exit the application"}
ENDPOPUP
POPUP "&Help"
     MENUITEM "&About"     HELP WHelp{"About this application"}  ;
          ACTION MessageBox( , "Easy!", "Clip-4-Win App")
ENDPOPUP


See Also: MENU POPUP

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson