Hello,
I'm writing a programm with an unknown number of comboboxes which are defined in a xrc file. To get the value of the comboboxes I wanted to use just one event function for all comboboxes. But to get the value I need the id of the changed combobox. How do I get this id?
Thanks
Get id of a changed combobox Topic is solved
That is a tough one. What you want is an XRC generated ID te be identified by you without knowing what ID belongs to what XRCCTRL string?
I don't think you can do that easily.. The XRC string is not stored in the control. What you can do is create a custom XRC handler, and handle the comboboxes yourself. When for example you have to instantiate an XRC control with a certain name (convention) you can store the generated ID together with the string or pointer that identifies it in a hash map. Then upon an event, look at what ID belongs to what control.
Handling all comboboxes with one event is easy, simply specify -1 as ID and all events of that type will be sent to that one handler ..
http://docs.wxwidgets.org/trunk/classwx ... ndler.html
http://wiki.wxwidgets.org/XRC
- Jorgen
I don't think you can do that easily.. The XRC string is not stored in the control. What you can do is create a custom XRC handler, and handle the comboboxes yourself. When for example you have to instantiate an XRC control with a certain name (convention) you can store the generated ID together with the string or pointer that identifies it in a hash map. Then upon an event, look at what ID belongs to what control.
Handling all comboboxes with one event is easy, simply specify -1 as ID and all events of that type will be sent to that one handler ..
http://docs.wxwidgets.org/trunk/classwx ... ndler.html
http://wiki.wxwidgets.org/XRC
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Re: Get id of a changed combobox
Use the following:torsten wrote:Hello,
I'm writing a programm with an unknown number of comboboxes which are defined in a xrc file. To get the value of the comboboxes I wanted to use just one event function for all comboboxes. But to get the value I need the id of the changed combobox. How do I get this id?
Thanks
Code: Select all
BEGIN_EVENT_TABLE(MyClass, BaseClass)
..
EVT_COMBOBOX (wxID_ANY, MyClass::MyHandler)
..
END_EVENT_TABLE()
void MyClass::MyHandler (wxCommandEvent &event)
{
int combo_id = event.GetId();
//...
}