4.1.1.2 Handling Dialog Builder Events with Origin C

When a user interacts with a Dialog Builder dialog in Origin any number of different resource events may be triggered. Creators of Dialog Builder dialogs must develop Origin C code to handle any event that might be triggered and that needs to be handled. For example, if a dialog contains a button with the caption "Perform Linear Fit" users would reasonably expect that a linear fit be performed on their data when the button is clicked. In this situation the event is the user clicking the button and the event handler is the Origin C function that runs to perform the linear fit. Clicking the button triggers the event causing the event handler function to execute.

Topics in this section discuss in detail how a message map is used to specify which resource events will be handled and which functions will be called to handle them. In Origin C a message map is a C construct (actually, a class object) that maps resource events to event handler functions. Message maps are constructed using a number of predefined Origin C macros. These predefined message map macros are defined in the system header file MagMap.h and many are summarized in the topics that follow. Template code implementing a message map (one each for the main dialog and for each tab in a tabbed dialog and each page in a wizard) and several basic event handler functions (with no body) are created and added to the header file <ProjectName>.h by the Origin Dialog AppWizard before it closes.

Handling Dialog Builder (Resource) Events with Origin C image159.gif

The Origin Dialog AppWizard creates template code for each message map and several basic event handler functions (with no body) but developers of Dialog Builder dialogs must customize them to map the events they want to handle to functions they want handling the events. The Origin Dialog AppWizard does not create the body of any event handler function. The bodies of event handler functions are determined by the event being handled and by how the event it is to be handled. Thus, developers of dialogs must code event handler functions for themselves.