IDMApplicationEvents Interface

Version: 3.0
Events interface for DMApplication Object

GUID: {673A9FC3-9A0B-11D4-B2A4-FD6847C75367}

IDMApplicationEvents interface should be used to receive notifications from the DM2003 application object(s). DM2003 supports multiple event sinks; following objects may take part in the event processing:

Members:
Kind Name ID Description
OnCreateDocument 1 Fired when new DataForm created
OnCloseDocument 2 Fired when DataForm closed
OnCommand 3 Provide feedback from server to client
OnLoadFile 4 Fired when disk file have been loaded into container
OnQuit 5 Fired from MainForm.OnClose
OnPlotClick 6 Plot point area clicked
OnPlotPointClick 7 Plot point clicked
OnPlotSelection 8 Plot selection changed
OnPlotGetPoint 9 Returns point coordinates
OnOpenFile 10 Used if data file dropped, reopened or opened from DDE and cmdline
OnStart 11 Invoked when after all initialization

Syntax:
event OnCreateDocument(Document): HResult

Applies to:
DMAppHelper, DMApplication, DMInternalApplication

Syntax:
event OnCloseDocument(Document): HResult

Applies to:
DMAppHelper, DMApplication, DMInternalApplication

Syntax:
event OnCommand(Command): HResult

Applies to:
DMAppHelper, DMApplication, DMInternalApplication

OnCommand event handler fires when user invokes some action. The name of action passed in the Command parameter. This is the same name as used in IsCommandXXX properties and ExecuteCommand method. You can use this event to create "Macro recorder" applications or add something to the default action behavior. See also the list of standard action names.

Syntax:
event OnLoadFile(Document): HResult

Applies to:
DMAppHelper, DMApplication, DMInternalApplication

Syntax:
event OnQuit(SaveState): HResult

Applies to:
DMAppHelper, DMApplication, DMInternalApplication

OnQuit event has important feature: in the SaveState parameter it passes the state of "Save settings on exit" checkbox in the Application Properties Dialog.

Syntax:
event OnPlotClick(Document, X, Y): HResult

Applies to:
DMAppHelper, DMApplication, DMInternalApplication

PlotClick event allows to do something when user clicks a given plot object. For example, in the Plot Calculator Tool some function of plot coordinates (passed as parameters) is calculated.

In the example below, we use coordinates of the clicked point just to add a new item into the Container and display new point (notice that current series must be not empty):

Example:

sub Server_OnPlotClick(Document, X, Y)
  Document.Container.AddItem(Array(X, Y))
  Document.Worksheet.Refresh
  Document.Plot.CurrentSerie.AddPoint
end sub

Syntax:
event OnPlotPointClick(Document, Point, Serie, Result): HResult

Applies to:
DMAppHelper, DMApplication, DMInternalApplication

Use this event if you want to do something when user clicks plot point (that is, mouse coordinates are inside some point). Notice that you can change default behavior of plot eraser and editor modes if you return false in this handler as shown in the example below (in case of several event handlers, their results are logically multiplied: Result1 and Result2 and ...)

Example:

function Server_OnPlotPointClick(Doc, Point, Serie)
  Server_OnPlotPointClick=not ((Doc is TempWnd) and (Serie<>1))
end function

Please note that the result returned to DM2003 core processed in some unclear and awkward manner due to limitations of JavaScript language (which does not allow ByRef parameters). There may be a lot of event handlers defined in various clients. All these handlers divided into following groups:

Every group (except minibrowser) may contain arbitrary number of event handlers. These groups invoked in the abovementioned order, and if some group return false, subsequent groups are just not called! So if your out-of-process automation client does not define this event handler, Scroller and Point Editor tools will not work.

Inside first two groups, every attached handler is called (keep in mind that COM object may have several client references), and the results are logically summed (OR operator). This is because .Net clients are connected to the event sink for every event handler (delegate object), so the event called many times in the client and the most of calls return false (since there is no handler defined for this connection).

Syntax:
event OnPlotSelection(Document): HResult

Applies to:
DMAppHelper, DMApplication, DMInternalApplication

Syntax:
event OnPlotGetPoint(Document, Point, Serie, X, Y, Result): HResult

Applies to:
DMAppHelper, DMApplication, DMInternalApplication

OnPlotGetPoint event allows you to display points whose coordinates calculated by your code. This is in contrast to usual mode, when plot point coordinates are stored in containers and possibly transformed by DM2003 application using axes and series expressions and embedded expression parser. To enable this feature for particular series, set IDMSerie3.EnableGetPointEvent property to True. Notice that unlike OnPlotPointClick event, for which Point parameter is a sequential index of the clicked point in the container (if any), for OnPlotGetPoint event Point is a zero-based index! To find appropriate data item for data-based series, you should calculate actual item index. Also note that X,Y parameters are initialized by point coordinates.

Example:

Server.CreateDocument Server.InstallPath & "samples\data_1.dat"
Server.ExecuteCommand "ShowWorksheetAction"
Server.ExecuteCommand "SelectAllAction"
Server.ExecuteCommand "PlotLinesAction"
Server.ExecuteCommand "ShowPlotAction"

Server.ActiveDocument.Plot.CurrentSerie.EnableGetPointEvent=true

' Returns point coordinates
function Server_OnPlotGetPoint(Doc, Point, Serie, ByRef X, ByRef Y)
' enter your code here
  Server_OnPlotGetPoint=true
  if x<100 then y=0.5
end function

Syntax:
event OnOpenFile(FileName): HResult

Applies to:
DMAppHelper, DMApplication, DMInternalApplication

Syntax:
event OnStart: HResult

Applies to:
DMAppHelper, DMApplication, DMInternalApplication