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.
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:
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.
You can construct and destruct objects of this class.
![]() |
public:
virtual ~ICommandEvent()
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
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.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
A command event contains the ID of the command to run and limited information about the source of the command.
![]() |
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.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
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.
![]() |
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.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
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.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
enum Source { pushButton, menu, accelerator, unknown }
These enumerators list the possible origin of the command event that ICommandEvent::source can return:
Windows | OS/2 | AIX |
Yes | Yes | Yes |
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