1
+ /* ------------------------------------------------------------------------------*
2
+ * File Name: *
3
+ * Creation: *
4
+ * Purpose: OriginC Source C file *
5
+ * Copyright (c) ABCD Corp. 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 *
6
+ * All Rights Reserved *
7
+ * *
8
+ * Modification Log: *
9
+ *------------------------------------------------------------------------------*/
10
+
11
+ // //////////////////////////////////////////////////////////////////////////////////
12
+ // Including the system header file Origin.h should be sufficient for most Origin
13
+ // applications and is recommended. Origin.h includes many of the most common system
14
+ // header files and is automatically pre-compiled when Origin runs the first time.
15
+ // Programs including Origin.h subsequently compile much more quickly as long as
16
+ // the size and number of other included header files is minimized. All NAG header
17
+ // files are now included in Origin.h and no longer need be separately included.
18
+ //
19
+ // Right-click on the line below and select 'Open "Origin.h"' to open the Origin.h
20
+ // system header file.
21
+ #include < Origin.h>
22
+ // //////////////////////////////////////////////////////////////////////////////////
23
+
24
+ // #pragma labtalk(0) // to disable OC functions for LT calling.
25
+
26
+ // //////////////////////////////////////////////////////////////////////////////////
27
+ #include < GetNbox.h>
28
+
29
+ // //////////////////////////////////////////////////////////////////////////////////
30
+
31
+ // #pragma labtalk(0) // to disable OC functions for LT calling.
32
+
33
+
34
+ // //////////////////////////////////////////////////////////////////////////////////
35
+ // This example is about GetNBox and PEVENT_GETN
36
+ // //////////////////////////////////////////////////////////////////////////////////
37
+ #include < Control.h>
38
+ void GetNBox_ex ()
39
+ {
40
+ GETN_TREE (tr)
41
+ GETN_COMBO_BUTTON (test, " >" , " List" , " User" , " AAA|BBB" , " " )
42
+ GETN_CHECK (check, " Yes or No" , 0 )
43
+
44
+ if ( GetNBox (tr, _event_func_ex, " Test Event Function" , " Test..." ) )
45
+ {
46
+ out_str (" Done" ); // if OK button clicked
47
+ }
48
+ }
49
+ static int _event_func_ex (TreeNode& tr, int nRow, int nEvent, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& getNContainer, string& strAux, string& strErrMsg)
50
+ {
51
+ // 1. show how to use tr, nRow and nEvent
52
+ if (GETNE_ON_VALUE_CHANGE == nEvent)
53
+ {
54
+ // get the value-changed node
55
+ TreeNode trEdited = tree_get_node (tr, nRow);
56
+ if ( trEdited )
57
+ printf (" changed node: %s\n " , trEdited.tagName );
58
+ }
59
+
60
+
61
+ // show how to use nEvent, lpcszNodeName, and getNContainer
62
+ if (ONODETYPE_BROWSECOMBO == nEvent && lstrcmpi (lpcszNodeName," test" ) == 0 )
63
+ {
64
+ // click the ">" button to show menu
65
+ Menu myMenu;
66
+ myMenu.Add (" Item1" , 1 , MF_STRING);
67
+ myMenu.Add (" Item2" , 2 , MF_STRING);
68
+
69
+ int nSelCmd;
70
+ POINT pt;
71
+ GetCursorPos (&pt);
72
+ myMenu.TrackPopupMenu (0 , pt.x , pt.y , getNContainer.GetSafeHwnd (), &nSelCmd);
73
+ if (nSelCmd > 0 )
74
+ {
75
+ string strName;
76
+ myMenu.GetMenuString (nSelCmd, strName, MF_STRING);
77
+ tr.test .strVal = strName;
78
+ }
79
+ }
80
+
81
+
82
+ // shows how to use strErrMsg and disable OK button
83
+ if ( tr.check )
84
+ {
85
+ // disable OK button if "Yes or No" checkbox is unchecked.
86
+ bool bEnable = ( 1 == tr.check .nVal );
87
+ O_SET_BIT (dwEnables, GETNGEVT_OK_ENABLE, bEnable);
88
+ if ( !bEnable )
89
+ strErrMsg = " Error! Yes or No checkbox is unchecked" ;
90
+ }
91
+ return true ;
92
+ }
93
+
94
+
95
+ // //////////////////////////////////////////////////////////////////////////////////
96
+ // This example shows the difference in
97
+ // GETN_STR_GROUP, GETN_MULTISEL_STR_LISTBOX and GETN_MULTISEL_LISTBOX
98
+ // //////////////////////////////////////////////////////////////////////////////////
99
+ static int Dialog1Node_event (TreeNode& tr, int nRow, int nEvent, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& getNContainer, string& strAux, string& strErrMsg)
100
+ {
101
+ string strNode = lpcszNodeName;
102
+
103
+ if (strNode == " list" ) {
104
+ vector<int > vnSel;
105
+ vnSel = tr.list .nVals ;
106
+ for (int ii = 0 ; ii < vnSel.GetSize (); ii++) {
107
+ printf (" %d: %d\n " , ii+1 , vnSel[ii]);
108
+ }
109
+ }
110
+
111
+ return true ;
112
+ }
113
+
114
+ void GetNMultiBox_ex ()
115
+ {
116
+ vector<string> vsFruits = {" Apple" , " Orange" , " Banana" , " Berries" , " Grapes" };
117
+ string strCombo;
118
+ strCombo.SetTokens (vsFruits, ' |' );
119
+
120
+ GETN_TREE (tr)
121
+ GETN_STR_GROUP (stats, " Please pick a few US Stats" , " MA" , " |MA|CA|RI|VT|NY" )
122
+ GETN_MULTISEL_STR_LISTBOX (StateList, _L (" Positive State Value" ), " " , " a|b|c" )
123
+ GETN_MULTISEL_LISTBOX (list, " Select" , 0 , strCombo)
124
+
125
+ if (GetNBox (tr, Dialog1Node_event , " Dialog title" ))
126
+ {
127
+ out_tree ( tr );
128
+
129
+ vector<int > vnSel;vnSel = tr.list .nVals ;
130
+ for (int ii = 0 ; ii < vnSel.GetSize (); ii++) {
131
+ string strName = vsFruits[vnSel[ii]];
132
+ printf (" %d: %s\n " , ii+1 , strName);
133
+ }
134
+ }
135
+ }
0 commit comments