Author |
Topic  |
|
Schmid
Germany
Posts |
Posted - 06/05/2006 : 5:33:34 PM
|
Origin Version (Select Help-->About Origin): Origin 7.5G SR3 v7.5853(B853) Operating System: Windows XP SP2
I would like to set up a dialog box having a text edit and button control(GETN_BUTTON) and a text edit control(GETN_STR).When the user klicks on the butten control, then the programm calls the GetMultiOpenBox function for selecting files and returns the file paths. The pointing problem is that I expect to show the file paths back in the user interface. For that I've got 2 ideas: 1. show multiple lines through the text edit control(as ask in the title) 2. set up text edit controls according to how many files the user selected in the event handler function to show the file paths separately.
for idea 1, I'd like to ask whether it is possible to show multiple lines in a text edit control or with other controls in OrigenC. for idea 2, my source codes are as follows:
bool main_interface() { GETN_TREE(tr) GETN_BUTTON(Path, "OpenData", "C:\\") if( !GetNBox(tr, "Open", NULL, NULL, EvHandler) ) return false; }
bool EvHandler(TreeNode& tr, int nRow, int nType, Dialog& Dlg) { if(TRGP_STR_BUTTON == nType) // If Browse button clicked then open browse dialog { StringArray sPath; GetMultiOpenBox(sPath, FDLOG_ASCII, NULL, NULL, "Open", false ); int nSize = sPath.GetSize(); if( nSize ) { tr.Path.strVal = sPath[0]; string str; for (int ii = 1; ii < nSize; ii++) GETN_STR("Path" + ftoa(ii), "Data" + ftoa(ii),sPath[ii] ) } return true; } return false; }
After compiling, it reports always "Error, Variable "_tmpNode" not declared ".
So how can I realize my aim without having OriginPro. Any help will be greatly appreciated.
|
|
Mike Buess
USA
3037 Posts |
Posted - 06/06/2006 : 4:30:15 PM
|
1. Origin 7.5's GetN dialog does not have a multiple-line text control. Closest thing is the drop-down list created by GETN_LIST.
2. The runtime error occurs because you cannot generate node labels for GETN_STR on-the-fly like you are trying to do. However, the primary reason that your approach will not work is that an event handler can only change the values of existing nodes. It cannot add new nodes (e.g., text controls) to the GetN dialog.
You'll probably have to do the file selection first and then create the GetN dialog in which to show the file list. The following code creates a drop-down list followed by individual text controls for each file. The runtime error you saw is avoided by using tr.AddTextNode instead of GETN_STR.
StringArray sPath; GetMultiOpenBox(sPath, FDLOG_ASCII, NULL, NULL, "Open", false ); string sList; sList.SetTokens(sPath,'|'); // create string for drop-down list GETN_TREE(tr) GETN_LIST(list, "File list", 0, sList) // drop-down list for(int i=0; i<sPath.GetSize(); i++) { TreeNode tn = tr.AddTextNode(sPath[i],"File" + (i + 1)); // text control } if( GetNBox(tr, "Open", NULL, NULL, NULL) ) { out_tree(tr); }
Mike Buess Origin WebRing Member |
 |
|
Mike Buess
USA
3037 Posts |
Posted - 06/07/2006 : 09:04:46 AM
|
Something more along the line of your original approach will work if you put a cap on the number of files that will be selected. This will show up to maxFiles files by creating all text controls at the start and hiding or showing as necessary...
void getnTest(int maxFiles = 32) { GETN_TREE(tr) GETN_BUTTON(Path, "OpenData", "C:\\") for(int i=0;i<maxFiles;i++) { TreeNode tn = tr.AddTextNode("","File" + (i+1)); tn.Show = false; } if( GetNBox(tr, "Open", NULL, NULL, EvHandler) ) { out_tree(tr); } }
bool EvHandler(TreeNode& tr, int nRow, int nType, Dialog& Dlg) { if(TRGP_STR_BUTTON == nType && nRow >= 0) { StringArray sPath; int nSize = GetMultiOpenBox(sPath, FDLOG_ASCII, tr.Path.strVal, NULL, "Open", false ); int maxFiles = tr.GetNodeCount() - 1; if( nSize ) { tr.Path.strVal = GetFilePath(sPath[0]); for(int i=0; i<maxFiles; i++) { TreeNode tn = tr.GetNode("File" + (i+1)); tn.strVal = i<nSize ? sPath[i] : ""; tn.Show = i<nSize ? true : false; } } return true; } return false; }
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 06/07/2006 09:36:26 AM |
 |
|
Schmid
Germany
Posts |
Posted - 06/07/2006 : 2:51:08 PM
|
Mike, Thank you so much for your kind help.It's a pity that event handler can only change the values of existing nodes, but cannot define new nodes. That means we cannot set up new controls in the interface dynamically using GetN method. So I think your second solution should be the only way out along the way of my approach. Moreover, it happened to be the final solution I've found. Thank you again. |
 |
|
|
Topic  |
|
|
|