Need help with some basic C++

This is a discussion on Need help with some basic C++ within the C++ Programming forums, part of the General Programming Boards category; Hello all, For a while now I have been trying to code an application that has two windows forms containing ...

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    3

    Question Need help with some basic C++

    Hello all,

    For a while now I have been trying to code an application that has two windows forms containing the following:

    Form 1: A web browser and menu strip with 1 button

    Form 2: A textbox and 2 buttons


    What I am trying to do here is have the menu strip button open Form2, and when the user presses the "ok" button on form2, call the webbrowser1's navigate function.

    However, i cannot seem to do this!!

    Any help is appreciated!

    ~3321thec

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Your problem is on that line and your technique is wrong. Fix that line, and maybe the other spot, and make sure your code conforms to the C++ standard.

    (Hint: Provide real information on what doesn't work and maybe someone will provide real solutions )

  3. #3
    Registered User
    Join Date
    Sep 2007
    Posts
    3

    Question

    Well, I guess what it comes down to is, I need to know how to access members of a seperate class (ie Buttons ect.)

    And I cant provide any real information, because this is the first piece of code that needs to be written, and I have tried and failed, leaving me with two brand new forms.

    Any further help appreciated!!

    ~3321thec

  4. #4
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    So if you can't show us what you're doing, how are we supposed to know how you're screwing up?

    If you're lost on the basics of the language, start with a good tutorial or a good book and start learning the language. Also, I would recommend that you start learning how to write console programs, before GUI programs, since GUI programs usually demand a lot more knowledge of the language to be able to make them.

  5. #5
    Registered User
    Join Date
    Nov 2006
    Posts
    519
    Quote Originally Posted by 3321thec View Post
    Well, I guess what it comes down to is, I need to know how to access members of a seperate class (ie Buttons ect.)
    Class or Object? If class, you probably mean static members.
    Code:
    ClassName::memeber(<param>);
    If object, you need to have a reference to that object to be able to use it's funtions.

    Code:
    class B
    {
    public:
       void member_of_B()
       {
            cout << "B here!\n";
       }
    };
    
    
    
    Class A
    {
    
       B& b_ref;
    
    public:
       A(const B& reference_to_B_object)
       :    b_ref(reference_to_B_object)
       {}
    
        void use_member_of_class_B()
        {
             b_ref.member_of_B();
        }
    
    };
    
    
    
    int main()
    {
    
       B b;  // create B object
       A a(b); // create A object and pass it a reference to the object of class B from above
       a.use_member_of_class_B(); // A accesses a non-static  member of class B
    
        return 0;
    }


    or place A and B in a stronger (has-a) relation:

    Code:
    class B
    {
    public:
       void member_of_B()
       {
            cout << "B here!\n";
       }
    };
    
    
    Class A
    {
    
       B b;
    
    public:
       A()
       :    b()
       {}
    
        void use_member_of_class_B()
        {
             b.member_of_B();
        }
    
    };
    
    
    
    
    int main()
    {
    
       A a; // create A object whose constructor creates a B object
       a.use_member_of_class_B(); // A accesses a non-static  member of class B
    
        return 0;
    }
    Last edited by pheres; 09-06-2007 at 01:52 AM.

  6. #6
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    There is nothing "basic" about GUI programming! In fact, there is no GUI in ANSI/ISO Standard C++. (There is no mouse, graphics, color, or sound, in Standard C/C++.) This is an advanced topic.

    So, you need to tell us what GUI library you are using and what operating system you are running. If you are programming for Microsoft Windows, there is a Windows Forum. And, if you are using the Win32API, The Forgers Windows Programming Tutorial is a good start.

  7. #7
    Registered User
    Join Date
    Sep 2007
    Posts
    3
    well, i will try the windows forum.

    Thanks for you guy's time.

    I'm native to visual basic, and the console and GUI programs in VB are not really any different.

    so sorry for any trouble I may have caused, im very sorry!

    Thanks
    ~3321thec

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [ANN] New script engine (Basic sintax)
    By MKTMK in forum C++ Programming
    Replies: 1
    Last Post: 11-01-2005, 09:28 AM
  2. what are your thoughts on visual basic?
    By orion- in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 09-22-2005, 04:28 AM
  3. visual basic vs C or C++
    By FOOTOO in forum Windows Programming
    Replies: 5
    Last Post: 02-06-2005, 07:41 PM
  4. Basic Graphics programming in C, please help
    By AdRock in forum Game Programming
    Replies: 3
    Last Post: 03-24-2004, 10:38 PM

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