Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6595561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:57:21+00:00 2026-05-25T17:57:21+00:00

I am taking a class in C++ and have been given my first project.

  • 0

I am taking a class in C++ and have been given my first project. In class, the professor just talks about syntax, grammar, etc. He never talks about how to use Visual Studio. He emailed us a header file with no explanation whatsoever and expects us to use it for the project. I am not too sure how to get started with this file. I tried creating an empty Visual C++ project, adding this file and running it but for one, there are red underline error everywhere and two, VS says it can’t find the executable. If anybody can help me get VS and/or my project set up, I can take care of making the program (just got done writing the same exact program in Java).

This is the header file he sent us. Judging by the looks of it, he’s kinda sloppy.

#pragma once

namespace control2 {

    using namespace System;
    using namespace System::IO; // added by Zhang
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;

    /// <summary>
    /// Summary for Form1
    ///
    /// WARNING: If you change the name of this class, you will need to change the
    ///          'Resource File Name' property for the managed resource compiler tool
    ///          associated with all .resx files this class depends on.  Otherwise,
    ///          the designers will not be able to interact properly with localized
    ///          resources associated with this form.
    /// </summary>
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
        Form1(void)
        {
            InitializeComponent();
            //
            //TODO: Add the constructor code here
            //
            // added by Zhang
            StreamReader ^sr = gcnew StreamReader("control.txt");
            this->choice=Int32::Parse(sr->ReadLine());
            sr->Close();

        }

    protected:
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        ~Form1()
        {
            if (components)
            {
                delete components;
            }
        }

    private:
        /// <summary>
        /// Required designer variable.
        /// </summary>
        System::ComponentModel::Container ^components;

        int choice;

#pragma region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        void InitializeComponent(void)
        {
            this->SuspendLayout();
            // 
            // Form1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(292, 266);
            this->Name = L"Form1";
            this->Text = L"CS351";
            this->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::Form1_Paint);
            this->ResumeLayout(false);

        }
#pragma endregion
    private: System::Void Form1_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {
              Graphics ^g = e->Graphics;
              // g->Clear(BackColor);
              // g->Clear(Color::Red);
              for ( int y = 0; y < 10; y++ ) {
                 // pick the shape based on the user's choice
                 switch ( choice )
                 {
                    case 1: // draw rectangles
                        g->DrawRectangle(Pens::Black, 10 + i * 10, 10 + i * 10, 50 + i * 10, 50 + i * 10 );
                       break;
                    case 2: // draw ovals
                       // g->DrawEllipse(Pens::Black, 10 + i * 10, 10 + i * 10, 50 + i * 10, 50 + i * 10 );
                       g->DrawArc(Pens::Black, 10 + i * 10, 10 + i * 10, 50 + i * 10, 50 + i * 10, 0, 360 );
                       break;
                    case 3: // fill rectangles
                        g->FillRectangle(Brushes::Red, 10 + i * 10, 10 + i * 10, 50 + i * 10, 50 + i * 10 );
                       break;
                    case 4: // fill ovals
                       // g->FillEllipse(gcnew SolidBrush(Color::Red), 10 + i * 10, 10 + i * 10, 50 + i * 10, 50 + i * 10 );
                       g->FillPie(gcnew SolidBrush(Color::Red), 10 + i * 10, 10 + i * 10, 50 + i * 10, 50 + i * 10, 0, 360 );
                       break;
                    default: // draw lines
                        g->DrawLine(Pens::Black, 10 + i * 10, 60 + i * 20, 60 + i * 20, 10 + i * 10 );
                       break;
                 } // end switch
              } // end for

              choice=(choice+1)%5;
             }
    };
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:57:21+00:00Added an answer on May 25, 2026 at 5:57 pm

    Ughh…pragma…Anyway…

    If you open up VS, and go to file, you’ll find the new project option. I’m assuming this is a Windows Forms App. So, select new project, under languages select C++, and then Windows Form App. When that’s all set, go to file->save all and place it in a directory. Now take the file your professor gave you and put it with the rest of the code files in that directory. Back to your project, under the solution explorer, right click header files, add, add existing, and select your header. That should be enough to get you started!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the data structures class that I am currently taking, we have been tasked
I'm taking an operating systems design class in which they have given us a
I just started taking a class on C# .NET and have found it really
I've been given some starter code for a project I have to complete in
I am new to web development and I have been taking a class through
I have some C# class libraries, that were designed without taking into account things
I am taking a class in C++ programming and the professor told us that
I'm currently taking a math class in College called Scientific Computing and the professor
I am just learning how to use classes in my projects. I have been
Background: I am taking a class at my university called "Software Constraints". In the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.