X-Functions support custom dialog created in a dialog builder as interface. If the user wants to use the customized dialog, and also wants to support Auto Update in the dialog, or wants to open the dialog from the Origin menu, then they can create an X-Function with customized dialog. And then can create an OPX file to share it to others.
Here is an example to show you how to build a resource-only DLL in Visual Studio 2008 or 2010 which is accessible in Origin C. Follow the section Creating a Resource-Only DLL, we will get two files: Welcome.dll and resource.h.
#include <..\Originlab\DialogEx.h> #include "resource.h" // file name of the resource without extension, here stand for Welcome.dll, //and it assume the DLL is in the same folder as this .h file #define STR_DLG_RESOURCE_DLL "Welcome" // the file name of resource DLL #ifdef _OWIN64 #define STR_DLG_RESOURCE_DLL "Welcome_64" // 64 bit DLL #else //!_OWIN64 #define STR_DLG_RESOURCE_DLL "Welcome" // 32 bit DLL #endif// _OWIN64 class CustomDialog : public ResizeDialog { public: // Important: IDD_MY_DIALOG is the dialog resource ID. // STR_DLG_RESOURCE_DLL is the name of the dialog resource DLL file. CustomDialog(TreeNode& trXFSettings) : ResizeDialog( IDD_MY_DIALOG, STR_DLG_RESOURCE_DLL ) { m_trXFSettings = trXFSettings; } int DoModalEx(HWND hParent = NULL) { InitMsgMap(); return ResizeDialog::DoModal(hParent); } protected: EVENTS_BEGIN ON_INIT(OnInitDialog) ON_OK(OnOK) EVENTS_END BOOL OnInitDialog() { ResizeDialog::OnInitDialog(); Edit ed; ed = GetDlgItem(IDC_EDIT1); // init dialog control with xf setting ed.Text = ftoa(m_trXFSettings.factor.dVal); return TRUE; } BOOL OnOK() { Edit ed; ed = GetDlgItem(IDC_EDIT1); m_trXFSettings.factor.dVal = atof(ed.Text); // If the input is 0, it will be changed to 1 automatically. if ( m_trXFSettings.factor.dVal == 0 ) m_trXFSettings.factor.dVal = 1; return TRUE; } private: TreeNode m_trXFSettings; };
//put additional include files here #include "CustomDlg.h"
//put your own support static functions here bool OpenCustomDlg(TreeNode& tr, PEVENT_FUNC pfn, LPCSTR lpcszTitle, LPCSTR lpcszDescription, HWND hWndParent) { CustomDialog dlg(tr); if( dlg.DoModal(GetWindow()) ) { tr.AutoUpdate.nVal = AU_AUTO; // Default is 2(Manual) return true; } else // click Cancel button on dialog { return false; // will not call main function } }
out = in * factor; // put comments like "Col(A)*8" on the Comments label of output column DataRange drIn; drIn = in.GetSourceDataRange(); Worksheet wks; int c1, c2; drIn.GetRange(wks, c1, c2); Column col(wks, c1); if( wks && col ) { string strOutputComment; strOutputComment.Format("Col(%s)*%g", col.GetName(), factor); out.SetOutputComment(strOutputComment); }
You can use Package Manager to distribute it as a single package file to other Origin users. Then he can install your application by dropping the package file into Origin directly.