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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 GETN_MULTISEL_LISTBOX
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

tinkusch

Germany
94 Posts

Posted - 07/21/2021 :  4:14:00 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

cpyang

USA
1406 Posts

Posted - 07/21/2021 :  8:24:07 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

tinkusch

Germany
94 Posts

Posted - 07/22/2021 :  05:01:23 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
works...
Thank you
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000