Accessing Dialog Builder Resources with Origin C

To access a resource (or control) on a Dialog Builder dialog first launch the dialog containing the control. Then, declare an Origin C object of the appropriate type and attach it to the desired resource (control). Once an Origin C object is successfully attached to the resource, the resource can be accessed (initialized, controlled, evaluated, enabled, and shown or hidden) by manipulating the methods and properties of the attached Origin C object.

To access a control on a dialog use the following syntax:

ControlName MyControl;

MyControl = GetItem(ControlID);

where ControlName is an Origin C class name and ControlID is the resource ID string of the control defined in your Symbol header file. The Dialog class member function GetItem returns the control for the given resource ID.

Note: To access a resource outside a Dialog class member function you must also include the name of the dialog. For example, you would use MyControl = DialogName.GetItem(ControlID); where DialogName is the Origin C name of the dialog containing the control.

The following example demonstrates how to declare an Origin C object of the appropriate type and attach it to a resource.

ListBox m_lbxAvailableData; // Declare ListBox object
m_lbxAvailableData = GetItem(IDC_LDS_LIST1); // Attach ListBox object to list box
// Loop through all data set names in project
string strDataName;
foreach(strDataName in Project.DatasetNames)
{
      m_lbxAvailableData.AddString(strDataName); // Add name to list box
}  

Note: The call to the GetItem method of the Dialog class above (step 2) does not require a prepended object identifier (e.g. dlgListDataSets.) because the call is contained within the scope of the dlgListDataSets class object. See the section Accessing a List Box Control with Origin C for a link to all source code used in the example above.