1.18.4 Adding Controls to a Graph

If you want to attach a dialog to a page, similar to a workbook's organizer or the top of a polar graph, then the SetSplitters method of the PageBase class can be used to accomplish this.

To add a dialog bar to a page, lpcszString needs to include the dialog class name and the position (Left, Right, Top or Bottom) of the page window. Set lpcszString as NULL to remove the existing dialog bar.

The following example shows how to add and remove user-created dialog on a Graph window.

The class of the user-defined dialog:

#include <..\Originlab\DialogEx.h>
// OC_REGISTERED key word must allow the PageBase::SetSplitters method 
// to find this class.
class OC_REGISTERED MyGraphPolarBar : public Dialog
	// IDD_POLAR_CONTROL is dialog resource ID
	// Odlg8 is the name of dialog resource DLL file, if not specified path, 
	//default path is \OriginC\Originlab.
	:Dialog(IDD_POLAR_CONTROL, "Odlg8")
	BOOL CreateWindow(int nID, HWND hWnd)
		int nRet = Dialog::Create(hWnd, DLG_AS_CHILD);
		HWND hWndThis = GetSafeHwnd();
		SetWindowLong(hWndThis, GWL_ID, nID);
		return nRet;

Add or remove dialog on a Graph window.

void Page_SplittersControl(BOOL bShow = TRUE, int nPos = 2)
	Page pg = Project.Pages("Graph1");

	if( bShow )
		int nPercent = 30;
		string strDlgClass = "MyGraphPolarBar"; // the above dialog class
		string	strConfig;
		case 0: // Bottom
			strConfig.Format("r{%s}r[%s]", (string)nPercent+"%", strDlgClass);
		case 1: // Right
			strConfig.Format("c{%s}c[%s]", (string)nPercent+"%", strDlgClass);
		case 2: // Top
			strConfig.Format("r[%s]{%d}r", strDlgClass, nPercent);
		case 3: // Left
			strConfig.Format("c[%s]{%d}c", strDlgClass, nPercent);
		pg.SetSplitters(NULL);	// remove dialog bar from page