Connecting Tech Pros Worldwide Forums | Help | Site Map

C++/wxWidgets Help accessing item

Member
 
Join Date: Aug 2008
Location: South essex, England
Posts: 82
#1: Sep 3 '08
Hi, Im basicly stuck trying to access a member, which controls a text box.

What I want to do is set a value for it, outside its class.


This code works in fine.
void ClientFrame::OnAbout(...){
wxTextCtrlBase *Status = ClientFrame::Status;
Status->SetValue(text);
}
What I want to do is access ClientFrame::Status, from int main().
I have tried this:

Expand|Select|Wrap|Line Numbers
  1. void ClientFrame::ChangeStatus(wxString text){
  2.         wxTextCtrlBase *Status = Status;
  3.         Status->SetValue(text);
  4. }
  5. int main(){
  6.     ClientFrame.ChangeStatus(_("Attempting to connect to server "));
  7. .
  8. .
  9. .
  10. }
This may seem simple in some casses, but I cant get my head round it!
error: expected unqualified-id before '.' token.


Sorry if my explanation is poor.

Moderator
 
Join Date: Mar 2007
Location: North Bend Washington USA
Posts: 5,379
#2: Sep 3 '08

re: C++/wxWidgets Help accessing item


Is ClientFrame::Status a public member of ClientFrame?

If not, the access is restricted to ClientFrame members.
Member
 
Join Date: Aug 2008
Location: South essex, England
Posts: 82
#3: Sep 4 '08

re: C++/wxWidgets Help accessing item


Sorry for the late responce, but it seems I declared the prototype not in ClientFrame, but here instead:
Expand|Select|Wrap|Line Numbers
  1. class ClientFrame: public wxFrame
  2. {
  3.     public:
  4.  
  5.         void ChangeStatus(wxString text);
  6. .
  7. .
  8. .
And I cant find the declaration of ClientFrame, so is there another way to access a function like this:

Expand|Select|Wrap|Line Numbers
  1.         wxTextCtrlBase *Status = Status;
  2.         Status->SetValue(text);
Status is private in ClientFrame, and I need to access SetValue somehow.


This function would work because it is in Clientframe class, which I cant seem to find, at all.
Expand|Select|Wrap|Line Numbers
  1. void ClientFrame::OnAbout(wxCommandEvent& event)
  2. {
  3. wxTextCtrlBase *Status = Status;
  4.         Status->SetValue(text);
  5. }
Any suggestions?
Member
 
Join Date: Aug 2008
Location: South essex, England
Posts: 82
#4: Sep 4 '08

re: C++/wxWidgets Help accessing item


Ok, nevermind that, what I want to do in wxWidgets is to create a main() function, to run for loops.

Im trying to convert a console program into a GUI, and failing.
Member
 
Join Date: Aug 2008
Location: South essex, England
Posts: 82
#5: Sep 5 '08

re: C++/wxWidgets Help accessing item


Can something tell me a way to have a main-like loop in wxWidgets?
Reply