【お知らせ】この部分は英語原文のみでの提供となります。何卒ご了承ください。
2.1.27.9 GetNBox
Contents
Description
This function opens a dialog from a tree constructed using a set of macros.
Syntax
int GetNBox(TreeNode& tr, PEVENT_GETN pfnEventEx, LPCSTR lpcszTitle = NULL, LPCSTR lpcszDescription = NULL, HWND hWndParent = NULL, bool bShowApplyButton = false, PAPPLY_FUNC pfnApply = NULL);
int GetNBox(TreeNode& tr, PEVENT_GETN pfnEvent, GetNBoxDisplayInfo* pInfo, HWND hWndParent = NULL);
Parameters
- trNode
- [modify] A TreeNode constructed by the GETN_BOX or GETN_TREE macro
- pfnEventEx
- [input] PEVENT_GETN type function pointer. See PEVENT_GETN for more details, or see function GetNBox_ex3 below for example.
- lpcszTitle
- [input] Dialog title
- lpcszDescription
- [input] A line of text above the editable list of parameters
- hWndParent
- [input] Parent window. If NULL, Origin main window will be used, also the location of the dialog will be reset to where it was brought up the time before.
- If hWndParent is specified, the dialog will be open at its default location, so the event handler can move the dialog to a desired location.
- bShowApplyButton
- [input] true to show Apply button; false will not show.
- pfnApply
- [input] PAPPLY_FUNC type function pointer. If specified, an Apply button will show and call this handler when click button. Click PAPPLY_FUNC for more details.
- tr
- [modify] A TreeNode constructed by the GETN_BOX or GETN_TREE macro
- pfnEvent
- [input] PEVENT_GETN type function pointer. See PEVENT_GETN for more details
- pInfo
- [input] Set dialog title, customise OK/Cancel buttons etc. See function GetNBox_ex4 below for example.
class GetNBoxDisplayInfo { public: LPCSTR lpcszTitle; // dialog title LPCSTR lpcszDescription; // A line of text above the editable list of parameters bool bAlwaysUpdateEditTree; // if true, tr is always be updated after dialog closes, no matter OK or Cancel button is clicked. bool bShowApply; // true to show Apply button; false will not show. PAPPLY_FUNC pfnApply; // PAPPLY_FUNC type function pointer. If specified, an Apply button will show and call this handler when click button. Click [[OriginC%3APAPPLY_FUNC|PAPPLY_FUNC]] for more details. LPCSTR lpcszTextApply; // Apply button's text bool bHideOK; // true to hide OK button LPCSTR lpcszTextOK; // OK button's text bool bHideCancel; // true to hide Cancel button LPCSTR lpcszTextCancel; // Cancel button's text bool bHideContextHelp; // true to hide the context help button on the upper-right corner of the dialog };
- hWndParent
- [input] Parent window. If NULL, Origin main window will be used, also the location of the dialog will be reset to where it was brought up the time before.
- If hWndParent is specified, the dialog will be open at its default location, so the event handler can move the dialog to a desired location.
Return
1 if user clicks OK, 0 if user clicks Cancel.
Examples
EX1
#include <Origin.h> #include <GetNbox.h> // this will bring up the simple form with dialog look void GetNBox_ex1() { double x0, x1; GETN_BOX(trTemp) GETN_NUM(xFrom, "X From", 1.3) GETN_NUM(xStep, "X Step", -0.5) if(GetNBox(trTemp, "Row# as X", "Please specify initial X value and increment")) { x0 = trTemp.xFrom.dVal; x1 = trTemp.xStep.dVal; printf("X from %f with increment %f\n", x0, x1); } }
Ex2
#include <GetNbox.h> void GetNBox_ex3() { GETN_TREE(tr) GETN_CHECK(check, "Yes or No", 0) GETN_STR(strval, "Please enter a text for label", "") if( GetNBox(tr, _event_func_ex, "Test Event Function", "Test...") ) { out_str("Done"); // if OK button clicked } } int _event_func_ex(TreeNode& tr, int nRow, int nEvent, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& getNContainer, string& strAux, string& strErrMsg) { TreeNode trEdited; // check nEvent switch(nEvent) { case GETNE_ON_INIT: out_str("Dialog Init event."); break; case GETNE_ON_OK: out_str("Cliked OK button. "); break; case GETNE_ON_VALUE_CHANGE: trEdited = tree_get_node(tr, nRow); if( trEdited ) printf("%s control changed.\n", trEdited.tagName); break; } // use lpcszNodeName to get the changed node if(lstrcmpi(lpcszNodeName,"strval") == 0) { out_str(tr.strval.strVal); } // shows how to disable OK button if( tr.check ) { // disable OK button if "Yes or No" checkbox is unchecked. bool bEnable = ( 1 == tr.check.nVal ); O_SET_BIT(dwEnables, GETNGEVT_OK_ENABLE, bEnable); if( !bEnable ) strErrMsg = "Error! Yes or No checkbox is unchecked"; } return true; }
Ex3
#include <GetNbox.h> void GetNBox_ex4() { GetNBoxDisplayInfo displayInfo; displayInfo.lpcszTitle = "Test GetNBoxDisplayInfo"; displayInfo.bAlwaysUpdateEditTree = true; displayInfo.lpcszTextOK = "Close"; displayInfo.bHideCancel = true; displayInfo.bHideContextHelp= true; GETN_TREE(tr) GETN_CHECK(check, "Yes or No", 0) GETN_STR(strval, "Please enter a text for label", "") GetNBox(tr, NULL, &displayInfo); out_tree(tr); }
Remark
See Also
InputBox, GetN, PAPPLY_FUNC, PEVENT_GETN
Header to Include
GetNbox.h