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:

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:

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:

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.


[view class]
~ICommandEvent
public:
virtual ~ICommandEvent()

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
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.


[view class]
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.


[view class]
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


[view class]
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


[view class]
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

Inherited Public Data

Inherited Protected Functions

Inherited Protected Data