How to access all the Editboxes in a form.
-
I have more than 50 Edit boexs in a form and I want to access them in a loop rather than accessing one by one, Is there any way by which I can do it?
Thanks, Anand.
-
I have more than 50 Edit boexs in a form and I want to access them in a loop rather than accessing one by one, Is there any way by which I can do it?
Thanks, Anand.
Each editbox has an ID if you set these ids for example of 100 to 150 on the resource.h you can use of a loop.
-
Each editbox has an ID if you set these ids for example of 100 to 150 on the resource.h you can use of a loop.
Yeah right, but the project has more than 50 forms and i have to do this for all forms, already the resource IDs are tightly bound ... more , it is not reliable to .. So i was thinking if some generic loop by which we can access all the controls on form and then screen out the other controls.
Thanks, Anand.
-
I have more than 50 Edit boexs in a form and I want to access them in a loop rather than accessing one by one, Is there any way by which I can do it?
Thanks, Anand.
Anand Todkar wrote:
Is there any way by which I can do it?
Set the taborder of all EditBox in a sequence. Now take the handle of EditBox in the top of zorder and call the GetWindow() with GW_HWNDNEXT. This will return the handle to the 2nd EditBox. now pass the 2nd EditBox handle to get third list and so on. Another option is to set the id value of the EditBox in a sequence. Now call the GetDlgItem() function in a for loop with the index starting from the id of first EditBox to the last one.
nave [OpenedFileFinder]
-
Each editbox has an ID if you set these ids for example of 100 to 150 on the resource.h you can use of a loop.
You mean something like that,
#define IDC_ONE 1000 #define IDC_TWO 1001
So, there can I use any number. I mean there is no restrictions on predefined events?I appreciate your help all the time... Eranga:)
-
Yeah right, but the project has more than 50 forms and i have to do this for all forms, already the resource IDs are tightly bound ... more , it is not reliable to .. So i was thinking if some generic loop by which we can access all the controls on form and then screen out the other controls.
Thanks, Anand.
Anand Todkar wrote:
Yeah right, but the project has more than 50 forms
Do all the forms have a common main dialog?
nave [OpenedFileFinder]
-
Anand Todkar wrote:
Is there any way by which I can do it?
Set the taborder of all EditBox in a sequence. Now take the handle of EditBox in the top of zorder and call the GetWindow() with GW_HWNDNEXT. This will return the handle to the 2nd EditBox. now pass the 2nd EditBox handle to get third list and so on. Another option is to set the id value of the EditBox in a sequence. Now call the GetDlgItem() function in a for loop with the index starting from the id of first EditBox to the last one.
nave [OpenedFileFinder]
Naveen.R wrote:
Set the taborder of all EditBox in a sequence. Now take the handle of EditBox in the top of zorder and call the GetWindow() with GW_HWNDNEXT. This will return the handle to the 2nd EditBox. now pass the 2nd EditBox handle to get third list and so on.
This sounds good, let me try this way, as the Taborder is not going to change. Thanks naveen :)
Thanks, Anand.
-
You mean something like that,
#define IDC_ONE 1000 #define IDC_TWO 1001
So, there can I use any number. I mean there is no restrictions on predefined events?I appreciate your help all the time... Eranga:)
Not any number,numbers must unique.
-
Not any number,numbers must unique.
Ya, its' true. What I mean that there is any numbers couldn't I use, may be those numbers are already use somewhere in the application.
I appreciate your help all the time... Eranga:)
-
I have more than 50 Edit boexs in a form and I want to access them in a loop rather than accessing one by one, Is there any way by which I can do it?
Thanks, Anand.
Hi, I made it very easy with an Array from pointers to the control. In my case, it was:
CMyColorComboBox* m_aComboBoxes [MAX];
then, in the constructor of the Dialog... I wrote the access to them. m_aComboBoxes[0] = &m_cmcbbVisIn1; m_aComboBoxes[1] = &m_cmcbbVisIn2; m_aComboBoxes[2] = &m_cmcbbVisIn3; m_aComboBoxes[3] = &m_cmcbbVisIn4; and then I use loops to access, write, delete data from them.
for (int i = 0; i < MAX; i++)
m_aComboBoxes [MAX]->ResetContent ();I have done it in that way because I had the member variables from class wizard. But you can use the idea as well without having any variable and using GetDlgItem (ID). If you use the GetDlgItem ... then you must use OnInitDialog or on InitialUpdate. Because if you use the constructor to give the pointers... then you will have an assertion because the window doesn't exist when trying to access. Hope it helps
Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)
-
Yeah right, but the project has more than 50 forms and i have to do this for all forms, already the resource IDs are tightly bound ... more , it is not reliable to .. So i was thinking if some generic loop by which we can access all the controls on form and then screen out the other controls.
Thanks, Anand.
Anand Todkar wrote:
...already the resource IDs are tightly bound ... more , it is not reliable to...
What exactly do you mean by this? Why can't you just open the project's
resource.h
file (or whatever you have named it) and renumber the controls such that they are sequential?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Anand Todkar wrote:
...already the resource IDs are tightly bound ... more , it is not reliable to...
What exactly do you mean by this? Why can't you just open the project's
resource.h
file (or whatever you have named it) and renumber the controls such that they are sequential?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
Yeah David, you are right, i done the changes in Resource file and accessed the Controls in a loop. Thanks for your help.
Thanks, Anand.