Hello I need help I been trying to make a list box like one I made in C# where you select and item in the listbox and then press a button and it does something like launch internet explorer. In my program I just have a button and a wxlistbox on the frame. I want to make a number of items and when each item is selected each one will do something different when the button is clicked. Here is my code so far it does not work. Thanks for any help.
void ListBoxFrame::OnButton3Click(wxCommandEvent& event)
{
for (int i = 0; i < ListBox1.IsSelected.Count; i++)
{
switch (ListBox1.IsSelected[i].ToString())
{
case "Foobar":
wxMessageBox(_T("Listbox item foobar selected"));
break;
case "Bazquirk":
wxMessageBox(_T("Listbox item Bazquirk selected"));
break;
case "Widgets":
wxMessageBox(_T("Listbox item Widgets selected"));
break;
case "Gadgets":
wxMessageBox(_T("Listbox item Gadgets selected"));
break;
}
}
}
Obviously it takes a real man like you to not help. The code is not miles away from proper. If you think this code is right for the purpose then you are miles off.
int sel = event.GetInt();
wxLogMessage(_T("Listbox item %d selected"), sel);
That code wont give you options for each selection. The code I wrote is very close because I have been researching and thats what they use or something like it. Oh I did read and read and read I went through and reverse engineered all the examples that wxdev provided and they all come down to that little code up there that does not do what I need to do. I searched google for 2 days and nothing worked and the info for wxlistbox to do what I want to do just is not there or not clear.
Well since I am using code blocks with wxpack it has everything to do with code blocks and wxwidgets. Yeah and that was written by me in c# not copied and pasted. I saw a c++ method like it
This is C++ and this is the code I saw that looked close to the c# method. They are both C
case MENU_FILE_TRANS:
{
char *ptrBuffer = &buffer[0];
for (int i = 0; i < RecvBytes; i+=2)
{
int firstvalue = RecvData[i] - '0';
int secondvalue;
//if RecvData[i+1] is a letter convert it to integer, otherwise use it.
switch(RecvData[i+1])
{
case 'A':
{
secondvalue = 10;
}break;
case 'B':
{
secondvalue = 11;
}break;
case 'C':
{
secondvalue = 12;
}break;
case 'D':
{
secondvalue = 13;
}break;
case 'E':
{
secondvalue = 14;
}break;
case 'F':
{
secondvalue = 15;
}break;
default:
secondvalue = RecvData[i+1] - '0';
break;
}
//convert the two values into decimal form
newval = 16 * firstvalue + secondvalue;
//change newval into a character
*ptrBuffer = char(newval);
//SendMessage(hlistbox,LB_ADDSTRING,0,(LPARAM)ptrBuffer);
ptrBuffer++;
//vShowText(hlistbox, ptrBuffer);
}
ptrBuffer = &buffer[0];
vShowText(hlistbox, ptrBuffer);
}break;