List Info

Thread: access to class elements (wxFrame to wxFrame)




access to class elements (wxFrame to wxFrame)
user name
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 <tzingenion.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,
&gt; Hi Daniel,
&gt; >
> > 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:&quot;));
&gt; >   ;  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.
&gt; For example add a public method
&gt; 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
&gt; void preferencesfrm::OnButtonClick( wxCommandEvent& event )
> {
>&nbsp; &nbsp;  wxString str:
>  ; &nbsp; str = wxT("COMBOBOX1 VALUE1 SELECTED:&quot;) + COMBOBOX1->GetValue();
>&nbsp;   ; mFrmP->SetTextCtrl(str);
>; }
> Hope this helps
>; Regards
&gt; Thomas
&gt;
> > (with dot or arrow after the class mainfrm)
> >
> > But I get the message error: syntax error before '->' token or error:
&gt; > syntax error before '.' token.
&gt; >
> > greetings
> > Daniel S.
> >
> > > --- Ursprüngliche Nachricht ---
> > > Von: Thomas Zehbe <tzingenion.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,
&gt; > >
> > > > Hello,
&gt; > > >
> > > > 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
&gt; > > Thomas
&gt; > >
> > > > 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,
&gt; > > > if preferencesfrm is your derived frame and TextCtrl1 is a defined
&gt; > >
> > > member
&gt; > >
> > > > variable for the textctrl, you simply write:
&gt; > > >
> > > >  void preferencesfrm::OnButtonClick( wxCommandEvent& event )
> > > >  {
> > > >   ; TextCtrl1->AppendText(wxT(&quot;COMBOBOX1 VALUE1 SELECTED:&quot;));
&gt; > > >   ; TextCtrl1->AppendText(COMBOBOX1->GetValue());
&gt; > > >  }
> > > > as OnButtonClick is a method of your class and all member vars are
> > >
> > > directly
> > >
> > > > accessible.
> > > > regards
&gt; > > > Thomas
&gt; > > >
> > > > > > I get the message error: syntax error before '->' token.
&gt; > > > > > I have include the header of my main frame class in the
> preferences
> > > >
> > > > frame
>; > > >
> > > > > > class.
&gt; > > > > > 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
&gt; > > >
> > > > > > helps me.
> > > > > >
> > > > > > A next question, but to DialogBlocks itself. The settings menu
> > >
> > > offers a
> > >
> > > > > > combobox named Language. Were can I get a German language file?
>; > > > > >
> > > > > > greetings
> > > > > > Daniel S.
> > > >
> > > > -- Dipl.-Ing. Thomas Zehbe INGENION GmbH Kuhweide 6 31552 Apelern
&gt; Fon:
> > > > 05043 is subject to: http://docs.yahoo.com/info/terms/
> > >
> > > --
> > > Dipl.-Ing. Thomas Zehbe
>; > > INGENION GmbH
> > > Kuhweide 6
> > > 31552 Apelern
&gt; > > Fon: 05043 / 40 57 904
> > > Fax: 05043 / 40 57 907
> > >
> > >
> > >
> > > Yahoo! Groups Links
>;
> --
> Dipl.-Ing. Thomas Zehbe
>; INGENION GmbH
> Kuhweide 6
> 31552 Apelern
&gt; Fon: 05043 / 40 57 904
> Fax: 05043 / 40 57 907
>
>
>&nbsp;
> Yahoo! Groups Links
>;
>
>
>&nbsp;
>
>
>

--
Echte DSL-Flatrate dauerhaft für 0,- Euro*!
&quot;Feel free" mit GMX DSL! http://www.gmx.net/de/go/dsl
access to class elements (wxFrame to wxFrame)
user name
2006-03-28 10:28:28
Am Dienstag, 28. März 2006 11:51 schrieb Daniel Schruver:
> Hello Thomas,
&gt;
> thanks for your help. I have to say that my C/C++ knowledge is not so well.
Hi Daniel, You're welcome!
> In school I have learned Delphi and a little bit of C.
...
&gt; Now this things I have done:
>;
> mainfrm.h
...
> preferencesfrm.h
>; ...
> /*pointer to MainFrm class*/
&gt; MainFrm *mFrmP;
The source compiles as expected. But you have to care that mFrmP points to an
instanciated object of type mainfrm at runtime. So there must be a statement
like this

mFrmP = <PointerToMainFrame>
anywhere in your code and must be excecuted before calling
mFrmP-&gt;SetTextCtrl(str);

I assume you first create the main frame and then you create the preferences
frame from code in the mainframe like this:
...
wxFrame* myprferencesframe = new PreferencesFrm(this, ...)

So one way ist to put this statement in the constructor of PreferencesFrm
mFrmP = (MainFrm*)parent;

This should work.
Regards
Thomas


>
> preferencesfrm.cpp
&gt; ...
> /*!
>&nbsp; * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON
*/
> void PreferencesFrm::OnButtonClick( wxCommandEvent& event )
> {
>&nbsp; &nbsp;  wxString str;
>  ; &nbsp; str = wxT("COMBOBOX1 VALUE1 SELECTED:&quot;);
&gt; &nbsp; &nbsp; mFrmP->SetTextCtrl(str);
>; }
>
&gt; The compilation was done without errors.
&gt; 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
&gt; 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.
&gt; I think the code is correct.
>
> regards
&gt; Daniel S.
>
> > --- Ursprüngliche Nachricht ---
> > Von: Thomas Zehbe <tzingenion.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,
&gt; >
> > Hi Daniel,
&gt; >
> > > 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:&quot;));
&gt; > >   ;  mainfrm.TextCtrl1->;AppendText(COMBOBOX1->GetValue());
> > >   }
> >
> > So my first understanding was wrong. In fact you are dealing with two
> > objects
&gt; > of as I assume two different classes. So we are talking about an C++
> > issue.
&gt; > Do you have programming experience using "native" C++?
> > Anyway.
&gt; > For example add a public method
&gt; > 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
&gt; > void preferencesfrm::OnButtonClick( wxCommandEvent& event )
> > {
> >   ;  wxString str:
>  ;  str = wxT("COMBOBOX1 VALUE1 SELECTED:&quot;) + COMBOBOX1->GetValue();
> >   ;  mFrmP->SetTextCtrl(str);
>; > }
> > Hope this helps
>; > Regards
&gt; > Thomas
&gt; >
> > > (with dot or arrow after the class mainfrm)
> > >
> > > But I get the message error: syntax error before '->' token or error:
&gt; > > syntax error before '.' token.
&gt; > >
> > > greetings
> > > Daniel S.
> > >
> > > > --- Ursprüngliche Nachricht ---
> > > > Von: Thomas Zehbe <tzingenion.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,
&gt; > > >
> > > > > Hello,
&gt; > > > >
> > > > > 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
&gt; > > > Thomas
&gt; > > >
> > > > > 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,
&gt; > > > > if preferencesfrm is your derived frame and TextCtrl1 is a defined
&gt; > > >
> > > > member
&gt; > > >
> > > > > variable for the textctrl, you simply write:
&gt; > > > >
> > > > >  void preferencesfrm::OnButtonClick( wxCommandEvent& event )
> > > > >  {
> > > > >   ; TextCtrl1->AppendText(wxT(&quot;COMBOBOX1 VALUE1 SELECTED:&quot;));
&gt; > > > >   ; TextCtrl1->AppendText(COMBOBOX1->GetValue());
&gt; > > > >  }
> > > > > as OnButtonClick is a method of your class and all member vars are
> > > >
> > > > directly
> > > >
> > > > > accessible.
> > > > > regards
&gt; > > > > Thomas
&gt; > > > >
> > > > > > > I get the message error: syntax error before '->' token.
&gt; > > > > > > I have include the header of my main frame class in the
> >
> > preferences
> >
> > > > > frame
>; > > > >
> > > > > > > class.
&gt; > > > > > > 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
&gt; > > > >
> > > > > > > helps me.
> > > > > > >
> > > > > > > A next question, but to DialogBlocks itself. The settings menu
> > > >
> > > > offers a
> > > >
> > > > > > > combobox named Language. Were can I get a German language file?
>; > > > > > >
> > > > > > > greetings
> > > > > > > Daniel S.
> > > > >
> > > > > -- Dipl.-Ing. Thomas Zehbe INGENION GmbH Kuhweide 6 31552 Apelern
&gt; >
> > Fon:
> > > > > 05043 is subject to: http://docs.yahoo.com/info/terms/
> > > >
> > > > --
> > > > Dipl.-Ing. Thomas Zehbe
>; > > > INGENION GmbH
> > > > Kuhweide 6
> > > > 31552 Apelern
&gt; > > > Fon: 05043 / 40 57 904
> > > > Fax: 05043 / 40 57 907
> > > >
> > > >
> > > >
> > > > Yahoo! Groups Links
>; >
> > --
> > Dipl.-Ing. Thomas Zehbe
>; > INGENION GmbH
> > Kuhweide 6
> > 31552 Apelern
&gt; > Fon: 05043 / 40 57 904
> > Fax: 05043 / 40 57 907
> >
> >
> >
> > Yahoo! Groups Links

--
Dipl.-Ing. Thomas Zehbe
INGENION GmbH
Kuhweide 6
31552 Apelern
Fon: 05043 / 40 57 904
Fax: 05043 / 40 57 907
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )