|
how do i get the default value of a check box into another form?
for example i have 2 check boxes in a form. if i click on any of the check boxes the value is getting passed. but what do i do to make the application fetch the value without clicking the checkboxes. or without opening that form?
|
|
|
|
|
Do you have tried already a simple GetWindowText?
Greetz
|
|
|
|
|
how can i use a GetWindowText function for this? i am not accessing the form for that. the default value needs to be set once i click on the first menu item of the screen.
|
|
|
|
|
You can set the value of the control via SetWindowText
This way:
CString val = "My Default";
MyComboBox.SetWindowText(val);
if you do this from another view, you need to have a pointer to the view where you want to change the value
In the view you create a small funtion which gets a CString and puts it into the control
void FirsteView::SetValueToComboBox(CString val)
{
MyComboBox.SetWindowText(val);
}
you call it naturally this way:
void SecondView::Test()
{
PointerToFirstView->SetValueToComboBox("lalalaa");
}
Via a Menu-Item it's the same way. You call into the menu-item-handler the SetValueToComboBox Function of the other view
I saw my error, i was doing the traitement for Combobox, not for Checkbox! SORRY
But the accessing to the control is the same, but Get/SetWindowText is totally bullshit
It's monday morning
|
|
|
|
|
What has to do GetWindowText with check box state?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Woupssss
Confused Combobox with Checkbox
Thanks for notation
|
|
|
|
|
|
workaround...???
any leads? please... dying to figure out this for the last couple of days. i have actually used GetCheck function to get the current value of the checkbox. that i am getting correctly. second part i am stuck..
|
|
|
|
|
Chandrasekharanp wrote: workaround...???
Yes, you have to store the check box status inside variables and access the latter. If you need to access the check status even when the form does not exists, then you have to make that variables persistent.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
that was a killer and went over my head... can u explain in a simpler way?
|
|
|
|
|
The form can store on a file the status of its check boxes, hence making them available (via file reading) even when the application is not alive.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
ok... i can certainly try that..
now another thing that i need to solve is that when i click on a checkbox. for ex: "changing the state to 0" will the value be the same when i come back again to the same screen or will it get reset? i am aware of the fact that i cant use OnOK() with formview class. so what can be done to store the state of the checkbox. if it resets what are the options to keep the checkbox alive thou the screen is not used?
i hope u understood my problem
|
|
|
|
|
I guess we're talking about MFC . Why don't you map the check box control (i.e. the CButton) to a form variable member? This way you can access the member variables even when the form is no more visible (is no more a Window).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
i know i am asking u too much... but i am forced to... will u be able to give me an example??
|
|
|
|
|
Well, it is not difficult:
Open the resource editor and select the dialog corrensponding to you FormView then select one of the check boxes, click the right mouse button and finally choose Add Variable item in the newly appeared context menu.
On the appeared dialog, choose the Value item of the Category list box, give a meaningful name to the variable and finally click the Finish button.
The new created variable will reflect the checkbox state content each time you call UpdateData and will maintain that value even when the FormView will be no more visible.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
i have done all this. now one thing that i need to know is, this has to been put in on InitialUpdate Function or OnDraw function?
|
|
|
|
|
Whenever you need (I guess either in the OnInitialUpdate handler and just before closing your FormView, at least -you may need it also whenever check status changes, I don't know about-. Don't do it in the OnDraw method).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
i did that. this is what i did.
created a function for the checkbox. there is an interger values which stores the checkbox status.
OnInitialUpdate Function i have mentioned a function called GetCheckBoxStatus which checks the status of the checkbox and returns. (As far as i know OnInitialUpdate is a function which gets called each time the dialog opens). so each time OnInitialUpdate fucntion gets called the state of the checkbox is returned....right??
But i am not being set the state after changing. its resetting to the original value(checked).
i know this is a simple mistake.. but cant figure out. please help..
|
|
|
|
|
Chandrasekharanp wrote: OnInitialUpdate Function i have mentioned a function called GetCheckBoxStatus which checks the status of the checkbox and returns.
You don't need it, just call UpdateData and the (bound) member variable will be assigned with the check box status.
Chandrasekharanp wrote: But i am not being set the state after changing. its resetting to the original value(checked).
If I understand correctly what do you need, then you have to call UpdateData each time the check box status changes.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
UpdateData(TRUE) is been called each time the state of the check box is changed,
|
|
|
|
|
setting of check box is done. the idea which u told me. the file option is will not work. is there any other way to figure out this?
fetching the data without opening the page.
|
|
|
|
|
How to call Matlab functions in VC++ plz help me
#sanroop#
|
|
|
|
|
Why do you repost without even making Hamid know if his reply [^] was helpful or not?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
I think if your answer is helpful you will be not get any reply but if its not you will be get vote down .
modified on Monday, January 21, 2008 5:32:43 AM
|
|
|
|
|
Your answer got no reply and wasn't voted down (in fact it was voted up), hence was helpful. Now, what is the rationale behind reposting the original question?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|