### ICommandEvent

  The ICommandEvent class represents an application-specific or system command. ICommandHandler constructs and processes objects of this class, typically as a result of the user selecting one of the following:

  - A menu item
  - A push button
  - An accelerator key sequence

  If these preceding controls each use the same value for the following identifiers, then all three produce the same command ID when pressed or selected:

  - Window ID for a button
  - Menu item ID for a menu item
  - Accelerator command value for the accelerator key

  Subsequently, the command ID is passed in the ICommandEvent. This allows an application to unify the logic for all three types of input within a single ICommandHandler.

#### Portability Considerations

  In OS/2, ICommandEvents from accelerators go directly to the associated IFrameWindow. For portability, attach the ICommandHandler to the IFrameWindow, which has the following characteristics:

  - Has these accelerators
  - Is the owner of this menu
  - Is the owner of these push buttons, either directly or by owning canvases, which, in turn, own the push buttons

#### OS/2 Considerations

  In Presentation Manager, the event result for WM_COMMAND and WM_SYSCOMMAND is reserved. Therefore, your callback functions do not have to set any result before they return true.

  Presentation Manager's default window procedure does not pass an unprocessed WM_COMMAND or WM_SYSCOMMAND message to another window, either up the owner chain or up the parent window chain.

### ICommandEvent - Member Functions and Data by Group

### Constructors & Destructor

You can construct and destruct objects of this class.

~ICommandEvent

      public:
      virtual ~ICommandEvent()

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

ICommandEvent

      public:
      ICommandEvent(const IEvent& event)

  Construct an ICommandEvent from the specified event. ICommandHandler::dispatchHandlerEvent constructs objects of this class from an object of the class IEvent and passes the resulting object to the function ICommandHandler::command or ICommandHandler::systemCommand.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### Command Information

A command event contains the ID of the command to run and limited information about the source of the command.

commandId

      public:
      unsigned long commandId() const

  Returns the ID of the push button or menu item, or the command ID of the accelerator key that initiated the command event. Application code can also create and post command events. In this case, the returned ID is whatever the creator of the event specified.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

Windows Considerations

  When the eventId is WM_SYSCOMMAND, this function sets the low order 4 bits of its return value to 0. These bits are reserved for use by the operating system.

isFromFrame

      public:
      bool isFromFrame() const

  Returns a bool type value (true or false) indicating whether the event has already been dispatched to the frame window and, consequently, whether it should not be dispatched to the frame again.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

source

      public:
      Source source() const

  Returns the enumerator corresponding to the way in which the command event was initiated. The enumeration Source provides the return values. It is possible for an application to have a menu item, a push button, and an accelerator table entry that all generate the same command ID. You can use this function to determine which of the three was the source of the command event.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### ICommandEvent - Enumerations

Source

      enum Source { pushButton,
                    menu,
                    accelerator,
                    unknown }

  These enumerators list the possible origin of the command event that ICommandEvent::source can return:

  pushButton
    The origin of the command event is a push button.
  menu
    The origin of the command event is a menu.
  accelerator
    The origin of the command event is an accelerator.
  unknown
    The origin of the command event is unknown.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### ICommandEvent - Inherited Member Functions and Data

#### Inherited Public Functions

  IEvent

  -     virtual ~IEvent()

  -     IWindowHandle controlHandle() const

  -     virtual IWindow* controlWindow() const

  -     IEvent& decrementOwnerLevels()

  -     virtual IWindow* dispatchingWindow() const

  -     unsigned long eventId() const

  -     IWindowHandle handle() const

  -     IEvent( IWindow* window,
                unsigned long eventId,
                const IEventParameter1& parameter1,
                const IEventParameter2& parameter2 )

  -     IEvent( const IWindowHandle& handle,
                unsigned long eventId,
                const IEventParameter1& parameter1,
                const IEventParameter2& parameter2 )

  -     IEvent(const IEvent& event)

  -     IEvent& operator =(const IEvent& event)

  -     IEventParameter1 parameter1() const

  -     IEventParameter2 parameter2() const

  -     bool passToOwner() const

  -     IEventResult result() const

  -     IEvent& setControlHandle(const IWindowHandle& handle)

  -     IEvent& setDispatchingHandle(const IWindowHandle& handle)

  -     IEvent& setDispatchingWindow(IWindow* window)

  -     IEvent& setHandle(const IWindowHandle& handle)

  -     IEvent& setNumberOfLevels(int levels = - 1)

  -     IEvent& setPassToOwner(bool passOn = true)

  -     IEvent& setResult(const IEventResult& eventResult)

  -     IEvent& setResult(bool eventResult)

  -     virtual IWindow* window() const

#### Inherited Public Data

  - None

#### Inherited Protected Functions

  - None

#### Inherited Protected Data

  - None