|
List Info
Thread: access to class elements (wxFrame to wxFrame)
|
|
| access to class elements (wxFrame to
wxFrame) |

|
2006-03-28 09:51:06 |
|
Hello Thomas,
thanks for your help. I have to say that my C/C++ knowledge is not so well.
In school I have learned Delphi and a little bit of C.
Your suggestion was already my idea, but I thought that's a workaround and
it must give a way for directly access to a visualy placed member DB and its
function of a class.
Now this things I have done:
mainfrm.h
...
void SetTextCtrl(wxString str);
//// begin MainFrm member variables
wxTextCtrl* TextCtrl1;
//// end MainFrm member variables
mainfrm.cpp
...
/*add text to textCtrl1*/
void MainFrm::SetTextCtrl(wxString str)
{
TextCtrl1->AppendText(str);
}
preferencesfrm.h
...
/*pointer to MainFrm class*/
MainFrm *mFrmP;
preferencesfrm.cpp
...
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON
*/
void PreferencesFrm::OnButtonClick( wxCommandEvent& event )
{
wxString str;
str = wxT("COMBOBOX1 VALUE1 SELECTED:");
mFrmP->SetTextCtrl(str);
}
The compilation was done without errors.
If I open the preferences frame, using the menu item for this, and click the
button onto the preferences frame an error appears:
The command in 0x00403666 points to memory in 0x0000019c. Read on memory
could not done.
The message in german: Die Anweisung in 0x00403666 verweist auf Speicher in
0x0000019c. Der Vorgang read konnte nicht auf dem Speicher durchgeführt
werden.
I think the code is correct.
regards
Daniel S.
> --- Ursprüngliche Nachricht ---
> Von: Thomas Zehbe <tz ingenion.de>
> An: anthemion-devtools@yahoogroups.com
> Betreff: Re: [anthemion-devtools] access to class elements (wxFrame to
> wxFrame)
> Datum: Tue, 28 Mar 2006 10:36:24 +0200
>
> Am Dienstag, 28. März 2006 10:19 schrieb Daniel Schruver:
> > Hello,
> Hi Daniel,
> >
> > I have set a name into the "member Variable Name" field, but it did not
> > work. The error message is that TextCtrl1 is undeclared...
> >
> > TextCtrl1 is placed on mainfrm and the button is placed on
> preferencesfrm!
> > The header files of the frame classes are included in both cpp-files.
> > So I think the call to set a text into the TextCtrl should looks like
> this:
> > void preferencesfrm::OnButtonClick( wxCommandEvent& event )
> > {
> > mainfrm.TextCtrl1->AppendText(wxT("COMBOBOX1 VALUE1 SELECTED:"));
> > mainfrm.TextCtrl1->AppendText(COMBOBOX1->GetValue());
> > }
> So my first understanding was wrong. In fact you are dealing with two
> objects
> of as I assume two different classes. So we are talking about an C++
> issue.
> Do you have programming experience using "native" C++?
> Anyway.
> For example add a public method
> void setTextCtrl(wxString str) to the mainfrm class wich sets the
> Textctrl.
> Propagate a pointer to the mainfrm object to the preferencesfrm object an
> store it an a manualy in .h file or via the local vars dialog from DB
> generated membervariable.
> Assumming this var is named mFrmP you can define
> void preferencesfrm::OnButtonClick( wxCommandEvent& event )
> {
> wxString str:
> str = wxT("COMBOBOX1 VALUE1 SELECTED:") + COMBOBOX1->GetValue();
> mFrmP->SetTextCtrl(str);
> }
> Hope this helps
> Regards
> Thomas
>
> > (with dot or arrow after the class mainfrm)
> >
> > But I get the message error: syntax error before '->' token or error:
> > syntax error before '.' token.
> >
> > greetings
> > Daniel S.
> >
> > > --- Ursprüngliche Nachricht ---
> > > Von: Thomas Zehbe <tz ingenion.de>
> > > An: anthemion-devtools@yahoogroups.com
> > > Betreff: Re: [anthemion-devtools] access to class elements (wxFrame to
> > > wxFrame)
> > > Datum: Tue, 28 Mar 2006 09:36:15 +0200
> > >
> > > Am Montag, 27. März 2006 09:57 schrieb Daniel Schruver:
> > > Hi Daniel,
> > >
> > > > Hello,
> > > >
> > > > no the TextCtrl1 is a member of my main frame, not a member of the
> > > > preferencesfrm.
> > >
> > > Mark the wxTextCtrl in the DialogBlocks Editor. Than goto the
> properties
> > > list
> > > and write TextCtrl1 into the field marked "member Variable Name". DB
> will
> > > generate the definition code for you.
> > > Regards
> > > Thomas
> > >
> > > > Your code generates the error 'TextCtrl1' undeclared(first use this
> > > > function).
> > > >
> > > > greetings
> > > > Daniel S.
> > > >
> > > >
> > > > Am Montag, 27. März 2006 08:37 schrieb Daniel Schruver:
> > > > Hi Daniel,
> > > > if preferencesfrm is your derived frame and TextCtrl1 is a defined
> > >
> > > member
> > >
> > > > variable for the textctrl, you simply write:
> > > >
> > > > void preferencesfrm::OnButtonClick( wxCommandEvent& event )
> > > > {
> > > > TextCtrl1->AppendText(wxT("COMBOBOX1 VALUE1 SELECTED:"));
> > > > TextCtrl1->AppendText(COMBOBOX1->GetValue());
> > > > }
> > > > as OnButtonClick is a method of your class and all member vars are
> > >
> > > directly
> > >
> > > > accessible.
> > > > regards
> > > > Thomas
> > > >
> > > > > > I get the message error: syntax error before '->' token.
> > > > > > I have include the header of my main frame class in the
> preferences
> > > >
> > > > frame
> > > >
> > > > > > class.
> > > > > > Please tell me how can I get acces to the wxTextCntrl in my main
> > >
> > > frame
> > >
> > > > from
> > > >
> > > > > > a control on my preferences frame. The book and the wxWidgets
> help
> > > >
> > > > doesn't
> > > >
> > > > > > helps me.
> > > > > >
> > > > > > A next question, but to DialogBlocks itself. The settings menu
> > > | |