PM_DataRecordStateEvent

Note: This page includes content based on the F1 documentation for Centura development. It may be partially converted to support APF development, but should be regarded to be of uncertain actuality. It is provided as is. Eventually, it should be replaced by documentation available from within Visual Studio.

Const.PM_DataRecordStateEvent

An application sends the Const.PM_DataRecordStateEvent message to a data source to invoke an event in the data source's state machine.

Parameters

Name Description
nWhat = wParam Standard method parameter. Possible values are Const.METHOD_Inquire, Const.METHOD_Execute, Const.METHOD_GetType
sEvent = SalString.FromHandle(Sys.lParam) Event name. The event name is case sensitive and should be written exactly as in the object model.

Returns

When nWhat = Const.METHOD_Inquire, TRUE is returned if the event can be executed from the records current state, and the data source is not dirty. If multiple records are selected in a table, TRUE is returned only if the event can be executed from the state of all the selected records. In any other case, FALSE is returned.

When nWhat = Const.METHOD_Execute, TRUE is returned if the state event was successfully executed, FALSE otherwise.

Comments

For the framework support for state events to work, the Foundation1 property "state machine" must be checked for the data source.

Example

This menu item uses the Const.PM_DataRecordStateEvent message to execute the Close event for a customer order.

Sal original code:

Menu Item: C&lose
   Keyboard Accelerator: (none)
   Status Text: Close order
   Menu Settings
       Enabled when: SalSendMsg( hWndForm, PM_DataRecordStateEvent,
                                 METHOD_Inquire, SalHStringToNumber( 'Close' ) )
       Checked when:
   Menu Actions
       Call SalPostMsg( hWndForm, PM_DataRecordStateEvent,
                   METHOD_Execute, SalHStringToNumber( 'Close' ) )
C# code:
private void cmdCancelOrder_Inquire(object sender, Ifs.Fnd.Windows.Forms.FndCommandInquireEventArgs e)
{
     ((FndCommand)sender).Enabled = SendMessage(Const.PM_DataRecordStateEvent,
                                                Const.METHOD_Inquire,
                                                ((SalString)"Cancel").ToHandle());
}
private void cmdCancelOrder_Execute(object sender, Ifs.Fnd.Windows.Forms.FndCommandExecuteEventArgs e)
{
     SendMessage(Const.PM_DataRecordStateEvent,
                 Const.METHOD_Execute,
                 ((SalString)"Cancel").ToHandle());
}

Note: For the execution the SendMessage should only be used if execution is expected to be very short. Otherwise use PostMessage.