Main frame collecting Dialog info?
-
- Super wx Problem Solver
- Posts: 497
- Joined: Mon Nov 06, 2006 9:58 pm
Main frame collecting Dialog info?
Hey, me again
I need to do something that I don't think I've seen discussed before. Can't remember though.
Anyway, I've got a ListCtrl in the main frame, and a buncha TextCtrl's in the dialog. How can I collect the value from a dialog and pass it to the main frame to collect the info and enter it in the ListCtrl?
Thanks again!
FlyingIsFun1217
I need to do something that I don't think I've seen discussed before. Can't remember though.
Anyway, I've got a ListCtrl in the main frame, and a buncha TextCtrl's in the dialog. How can I collect the value from a dialog and pass it to the main frame to collect the info and enter it in the ListCtrl?
Thanks again!
FlyingIsFun1217
Re: Main frame collecting Dialog info?
Many ways to do that - you can just have the wxDialog check for some events (choose which ones) and on those events call MainFrame->setMyData() etc.FlyingIsFun1217 wrote: Anyway, I've got a ListCtrl in the main frame, and a buncha TextCtrl's in the dialog. How can I collect the value from a dialog and pass it to the main frame to collect the info and enter it in the ListCtrl?
-
- Super wx Problem Solver
- Posts: 497
- Joined: Mon Nov 06, 2006 9:58 pm
Re: Main frame collecting Dialog info?
Why would I have the dialog check for events? Wouldn't the Frame do that?Auria wrote:Many ways to do that - you can just have the wxDialog check for some events (choose which ones) and on those events call MainFrame->setMyData() etc.FlyingIsFun1217 wrote: Anyway, I've got a ListCtrl in the main frame, and a buncha TextCtrl's in the dialog. How can I collect the value from a dialog and pass it to the main frame to collect the info and enter it in the ListCtrl?
Also, would I be able to make the frame see when the dialog closes, and have it refresh the ListCtrl?
Thanks!
FlyingIsFun1217
-
- Super wx Problem Solver
- Posts: 497
- Joined: Mon Nov 06, 2006 9:58 pm
Re: Main frame collecting Dialog info?
To know when the user closes it!FlyingIsFun1217 wrote: Why would I have the dialog check for events?
Well at least that's how i do it in my project and it works fine.
-
- Super wx Problem Solver
- Posts: 497
- Joined: Mon Nov 06, 2006 9:58 pm
Re: Main frame collecting Dialog info?
Ok, I see what you are saying; I would need to add something to do to the close event in order to collect it. But what can I use to catch that close from the main frame?Auria wrote:To know when the user closes it!FlyingIsFun1217 wrote: Why would I have the dialog check for events?
Well at least that's how i do it in my project and it works fine.
Thanks again!
FlyingIsFun1217
Re: Main frame collecting Dialog info?
perhaps look into Connectso that Dialog events are sent to the main frame.FlyingIsFun1217 wrote:Ok, I see what you are saying; I would need to add something to do to the close event in order to collect it. But what can I use to catch that close from the main frame?Auria wrote:To know when the user closes it!FlyingIsFun1217 wrote: Why would I have the dialog check for events?
Well at least that's how i do it in my project and it works fine.
Thanks again!
FlyingIsFun1217
but anyway as i already said you can just add a SetData method to your main frame and have the dialog call that one (assuming you derived both wxFrame and wxDialog)
-
- Super wx Problem Solver
- Posts: 497
- Joined: Mon Nov 06, 2006 9:58 pm
Hm we don't seem to understand each otherFlyingIsFun1217 wrote:As to the SetData method, that would be something that the Frame would do, right? So before it does that, it needs to collect the info from the dialog? Doesn't that defeat the purpose?
Pseudo-code: (it doesn,t work, it's just an example of how to proceed)
Code: Select all
class MyFrame : wxFrame
{
public:
void setData(wxString a, int b, float c);
MyFrame : wxFrame(...)
{
Show();
}
void onSomeEvent()
{
MyDialog* x =new MyDialog(this);
}
};
class MyDialog : wxDialog
{
MyFrame* parent_frame;
public:
MyDialog(MyFrame* parent) : wxDialog(parent)
{
/// ---- HERE
parent_frame = parent;
/// ----
Show();
}
void onOKClicked()
{
parent_frame -> SetData( z->GetValue(), y->GetValue(), x->GetValue() );
Hide();
}
};
As to 'Connect', can you send me a link to a doc about it?
http://wxwidgets.blogspot.com/2007/01/i ... nnect.html
Last edited by Auria on Tue Mar 27, 2007 11:42 pm, edited 4 times in total.
-
- Super wx Problem Solver
- Posts: 497
- Joined: Mon Nov 06, 2006 9:58 pm
Yeah, I'm losing itAuria wrote:Hm we don't seem to understand each otherFlyingIsFun1217 wrote:As to the SetData method, that would be something that the Frame would do, right? So before it does that, it needs to collect the info from the dialog? Doesn't that defeat the purpose?
Code: Select all
parent_frame -> SetData( z->GetValue(), y->GetValue(), x->GetValue() );
Only thing is, your getting the values and passing them on to the main frame, how does it know what to do with those values?
Thanks again, I really appreciate it
FlyingIsFun1217
Well you needs to implement a SetData method that does whatever you want it to do i don't get the question, i suppose you know how to write a method in C++?? what don't you understand?FlyingIsFun1217 wrote: your getting the values and passing them on to the main frame, how does it know what to do with those values?
-
- Super wx Problem Solver
- Posts: 497
- Joined: Mon Nov 06, 2006 9:58 pm
Well, actually, no. Gotta remember I'm new to the language, and as can be seen, I went down the wrong path and started learning wxWidgets before I knew enough c++.Auria wrote:i suppose you know how to write a method in C++?
Now we know what the root of the problem is! I'll try looking it up and study it for a while.
Thanks!
FlyingIsFun1217
Okay i didn't know you were new to C++ - in my imaginary world beginners learn the language before trying libs they cannot understand, however i don't even do it myselfFlyingIsFun1217 wrote:Well, actually, no. Gotta remember I'm new to the language, and as can be seen, I went down the wrong path and started learning wxWidgets before I knew enough c++.Auria wrote:i suppose you know how to write a method in C++?
Now we know what the root of the problem is! I'll try looking it up and study it for a while.
Thanks!
FlyingIsFun1217
but writing a method is not hard, just looking at some docs should help you
Last edited by Auria on Thu Feb 22, 2007 9:54 pm, edited 1 time in total.
-
- Super wx Problem Solver
- Posts: 497
- Joined: Mon Nov 06, 2006 9:58 pm