Is there a way to iterate trought controls using the control's ID number.
I mean, if i have 20 checkboxes, is there a way to check the state of each one of them using the control ID and incremating this ID (asuming secuentials IDs numbers)???
I could do this with the win32 Api - SendMessage() function -, but i can't find a way to do this in wxWidgets yet.
Iterating through controls with control ID number
-
- Earned some good credits
- Posts: 113
- Joined: Mon May 09, 2005 5:11 am
- Location: Argentina - BS AS
Iterating through controls with control ID number
Just a newbie - Too many interests, not too many time.
Windows XP SP2
Kubuntu GNU/Linux - Feisty
wxActiveRecordGenerator (aka wxARG) maintainer
Find it at wxCode
Windows XP SP2
Kubuntu GNU/Linux - Feisty
wxActiveRecordGenerator (aka wxARG) maintainer
Find it at wxCode
-
- Earned some good credits
- Posts: 120
- Joined: Sun Aug 29, 2004 3:09 pm
- Location: Grenoble, France
- Contact:
Yes you can by the wxWindow::FindWindowByID [1]. You have just to pass the parent adress and the ID, and it return the corresponding child wxWindow adress.
You can also use the wxWindow::GetChildren [2] but it is useless.
[1] : http://www.wxwidgets.org/manuals/2.6.0/ ... windowbyid
[2] : http://www.wxwidgets.org/manuals/2.6.0/ ... etchildren
You can also use the wxWindow::GetChildren [2] but it is useless.
[1] : http://www.wxwidgets.org/manuals/2.6.0/ ... windowbyid
[2] : http://www.wxwidgets.org/manuals/2.6.0/ ... etchildren
What is little and green, witch go up and down ??
Yoda playing with the force.
Yoda playing with the force.
-
- Earned some good credits
- Posts: 113
- Joined: Mon May 09, 2005 5:11 am
- Location: Argentina - BS AS
Thanx for answeringCursor wrote:Yes you can by the wxWindow::FindWindowByID [1]. You have just to pass the parent adress and the ID, and it return the corresponding child wxWindow adress.
You can also use the wxWindow::GetChildren [2] but it is useless.
[1] : http://www.wxwidgets.org/manuals/2.6.0/ ... windowbyid
[2] : http://www.wxwidgets.org/manuals/2.6.0/ ... etchildren
Now...lets see...how do i use the child address? Is it the pointer of the control? Do i have to cast it? Can u give a small example plz?
My idea is:
Code: Select all
wxCheckbox temp;
temp=wxWindow::FindWindowById(ID_CHECKBOX1,this);
if(temp->IsChecked()) count++;
Just a newbie - Too many interests, not too many time.
Windows XP SP2
Kubuntu GNU/Linux - Feisty
wxActiveRecordGenerator (aka wxARG) maintainer
Find it at wxCode
Windows XP SP2
Kubuntu GNU/Linux - Feisty
wxActiveRecordGenerator (aka wxARG) maintainer
Find it at wxCode
Well, FindWindowsById returns a pointer!
Do it this way:
Do it this way:
Code: Select all
wxCheckBox* temp = wxWindow::FindWindowById(ID_CHECKBOX1, this);
if(temp->IsChecked()) count++;
To be sure you can also use wxDynamicCast and wxStaticCast to see if the control you get the ID back from is a proper wxCheckBox control.
- Jorgen
- 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