Orientation about change object in other frame, please.
newDialog ( ButtonZ -click ) ----- (Setlabel of object in mainFrame)
something like this:
void NewDialog::OnButtonZClick(wxCommandEvent& event){
mainFrame::Button1->Setlabel("lalala");
}
Change instance of other frame
-
- Experienced Solver
- Posts: 56
- Joined: Sun May 05, 2019 7:12 am
Re: Change instance of other frame
to change instance you must give it. Not a class of this instance.
Where __mainFrameInstance is a pointer to instance of class MainFrame, created by new(..)
you write -
int MyInt = 10;
you do not write
int = 10;
Class is a type. instance is an object of this type.
Code: Select all
void NewDialog::OnButtonZClick(wxCommandEvent& event){
__mainFrameInstance->Button1->Setlabel("lalala");
}
you write -
int MyInt = 10;
you do not write
int = 10;
Class is a type. instance is an object of this type.
ubuntu 20.04, wxWidgets 3.2.1
-
- Experienced Solver
- Posts: 56
- Joined: Sun May 05, 2019 7:12 am
Re: Change instance of other frame
mainFrame * __mainFrameInstance = new mainFrame(0);
void NewDialog::OnButtonZClick(wxCommandEvent& event){
__mainFrameInstance->Button_mainFrame->SetLabel("lalala");
}
this code compile whitout errors;
but clicking in the ButtonZ, Button_mainFrame don't SetLabel("lalala");
void NewDialog::OnButtonZClick(wxCommandEvent& event){
__mainFrameInstance->Button_mainFrame->SetLabel("lalala");
}
this code compile whitout errors;
but clicking in the ButtonZ, Button_mainFrame don't SetLabel("lalala");
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: Change instance of other frame
Code: Select all
class MyDialog: public wxDiaog
{
public:
MyDialog(MyFrame *parent): wxDalog(parent....){}
void ShowLalala(){
MyFrame *frame = dynamic_cast<MyFrame*>(GetParent());
if(frame) frame->SetMyText("Lalalalaaaa");
}
};
//then MyFrame
class MyFrame : public wxFrame
{
public:
MyFrame(wxWindow* parent): wxFrame(parent){}
void SetMyText(const wxString& text)
{
m_buttonInTheText->SetLabel(text);
}
}
//using it
MyFrame *f = new MyFrame(NULL);
..
..
..
MyDialog dlg(f);
dlg.ShowLalala();
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Re: Change instance of other frame
Hi,
You should learn and understand the features of the language prior to do the actual development with anything.
Thank you.
This is a basic C++ question.mxoliveira73 wrote: ↑Thu Jun 13, 2019 11:49 am mainFrame * __mainFrameInstance = new mainFrame(0);
void NewDialog::OnButtonZClick(wxCommandEvent& event){
__mainFrameInstance->Button_mainFrame->SetLabel("lalala");
}
this code compile whitout errors;
but clicking in the ButtonZ, Button_mainFrame don't SetLabel("lalala");
You should learn and understand the features of the language prior to do the actual development with anything.
Thank you.
Re: Change instance of other frame
you must somehow register this handler OnButtonZClick, to have him getting events.mxoliveira73 wrote: ↑Thu Jun 13, 2019 11:49 am mainFrame * __mainFrameInstance = new mainFrame(0);
void NewDialog::OnButtonZClick(wxCommandEvent& event){
__mainFrameInstance->Button_mainFrame->SetLabel("lalala");
}
this code compile whitout errors;
but clicking in the ButtonZ, Button_mainFrame don't SetLabel("lalala");
put debugger breakpoint at this line...
Code: Select all
__mainFrameInstance->Button_mainFrame->SetLabel("lalala");
ubuntu 20.04, wxWidgets 3.2.1