Help with classes

This is a discussion on Help with classes within the C++ Programming forums, part of the General Programming Boards category; I'm definitely getting lost in al the wxWidget classes. I want to have a frame/window that acts like a cout ...

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    85

    Help with classes

    I'm definitely getting lost in al the wxWidget classes. I want to have a frame/window that acts like a cout - there's a textbox on it, and it can be accessed from any other frame.

    I'm not sure how I can do this, though. Someone on the wxForum recommended me wxLog, but that seems to be only local to a class. Is it possible to make the log global to all classes ? If yes, how?

  2. #2
    Registered User
    Join Date
    Aug 2007
    Posts
    85
    Hmm, i think i got it, but I don't know how to implement this.
    I've got class A and class B, both implemented in main. Class A contains a pointer to a class B. Somehow, I have to set this pointer externally, in main, after B is implemented.

    Is this possible?

  3. #3
    The larch
    Join Date
    May 2006
    Posts
    3,573
    std::cout is a global instance of std:stream if I'm not mistaken, so you might also declare a global wxLog or whatever instance.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  4. #4
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    There's a wx class that is a textbox, but I can't remember the name offhand. What you should do is provide a function for your frame that the textbox is on, to accept a wxString and then have that frame put the wxString in the textbox.

  5. #5
    Registered User
    Join Date
    Aug 2007
    Posts
    85
    yes, but how can I call the frame with the textbox from a bunch of other frames?
    I'm thinking of something with pointers, but I ain't entirely sure.

  6. #6
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Do you have no idea how any of this works?

    Create a parent frame that represents your program. Have that frame start other frames or dialogs, depending on what is needed. Pass a pointer (or a reference) of the parent frame into the constructor of your child frames. Heck, you probably could even pass it into the constructor of wxFrame as the parent window (although that may not be what you want).

    There. Now the child frame can call a function in your parent frame. addText() or something that you define. Go for it.

    TBH, I think you're rushing your way learning a bunch of libraries and fancy things before even getting a real firm grasp of the language itself. Consider slowing down and building a better foundation.

  7. #7
    The larch
    Join Date
    May 2006
    Posts
    3,573
    If the other frames are children of the window where you want to print to, you should be able to get a pointer to the parent from the child (some method). To call a custom method on it, you'd need to dynamic_cast it to your frame class.

    If they are not children, you'll probably need to store a pointer/reference to the log window/control in each of them.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you Initialize all classes once with New?
    By peacerosetx in forum C++ Programming
    Replies: 12
    Last Post: 07-02-2008, 10:47 AM
  2. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  3. Exporting VC++ classes for use with VB
    By Helix in forum Windows Programming
    Replies: 2
    Last Post: 12-29-2003, 04:38 PM
  4. Prime Number Generator... Help !?!!
    By Halo in forum C++ Programming
    Replies: 9
    Last Post: 10-20-2003, 07:26 PM
  5. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21