my C++ teacher is horrible... this is so easy but i need help :o

Discussion in 'OT Technology' started by Tk, Feb 6, 2006.

  1. Tk

    Tk Well-Known Member

    Joined:
    Dec 23, 2001
    Messages:
    23,086
    Likes Received:
    285
    Location:
    nw iowa
    im in a c++ class at a community college... since school started this semester, ~3 weeks, hes explained the basics, now we are in to conditional statements and loops.... real basic things. anyways, we've been doing this tasks in console environments, using devc++. ive got no problem with that, but shits slow for me and i want to use vs.net.

    so he said me and another kid can use vc++2005 express for our programs, but it seems like he doesnt know the first thing about the IDE.

    anyways heres my question: ive added a form (frmAbout) to my project, and I want to show frmAbout from a click event in my frmMain. simple VB that i used years ago would suggest frmAbout.Show();, but this doesnt work. you have to create a .... something to reference the object.

    how exactly is this done?

    ive been reading through MSDN 2005 and the closest thing ive come across is:

    Form^ form1 = gcnew Form;

    but thats just creating a new, blank form.

    the teacher spent probably 60 minutes total dicking around with trying to get the form to show :rolleyes:
     
  2. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,923
    Likes Received:
    11
    Location:
    Los Angeles
  3. Joe_Cool

    Joe_Cool Never trust a woman or a government. Moderator

    Joined:
    Jun 30, 2003
    Messages:
    299,395
    Likes Received:
    581
    If you're in a basic c++ class and you're learning loops and control structures, you have no business fucking around with forms.

    And why would you argue to use VS2005 if you don't understand how to use it?
     
  4. skelm

    skelm New Member

    Joined:
    Jan 9, 2006
    Messages:
    868
    Likes Received:
    0
    Location:
    Australia
    Exactly...

    I personally think your full of it.. I don't think you're in a class and I think this was your weird ruse for help.
     
  5. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    You're better off making a Win32 console project instead of a Win32 GUI project. If you are in fact just learning, you don't need to confound the problem by adding in graphical objects.

    If you're still going to make a GUI, you're better off doing it in VB and calling your C++ code from inside your VB forms. The reason Microsoft introduced .NET in the first place, aside from competing with the Java Runtime, was to make it easier for advanced programmers (who had been writing C++ DLLs and calling them from within VB interfaces for years) to use whatever languages were best suited for each part of their projects. Too bad they fucked up VB in the process.
     
  6. Tk

    Tk Well-Known Member

    Joined:
    Dec 23, 2001
    Messages:
    23,086
    Likes Received:
    285
    Location:
    nw iowa
    omg wtf
     
  7. Tk

    Tk Well-Known Member

    Joined:
    Dec 23, 2001
    Messages:
    23,086
    Likes Received:
    285
    Location:
    nw iowa
    hows about just telling me how to do it.......
     
  8. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,923
    Likes Received:
    11
    Location:
    Los Angeles
    :bowdown:
     
  9. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    how about learning the basics before jumping into the deepend and fucking yourself over even worse?
     
  10. Joe_Cool

    Joe_Cool Never trust a woman or a government. Moderator

    Joined:
    Jun 30, 2003
    Messages:
    299,395
    Likes Received:
    581
    How to do it is the way your instructor has the rest of the class doing it. If you're just learning the basics of the language, you have no business in the form designer.
     
  11. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    The short answer about why we don't tell you is: some of us don't know and the rest of us are assholes. I'm not saying which group I'm in.

    The longer answer is that if you don't learn it from the ground up, it will take you much, much longer to understand why the complicated code works the way it does, if ever. You CAN skip the basics, yes, but it's better not to and I don't think there's anybody here who's learned programming the hard way who will disagree.
     
  12. Frequency

    Frequency New Member

    Joined:
    Dec 30, 2004
    Messages:
    7,504
    Likes Received:
    0
    Location:
    PA
    I'm going go out on a limb and say the teacher isn't the problem.
     
  13. Tk

    Tk Well-Known Member

    Joined:
    Dec 23, 2001
    Messages:
    23,086
    Likes Received:
    285
    Location:
    nw iowa
    thanks for giving me somewhat straight answers....... i understand the importance of learning 'from the ground up'. the teacher was the one who wanted us to use the form designer and code a windows application rather than a console app, which is what we've been doing the last two semesters. personally, i used to work with VB a lot and have worked with several other languages, so LOGICALLY, i understand what he wants us to do.

    since this thread is going nowhere, ill just keep looking for an answer on the web.

    thanks
     
  14. antiyou

    antiyou OT Supporter

    Joined:
    Jul 13, 2005
    Messages:
    25,295
    Likes Received:
    0
    Location:
    in ur base
    Code:
    //C++
    #using <mscorlib.dll>
    #using <System.dll>
    #using <System.Windows.Forms.dll>
    #using <System.Drawing.dll>
    
    using namespace System;
    using namespace System::Drawing;
    using namespace System::Windows::Forms;
    
    public __gc class Form1 : public System::Windows::Forms::Form {
    private:
       System::Windows::Forms::NotifyIcon*  notifyIcon1;
       System::Windows::Forms::ContextMenu*  contextMenu1;
       System::Windows::Forms::MenuItem*  menuItem1;
       System::ComponentModel::IContainer*  components;
    
    public:
       Form1() {
          this->components = new System::ComponentModel::Container();
          this->contextMenu1 = new System::Windows::Forms::ContextMenu();
          this->menuItem1 = new System::Windows::Forms::MenuItem();
    
          // Initialize contextMenu1
    
          System::Windows::Forms::MenuItem* temp0 [] = {this->menuItem1};
    
          this->contextMenu1->MenuItems->AddRange(temp0);
    
          // Initialize menuItem1
          this->menuItem1->Index = 0;
          this->menuItem1->Text = S"E&xit";
          this->menuItem1->Click += new System::EventHandler(this, &Form1::menuItem1_Click);
    
          // Set up how the form should be displayed.
          this->ClientSize =  System::Drawing::Size(292, 266);
          this->Text = S"Notify Icon Example";
    
          // Create the NotifyIcon.
          this->notifyIcon1 = new System::Windows::Forms::NotifyIcon(this->components);
    
          // The Icon property sets the icon that will appear
          // in the systray for this application.
          notifyIcon1->Icon = new System::Drawing::Icon(S"appicon.ico");
    
          // The ContextMenu property sets the menu that will
          // appear when the systray icon is right clicked.
          notifyIcon1->ContextMenu = this->contextMenu1;
    
          // The Text property sets the text that will be displayed,
          // in a tooltip, when the mouse hovers over the systray icon.
          notifyIcon1->Text = S"Form1 (NotifyIcon example)";
          notifyIcon1->Visible = true;
    
          // Handle the DoubleClick event to activate the form.
          notifyIcon1->DoubleClick += new System::EventHandler(this, &Form1::notifyIcon1_DoubleClick);
    
       }
    
    protected:
       void Dispose(bool disposing) {
          // Clean up any components being used.
          if (disposing)
             if (components != 0)
                components->Dispose();
    
          Form::Dispose(disposing);
       }
    
    private:
       void notifyIcon1_DoubleClick(Object* /*Sender*/, EventArgs* /*e*/) {
          // Show the form when the user double clicks on the notify icon.
    
          // Set the WindowState to normal if the form is minimized.
          if (this->WindowState == FormWindowState::Minimized)
             this->WindowState = FormWindowState::Normal;
    
          // Activate the form.
          this->Activate();
       }
    
       void menuItem1_Click(Object* /*Sender*/, EventArgs* /*e*/) {
          // Close the form, which closes the application.
          this->Close();
       }
    };
    
    if you need anymore help than that you will have to specify more clearly what you are asking
     
  15. uneek

    uneek OT Supporter

    Joined:
    Dec 14, 2003
    Messages:
    12,002
    Likes Received:
    0
    Form^ form1

    isn't that delphi?
     
  16. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    i know it was back when i did Delphi back in highschool :mamoru:
     
  17. MrMan

    MrMan New Member

    Joined:
    Jul 13, 2004
    Messages:
    308
    Likes Received:
    0
    The thing with VB was that, it was easier to make a user interface. With C++, it is much harder. That's the reason C# was invented... to have the power of C/C++ and rapid development of VB. So rapid development in Visual C++ is still not like VB.
     
  18. blang

    blang lang

    Joined:
    Jun 25, 2004
    Messages:
    1,956
    Likes Received:
    0
    Location:
    cambodia
    gui in c++ sucks.

    MFC FTL
     
  19. Runescaper

    Runescaper Guest

    How much easier does GUI development in C++ become with Visual C++.NET 2003 and newer? I know it allows you to create the forms visually like in VB but I've never really tried it myself. I probably wouldn't be able to do much with it anyway. Is it still a big pain?
     
  20. MrMan

    MrMan New Member

    Joined:
    Jul 13, 2004
    Messages:
    308
    Likes Received:
    0
    Well, if you use the C# language, Windows Forms is not much harder. It's like Java, in that it is based on events (listeners in Java). A user clicks on a button, fills in a form, etc... and it calls an event. That event is simply a call to your own function. You create the user interface using drag and drop, define what events it should have, write the functions for it. In this case, a programmer can worry more about coding, and not spend too much time building an interface.

    Not sure if Visual C++ .NET includes C#, I think it does. Visual Studio also supports C++ (managed, which runs under .NET, and unmanaged, which doesn't). But I believe C# and VB.NET are the two main languages for Windows Forms.
     
  21. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    GTK ftw.
     
  22. mace

    mace i don't read

    Joined:
    Jun 6, 2004
    Messages:
    12,567
    Likes Received:
    0
    Location:
    Texas
    MFC and the dialog editor are not included in VC 2005 Express.
     

Share This Page