The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 GETN_MULTISEL_LISTBOX

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
tinkusch Posted - 07/21/2021 : 4:14:00 PM
Origin Pro 2018G, SR1, Win10

need some help with the Multiselect_ListBox.
I wrote a dialog function with a multiselect listbox in ORIGIN C:

int Dialog1()
{
   GETN_TREE(tree1)   
   GETN_MULTISEL_LISTBOX(Menu, "Select ", 0, "A|B|C|D|E")
   if(GetNBox(tree1, Dialog1Node_event , "Dialog title"))
   {
     return 0;
   }
   return 1;
}


The following Dialog1Node_event function should evaluate the selection:

int Dialog1Node_event(TreeNode& tree1, int nRow, int nEvent, DWORD& dwEnables,       
        LPCSTR lpcszNodeName, WndContainer& getNContainer, string& strAux, 
        string& strErrMsg)
{
   TreeNode trEdited;
   switch(nEvent)
   {
   case GETNE_ON_VALUE_CHANGE: 
       trEdited = tree_get_node(tree1, nRow);
       vector<string> vsOnlySubNode;
       tree_get_values(trEdited, vsOnlySubNode, true);
       out_int("size ",vsOnlySubNode.GetSize());
       for(int ii=0;ii<vsOnlySubNode.GetSize();ii++)
           printf("subnode string %s\n",vsOnlySubNode[ii]);

   break;
   }
   out_tree(trEdited);
   return 1;
}


The dialog works with the below output if all enrtries are selected:
size 1
subnode string AAAAAAEAAAACAAAAAwAAAAQAAAA=
Select = 5:{0, 1, 2, 3, 4}


It seems that the tree is ok but the subnode string looks odd and seemingly cannot be evaluated this way.
So what is wrong with the code?
What is the best way to evaluate the dialog?
What data type does GETN_MULTISEL_LISTBOX return?
Any help or comments welcome, thanks,
Stefan
2   L A T E S T    R E P L I E S    (Newest First)
tinkusch Posted - 07/22/2021 : 05:01:23 AM
works...
Thank you
cpyang Posted - 07/21/2021 : 8:24:07 PM
GETNE_ON_VALUE_CHANGE unfortunately does not have lpcszNodeName so you will need to use nRow, which is not as clean as using tree node name, so just test it is better, see the code below.


static int Dialog1Node_event(TreeNode& tr, int nRow, int nEvent, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& getNContainer, string& strAux, string& strErrMsg)
{	
	string strNode = lpcszNodeName;
	
	if(strNode == "list") {
		vector<int> vnSel;
		vnSel = tr.list.nVals;
		for(int ii = 0; ii < vnSel.GetSize(); ii++) {
			printf("%d: %d\n", ii+1, vnSel[ii]);
		}
	}

	return true;
}

void tms()
{
	vector<string> vsFruits = {"Apple", "Orange", "Banana", "Berries", "Grapes"};
	string strCombo;
	strCombo.SetTokens(vsFruits, '|');
	
	GETN_TREE(tr)
	GETN_MULTISEL_LISTBOX(list, "Select", 0, strCombo)
	
	if(GetNBox(tr, Dialog1Node_event , "Dialog title"))
	{
		vector<int> vnSel;vnSel = tr.list.nVals;
		for(int ii = 0; ii < vnSel.GetSize(); ii++) {			
			string strName = vsFruits[vnSel[ii]];
			printf("%d: %s\n", ii+1, strName);
		}	
	}
}



Basically multiple selection give you a vector of the selected entries with the row index.

CP

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000