Launching Dialog Builder Resources with Origin C

After building your resource in Visual C++ it is a good idea to open your resource in Origin to verify that it looks the way you want. Before accessing your resource in Origin, make sure your resource-only DLL and all the Origin C source and header files are in the same project folder.

To launch a Dialog Builder resource (dialog) in Origin with Origin C:

  1. Launch Origin and open Code Builder by clicking the Code Builder toolbar button Launching Dialog Builder Resources with Origin C CodeBuilder.pngon Origin's Standard toolbar. Click the Open button Launching Dialog Builder Resources with Origin C image35.gifin Code Builder. Browse to and open the Origin C source and header files created by the Origin Dialog AppWizard. Do not open the resource-only DLL or the Visual C++ resource file (having the type *.rc) in Code Builder. Open only the Origin C source file (of type *.c or *.cpp) and header files (of type *.h).
  2. Add the source file (*.c or *.cpp) to the User folder in the Code Builder workspace by activating it and pressing the CTRL + W keys. The source file should #include both header files.Select the Tools:Rebuild All menu item in Code Builder to compile and link the Origin C code used to launch the resource.
  3. Locate a function in the source file (*.c or *.cpp) that contains code constructing an Origin C object of type Dialog and calling either the Dialog.Create or Dialog.DoModal method. The Dialog.Create method launches a modeless dialog and the Dialog.DoModal method launches a modal dialog. In source files created using the Origin Dialog AppWizard the name of the function that launches the dialog will have the form
    Launching Dialog Builder Resources with Origin C image153.gif
    where DialogName is the name of the main dialog in your resource.
  4. Activate Origin and open the Script Window by selecting the Origin Widow:Script Window menu item. Execute the function (from step 3) that launches the dialog by typing its name in the Script Window and pressing ENTER.

The following example demonstrates how to construct an Origin C object of type Dialog and then use it to launch a modal dialog.

The example code below constructs an Origin C object of type ListDataSets and then launches a modal dialog in Origin using the ListDataSets.DoModal method. In this example the user-defined class type ListDataSets is derived from the built-in Origin C Dialog class and inherits all of its functionality.

ListDataSets dlgListDataSets; // Declare 

Dialog class derived object

dlgListDataSets.DoModal(GetWindow()); // 

Launch modal dialog

The ListDataSets constructor used above declares the dlgListDataSets object by calling the Dialog class constructor. It passes the resource ID string of the dialog and the name of the resource-only DLL containing the dialog. The ListDataSets constructor is implemented elow.

ListDataSets() : Dialog(IDD_LDS_DLG, "ListDataSets") { }

The ListDataSets.DoModal method called above directly calls the Dialog.DoModal method passing to it the return value of the GetWindow function (a handle to the Origin window). The ListDataSets.DoModal function is implemented below.

int DoModal(HWND hParent = NULL)
	int nRet = Dialog::DoModal(hParent);
	return nRet;

Note: See the example in the section Accessing a List Box Control with Origin C for a link to all source code used in this example.