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 8806375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:06:37+00:00 2026-06-14T02:06:37+00:00

I’m programming in C++ using Visual Studio 2010 using a Windows Form to create

  • 0

I’m programming in C++ using Visual Studio 2010 using a Windows Form to create stuff. Friggin’ hating it!

I want to use vector arrays, which I can do easily enough in a native C++ program but I can’t find any walk thru examples for use in a Form.

I’ve included cliext/vector in the main.cpp. If I try and include in the Form.h it tells me I can’t do it.
When I try and create a vector array variable it tells me I have a

syntax error missing ‘;’ before ‘<‘

All I want to do is create 6 arrays (int/float/2 Point/2 String^) that I can easily add data too then read it back later.

I just need an example of how to set it up.

[Edit]

Not sure how posting code that doesn’t work is going to help in getting a link to a working example but sure… I’ll go along with it.

Oh, if I add using namespace cliext; at the top of my .h file I’m told that cliext isn’t a class or namesapce.

The first load of errors are all about how the vector syntax is wrong…then I get a load of errors stemming from the variables being undefined later on.

#pragma once

 namespace Lab6_Draw_V1 {


using namespace System;
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
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
    Form1(void)
    {
        InitializeComponent();
        //
        //TODO: Add the constructor code here
        iPix=1;
        sColorLine="Black";
        sColor="Black";
        //
    }

protected:
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    ~Form1()
    {
        if (components)
        {
            delete components;
        }
    }
private: System::Windows::Forms::Panel^  panel1;
protected: 
private: System::Windows::Forms::ColorDialog^  colorDialog1;





private: System::Windows::Forms::Label^  colorBox1;
private: System::Windows::Forms::RadioButton^  BtnPix1;
private: System::Windows::Forms::RadioButton^  BtnPix3;
private: System::Windows::Forms::RadioButton^  BtnPix5;



private: System::Windows::Forms::ToolStrip^  toolStrip1;
private: System::Windows::Forms::ToolStripButton^  toolStripBtnLine;
private: System::Windows::Forms::ToolStripButton^  toolStripBtnSquare;
private: System::Windows::Forms::ToolStripButton^  toolStripBtnEllipse;





private: System::Windows::Forms::ToolStripButton^  toolStripBtnColor;
private: System::Windows::Forms::Label^  labelPos1;
private: System::Windows::Forms::Label^  labelPos2;






private:
    /// <summary>
    /// Required designer variable.
    Point firstPoint,finalPoint,iSize;
    bool Drawing,move;
    int iShape;
    float iPix;
    String^ sColor;
    String^ sColorLine;

    vector<int> vShape;
    vector<Point> vfirstPoint;
    vector<Point> vSize;
    vector<float> vPix;
    vector<String^>^ vfillColor;
    vector<String^>^ vlineColor;


private: System::Windows::Forms::RadioButton^  BtnPix7;
private: System::Windows::Forms::RadioButton^  BtnPix10;
private: System::Windows::Forms::RadioButton^  BtnPix15;

private: System::Windows::Forms::Panel^  panel2;
private: System::Windows::Forms::ToolStripButton^  toolStripBtnLineColor;
private: System::Windows::Forms::Label^  colorBox2;
private: System::Windows::Forms::Label^  label1;
private: System::Windows::Forms::Label^  label2;







    /// </summary>
    System::ComponentModel::Container ^components;

      #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)
    {
        System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
        this->panel1 = (gcnew System::Windows::Forms::Panel());
        this->colorDialog1 = (gcnew System::Windows::Forms::ColorDialog());
        this->colorBox1 = (gcnew System::Windows::Forms::Label());
        this->BtnPix1 = (gcnew System::Windows::Forms::RadioButton());
        this->BtnPix3 = (gcnew System::Windows::Forms::RadioButton());
        this->BtnPix5 = (gcnew System::Windows::Forms::RadioButton());
        this->toolStrip1 = (gcnew System::Windows::Forms::ToolStrip());
        this->toolStripBtnLine = (gcnew         System::Windows::Forms::ToolStripButton());
        this->toolStripBtnSquare = (gcnew System::Windows::Forms::ToolStripButton());
        this->toolStripBtnEllipse = (gcnew System::Windows::Forms::ToolStripButton());
        this->toolStripBtnColor = (gcnew System::Windows::Forms::ToolStripButton());
        this->toolStripBtnLineColor = (gcnew System::Windows::Forms::ToolStripButton());
        this->labelPos1 = (gcnew System::Windows::Forms::Label());
        this->labelPos2 = (gcnew System::Windows::Forms::Label());
        this->BtnPix7 = (gcnew System::Windows::Forms::RadioButton());
        this->BtnPix10 = (gcnew System::Windows::Forms::RadioButton());
        this->BtnPix15 = (gcnew System::Windows::Forms::RadioButton());
        this->panel2 = (gcnew System::Windows::Forms::Panel());
        this->colorBox2 = (gcnew System::Windows::Forms::Label());
        this->label1 = (gcnew System::Windows::Forms::Label());
        this->label2 = (gcnew System::Windows::Forms::Label());
        this->toolStrip1->SuspendLayout();
        this->SuspendLayout();
        // 
        // panel1
        // 
        this->panel1->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
        this->panel1->Location = System::Drawing::Point(160, 37);
        this->panel1->Name = L"panel1";
        this->panel1->Size = System::Drawing::Size(837, 447);
        this->panel1->TabIndex = 0;
        this->panel1->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::panel1_Paint);
        this->panel1->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::panel1_MouseDown);
        this->panel1->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::panel1_MouseMove);
        this->panel1->MouseUp += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::panel1_MouseUp);
        // 
        // colorBox1
        // 
        this->colorBox1->AutoSize = true;
        this->colorBox1->BackColor = System::Drawing::Color::White;
        this->colorBox1->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
        this->colorBox1->Location = System::Drawing::Point(16, 148);
        this->colorBox1->MinimumSize = System::Drawing::Size(37, 37);
        this->colorBox1->Name = L"colorBox1";
        this->colorBox1->Size = System::Drawing::Size(37, 37);
        this->colorBox1->TabIndex = 6;
        this->colorBox1->BackColorChanged += gcnew System::EventHandler(this, &Form1::colorBox1_BackColorChanged);
        // 
        // BtnPix1
        // 
        this->BtnPix1->AutoSize = true;
        this->BtnPix1->Checked = true;
        this->BtnPix1->Location = System::Drawing::Point(83, 213);
        this->BtnPix1->Name = L"BtnPix1";
        this->BtnPix1->Size = System::Drawing::Size(56, 17);
        this->BtnPix1->TabIndex = 7;
        this->BtnPix1->TabStop = true;
        this->BtnPix1->Text = L"1 Pixel";
        this->BtnPix1->UseVisualStyleBackColor = true;
        this->BtnPix1->CheckedChanged += gcnew System::EventHandler(this, &Form1::BtnPix1_CheckedChanged);
        // 
        // BtnPix3
        // 
        this->BtnPix3->AutoSize = true;
        this->BtnPix3->Location = System::Drawing::Point(83, 236);
        this->BtnPix3->Name = L"BtnPix3";
        this->BtnPix3->Size = System::Drawing::Size(56, 17);
        this->BtnPix3->TabIndex = 8;
        this->BtnPix3->Text = L"3 Pixel";
        this->BtnPix3->UseVisualStyleBackColor = true;
        this->BtnPix3->CheckedChanged += gcnew System::EventHandler(this, &Form1::BtnPix3_CheckedChanged);
        // 
        // BtnPix5
        // 
        this->BtnPix5->AutoSize = true;
        this->BtnPix5->Location = System::Drawing::Point(83, 259);
        this->BtnPix5->Name = L"BtnPix5";
        this->BtnPix5->Size = System::Drawing::Size(56, 17);
        this->BtnPix5->TabIndex = 9;
        this->BtnPix5->Text = L"5 Pixel";
        this->BtnPix5->UseVisualStyleBackColor = true;
        this->BtnPix5->CheckedChanged += gcnew System::EventHandler(this, &Form1::BtnPix5_CheckedChanged);
        // 
        // toolStrip1
        // 
        this->toolStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(5) {this->toolStripBtnLine, 
            this->toolStripBtnSquare, this->toolStripBtnEllipse, this->toolStripBtnColor, this->toolStripBtnLineColor});
        this->toolStrip1->Location = System::Drawing::Point(0, 0);
        this->toolStrip1->Name = L"toolStrip1";
        this->toolStrip1->Size = System::Drawing::Size(1016, 25);
        this->toolStrip1->TabIndex = 10;
        this->toolStrip1->Text = L"toolStrip1";
        this->toolStrip1->ItemClicked += gcnew System::Windows::Forms::ToolStripItemClickedEventHandler(this, &Form1::toolStrip1_ItemClicked);
        // 
        // toolStripBtnLine
        // 
        this->toolStripBtnLine->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Text;
        this->toolStripBtnLine->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripBtnLine.Image")));
        this->toolStripBtnLine->ImageTransparentColor = System::Drawing::Color::Magenta;
        this->toolStripBtnLine->Name = L"toolStripBtnLine";
        this->toolStripBtnLine->Size = System::Drawing::Size(33, 22);
        this->toolStripBtnLine->Text = L"Line";
        this->toolStripBtnLine->Click += gcnew System::EventHandler(this, &Form1::toolStripBtnLine_Click);
        // 
        // toolStripBtnSquare
        // 
        this->toolStripBtnSquare->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Text;
        this->toolStripBtnSquare->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripBtnSquare.Image")));
        this->toolStripBtnSquare->ImageTransparentColor = System::Drawing::Color::Magenta;
        this->toolStripBtnSquare->Name = L"toolStripBtnSquare";
        this->toolStripBtnSquare->Size = System::Drawing::Size(47, 22);
        this->toolStripBtnSquare->Text = L"Square";
        this->toolStripBtnSquare->Click += gcnew System::EventHandler(this, &Form1::toolStripBtnSquare_Click);
        // 
        // toolStripBtnEllipse
        // 
        this->toolStripBtnEllipse->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Text;
        this->toolStripBtnEllipse->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripBtnEllipse.Image")));
        this->toolStripBtnEllipse->ImageTransparentColor = System::Drawing::Color::Magenta;
        this->toolStripBtnEllipse->Name = L"toolStripBtnEllipse";
        this->toolStripBtnEllipse->Size = System::Drawing::Size(44, 22);
        this->toolStripBtnEllipse->Text = L"Ellipse";
        this->toolStripBtnEllipse->Click += gcnew System::EventHandler(this, &Form1::toolStripBtnEllipse_Click);
        // 
        // toolStripBtnColor
        // 
        this->toolStripBtnColor->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Text;
        this->toolStripBtnColor->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripBtnColor.Image")));
        this->toolStripBtnColor->ImageTransparentColor = System::Drawing::Color::Magenta;
        this->toolStripBtnColor->Name = L"toolStripBtnColor";
        this->toolStripBtnColor->Size = System::Drawing::Size(58, 22);
        this->toolStripBtnColor->Text = L"Fill Color";
        this->toolStripBtnColor->Click += gcnew System::EventHandler(this, &Form1::toolStripBtnColor_Click);
        // 
        // toolStripBtnLineColor
        // 
        this->toolStripBtnLineColor->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Text;
        this->toolStripBtnLineColor->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripBtnLineColor.Image")));
        this->toolStripBtnLineColor->ImageTransparentColor = System::Drawing::Color::Magenta;
        this->toolStripBtnLineColor->Name = L"toolStripBtnLineColor";
        this->toolStripBtnLineColor->Size = System::Drawing::Size(65, 22);
        this->toolStripBtnLineColor->Text = L"Line Color";
        this->toolStripBtnLineColor->Click += gcnew System::EventHandler(this, &Form1::toolStripBtnLineColor_Click);
        // 
        // labelPos1
        // 
        this->labelPos1->AutoSize = true;
        this->labelPos1->Location = System::Drawing::Point(712, 504);
        this->labelPos1->Name = L"labelPos1";
        this->labelPos1->Size = System::Drawing::Size(35, 13);
        this->labelPos1->TabIndex = 11;
        this->labelPos1->Text = L"label1";
        // 
        // labelPos2
        // 
        this->labelPos2->AutoSize = true;
        this->labelPos2->Location = System::Drawing::Point(848, 504);
        this->labelPos2->Name = L"labelPos2";
        this->labelPos2->Size = System::Drawing::Size(35, 13);
        this->labelPos2->TabIndex = 12;
        this->labelPos2->Text = L"label2";
        // 
        // BtnPix7
        // 
        this->BtnPix7->AutoSize = true;
        this->BtnPix7->Location = System::Drawing::Point(83, 282);
        this->BtnPix7->Name = L"BtnPix7";
        this->BtnPix7->Size = System::Drawing::Size(56, 17);
        this->BtnPix7->TabIndex = 13;
        this->BtnPix7->Text = L"7 Pixel";
        this->BtnPix7->UseVisualStyleBackColor = true;
        this->BtnPix7->CheckedChanged += gcnew System::EventHandler(this, &Form1::BtnPix7_CheckedChanged);
        // 
        // BtnPix10
        // 
        this->BtnPix10->AutoSize = true;
        this->BtnPix10->Location = System::Drawing::Point(83, 306);
        this->BtnPix10->Name = L"BtnPix10";
        this->BtnPix10->Size = System::Drawing::Size(62, 17);
        this->BtnPix10->TabIndex = 14;
        this->BtnPix10->Text = L"10 Pixel";
        this->BtnPix10->UseVisualStyleBackColor = true;
        this->BtnPix10->CheckedChanged += gcnew System::EventHandler(this, &Form1::BtnPix10_CheckedChanged);
        // 
        // BtnPix15
        // 
        this->BtnPix15->AutoSize = true;
        this->BtnPix15->Location = System::Drawing::Point(83, 329);
        this->BtnPix15->Name = L"BtnPix15";
        this->BtnPix15->Size = System::Drawing::Size(62, 17);
        this->BtnPix15->TabIndex = 15;
        this->BtnPix15->Text = L"15 Pixel";
        this->BtnPix15->UseVisualStyleBackColor = true;
        this->BtnPix15->CheckedChanged += gcnew System::EventHandler(this, &Form1::BtnPix15_CheckedChanged);
        // 
        // panel2
        // 
        this->panel2->BackColor = System::Drawing::Color::White;
        this->panel2->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
        this->panel2->Location = System::Drawing::Point(83, 148);
        this->panel2->Name = L"panel2";
        this->panel2->Size = System::Drawing::Size(37, 37);
        this->panel2->TabIndex = 17;
        // 
        // colorBox2
        // 
        this->colorBox2->AutoSize = true;
        this->colorBox2->BackColor = System::Drawing::Color::Black;
        this->colorBox2->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
        this->colorBox2->Location = System::Drawing::Point(16, 213);
        this->colorBox2->MinimumSize = System::Drawing::Size(37, 37);
        this->colorBox2->Name = L"colorBox2";
        this->colorBox2->Size = System::Drawing::Size(37, 37);
        this->colorBox2->TabIndex = 18;
        this->colorBox2->BackColorChanged += gcnew System::EventHandler(this, &Form1::colorBox2_BackColorChanged);
        // 
        // label1
        // 
        this->label1->AutoSize = true;
        this->label1->Location = System::Drawing::Point(8, 250);
        this->label1->Name = L"label1";
        this->label1->Size = System::Drawing::Size(54, 13);
        this->label1->TabIndex = 19;
        this->label1->Text = L"Line Color";
        // 
        // label2
        // 
        this->label2->AutoSize = true;
        this->label2->Location = System::Drawing::Point(12, 185);
        this->label2->Name = L"label2";
        this->label2->Size = System::Drawing::Size(46, 13);
        this->label2->TabIndex = 20;
        this->label2->Text = L"Fill Color";
        // 
        // Form1
        // 
        this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
        this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
        this->BackColor = System::Drawing::SystemColors::Control;
        this->ClientSize = System::Drawing::Size(1016, 538);
        this->Controls->Add(this->label2);
        this->Controls->Add(this->label1);
        this->Controls->Add(this->colorBox2);
        this->Controls->Add(this->panel2);
        this->Controls->Add(this->BtnPix15);
        this->Controls->Add(this->BtnPix10);
        this->Controls->Add(this->BtnPix7);
        this->Controls->Add(this->labelPos2);
        this->Controls->Add(this->labelPos1);
        this->Controls->Add(this->toolStrip1);
        this->Controls->Add(this->BtnPix5);
        this->Controls->Add(this->BtnPix3);
        this->Controls->Add(this->BtnPix1);
        this->Controls->Add(this->colorBox1);
        this->Controls->Add(this->panel1);
        this->Icon = (cli::safe_cast<System::Drawing::Icon^  >(resources->GetObject(L"$this.Icon")));
        this->MinimumSize = System::Drawing::Size(1024, 530);
        this->Name = L"Form1";
        this->Text = L"Lab 6 Paint";
        this->toolStrip1->ResumeLayout(false);
        this->toolStrip1->PerformLayout();
        this->ResumeLayout(false);
        this->PerformLayout();

    }
    #pragma endregion
private: System::Void btnColor_Click(System::Object^  sender, System::EventArgs^  e) {

         }
    private: System::Void panel1_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {

         //  Loop with case statements for the shapes and colours
         // grab data from vector array




     }
    private: System::Void toolStripBtnColor_Click(System::Object^  sender, System::EventArgs^  e) {
        ColorDialog^ MyDialog = gcnew ColorDialog;
  // Keeps the user from selecting a custom color.
  MyDialog->AllowFullOpen = false;
  // Allows the user to get help. (The default is false.)
  MyDialog->ShowHelp = true;
  // Sets the initial color select to the current text color.
  MyDialog->Color = panel1->ForeColor;

  // Update the text box color if the user clicks OK  
  if ( MyDialog->ShowDialog() == ::System::Windows::Forms::DialogResult::OK )
         {
            colorBox1->BackColor= MyDialog->Color;
            sColor = Convert::ToString(colorBox1->BackColor);
        //  labelColor->Text=sColor;
         }
     }
     private: System::Void panel1_MouseDown(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) {
        if( e->Button== System::Windows::Forms::MouseButtons::Left)
            {
             Drawing = true;
             firstPoint = e->Location;
             labelPos1->Text = Convert::ToString(e->Location);
             // set shape flag
            } 
        if( e->Button== System::Windows::Forms::MouseButtons::Right)
            {
            move=true;
            iSize.X=finalPoint.X-firstPoint.X;
            iSize.Y=finalPoint.Y-firstPoint.Y;
            } 

        }
     private: System::Void toolStrip1_ItemClicked(System::Object^  sender, System::Windows::Forms::ToolStripItemClickedEventArgs^  e) {
              }

          private: System::Void panel1_MouseMove(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
     {

// tempPos=e->Location;
labelPos2->Text = Convert::ToString(e->Location);

         if(Drawing)
         {
             //draw temp outline with no fill and black outline
              panel1->Refresh();
             auto g = panel1->CreateGraphics();

             switch(iShape)
             {
             case 1:
                 g->DrawLine(Pens::Black,firstPoint,e->Location);
                 break;
             case 2:
                 g->DrawRectangle(Pens::Black,firstPoint.X,firstPoint.Y,(e->Location.X-firstPoint.X),(e->Location.Y-firstPoint.Y));
                 break;
             case 3:
                 g->DrawEllipse(Pens::Black,firstPoint.X,firstPoint.Y,(e->Location.X-firstPoint.X),(e->Location.Y-firstPoint.Y));
             default:break;

             }


         }
         if(move)
         {
             //code
             panel1->Refresh();
             auto g = panel1->CreateGraphics();
             firstPoint=e->Location;
             SolidBrush^ myBrush = gcnew SolidBrush(Color::FromArgb(colorBox1->BackColor.A,colorBox1->BackColor.R,colorBox1->BackColor.G,colorBox1->BackColor.B) );
             Pen^ myPen = gcnew Pen(Color::FromArgb(colorBox2->BackColor.A,colorBox2->BackColor.R,colorBox2->BackColor.G,colorBox2->BackColor.B) );
             myPen->Width = iPix;

             switch(iShape)
             {
             case 1:
                 finalPoint.X=iSize.X+firstPoint.X;
                 finalPoint.Y=iSize.Y+firstPoint.Y;
                 g->DrawLine(myPen,firstPoint,finalPoint);
                 break;
             case 2:
                 g->FillRectangle(myBrush,firstPoint.X,firstPoint.Y,iSize.X,iSize.Y);
                 g->DrawRectangle(myPen,firstPoint.X,firstPoint.Y,iSize.X,iSize.Y);
                 break;
             case 3:
                 g->FillEllipse(myBrush,firstPoint.X,firstPoint.Y,iSize.X,iSize.Y);
                 g->DrawEllipse(myPen,firstPoint.X,firstPoint.Y,iSize.X,iSize.Y);
                 break;
             default:break;
            }
         }

     }
          private: System::Void panel1_MouseUp(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
     {
         if( e->Button== System::Windows::Forms::MouseButtons::Left)
            {
             finalPoint = e->Location;
             labelPos2->Text = Convert::ToString(e->Location);
             // draw filled shape

             panel1->Refresh();
             auto g = panel1->CreateGraphics();
             SolidBrush^ myBrush = gcnew SolidBrush(Color::FromArgb(colorBox1->BackColor.A,colorBox1->BackColor.R,colorBox1->BackColor.G,colorBox1->BackColor.B) );
             Pen^ myPen = gcnew Pen(Color::FromArgb(colorBox2->BackColor.A,colorBox2->BackColor.R,colorBox2->BackColor.G,colorBox2->BackColor.B) );
             myPen->Width = iPix;

             switch(iShape)
             {
             case 1:
                 g->DrawLine(myPen,firstPoint,finalPoint);
                 break;
             case 2:
                 g->FillRectangle(myBrush,firstPoint.X,firstPoint.Y,(e->Location.X-firstPoint.X),(e->Location.Y-firstPoint.Y));
                 g->DrawRectangle(myPen,firstPoint.X,firstPoint.Y,(e->Location.X-firstPoint.X),(e->Location.Y-firstPoint.Y));
                 break;
             case 3:
                 g->FillEllipse(myBrush,firstPoint.X,firstPoint.Y,(e->Location.X-firstPoint.X),(e->Location.Y-firstPoint.Y));
                 g->DrawEllipse(myPen,firstPoint.X,firstPoint.Y,(e->Location.X-firstPoint.X),(e->Location.Y-firstPoint.Y));
                 break;
             default:break;

             }
             iSize.X=finalPoint.X-firstPoint.X;
             iSzie.Y=finalPoint.Y-firstPoint.Y;

             vShape.push_back (iShape);
             vfirstPoint.push_back (firstPoint);
             vSize.push_back (iSize);
             vfillColor.push_back (myBrush);
             vlineColor.push_back (myPen);
             vPix.push_back (iPix);

             Drawing=false;
            }
         else move=false;
     }
          private: System::Void toolStripBtnLine_Click(System::Object^  sender, System::EventArgs^  e) {
         iShape=1;
     }
          private: System::Void toolStripBtnSquare_Click(System::Object^  sender, System::EventArgs^  e) {
         iShape=2;

     }
         private: System::Void toolStripBtnEllipse_Click(System::Object^  sender, System::EventArgs^  e) {
         iShape=3;
     }
         private: System::Void BtnPix1_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
         iPix=1;
         panel2->Refresh();
         auto g = panel2->CreateGraphics();
         Pen^ myPen = gcnew Pen(Color::FromArgb(colorBox2->BackColor.A,colorBox2->BackColor.R,colorBox2->BackColor.G,colorBox2->BackColor.B) );
         myPen->Width = iPix;
         g->DrawLine(myPen,2,18,33,18);
     }
           private: System::Void BtnPix3_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
         iPix=3;
         panel2->Refresh();
         auto g = panel2->CreateGraphics();
         Pen^ myPen = gcnew Pen(Color::FromArgb(colorBox2->BackColor.A,colorBox2->BackColor.R,colorBox2->BackColor.G,colorBox2->BackColor.B) );
         myPen->Width = iPix;
         g->DrawLine(myPen,2,18,33,18);
     }
          private: System::Void BtnPix5_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
         iPix=5;
         panel2->Refresh();
         auto g = panel2->CreateGraphics();
         Pen^ myPen = gcnew Pen(Color::FromArgb(colorBox2->BackColor.A,colorBox2->BackColor.R,colorBox2->BackColor.G,colorBox2->BackColor.B) );
         myPen->Width = iPix;
         g->DrawLine(myPen,2,18,33,18);
     }
         private: System::Void BtnPix7_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
         iPix=7;
         panel2->Refresh();
         auto g = panel2->CreateGraphics();
         Pen^ myPen = gcnew Pen(Color::FromArgb(colorBox2->BackColor.A,colorBox2->BackColor.R,colorBox2->BackColor.G,colorBox2->BackColor.B) );
         myPen->Width = iPix;
         g->DrawLine(myPen,2,18,33,18);
     }
           private: System::Void BtnPix10_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
         iPix=10;
         panel2->Refresh();
         auto g = panel2->CreateGraphics();
         Pen^ myPen = gcnew Pen(Color::FromArgb(colorBox2->BackColor.A,colorBox2->BackColor.R,colorBox2->BackColor.G,colorBox2->BackColor.B) );
         myPen->Width = iPix;
         g->DrawLine(myPen,2,18,33,18);
     }
            private: System::Void BtnPix15_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
         iPix=15;
         panel2->Refresh();
         auto g = panel2->CreateGraphics();
         Pen^ myPen = gcnew Pen(Color::FromArgb(colorBox2->BackColor.A,colorBox2->BackColor.R,colorBox2->BackColor.G,colorBox2->BackColor.B) );
         myPen->Width = iPix;
         g->DrawLine(myPen,2,18,33,18);
     }
            private: System::Void toolStripBtnLineColor_Click(System::Object^  sender, System::EventArgs^  e) {
    ColorDialog^ MyDialog = gcnew ColorDialog;
    // Keeps the user from selecting a custom color.
    MyDialog->AllowFullOpen = false;
    // Allows the user to get help. (The default is false.)
    MyDialog->ShowHelp = true;
    // Sets the initial color select to the current text color.
    MyDialog->Color = colorBox2->BackColor;

  // Update the text box color if the user clicks OK  
  if ( MyDialog->ShowDialog() == ::System::Windows::Forms::DialogResult::OK )
         {
            sColorLine = Convert::ToString(MyDialog->Color);
        //  labelColorLine->Text=sColorLine;
            colorBox2->BackColor= MyDialog->Color;
         }
     }
           private: System::Void colorBox1_BackColorChanged(System::Object^  sender, System::EventArgs^  e) {
          panel1->Refresh();
             auto g = panel1->CreateGraphics();
             SolidBrush^ myBrush = gcnew SolidBrush(Color::FromArgb(colorBox1->BackColor.A,colorBox1->BackColor.R,colorBox1->BackColor.G,colorBox1->BackColor.B) );
             Pen^ myPen = gcnew Pen(Color::FromArgb(colorBox2->BackColor.A,colorBox2->BackColor.R,colorBox2->BackColor.G,colorBox2->BackColor.B) );
             myPen->Width = iPix;

             switch(iShape)
             {
             case 1:
                 g->DrawLine(myPen,firstPoint,finalPoint);
                 break;
             case 2:
                 g->FillRectangle(myBrush,firstPoint.X,firstPoint.Y,(finalPoint.X-firstPoint.X),(finalPoint.Y-firstPoint.Y));
                 g->DrawRectangle(myPen,firstPoint.X,firstPoint.Y,(finalPoint.X-firstPoint.X),(finalPoint.Y-firstPoint.Y));
                 break;
             case 3:
                 g->FillEllipse(myBrush,firstPoint.X,firstPoint.Y,(finalPoint.X-firstPoint.X),(finalPoint.Y-firstPoint.Y));
                 g->DrawEllipse(myPen,firstPoint.X,firstPoint.Y,(finalPoint.X-firstPoint.X),(finalPoint.Y-firstPoint.Y));
                 break;
             default:break;
            } 
     }
           private: System::Void colorBox2_BackColorChanged(System::Object^  sender, System::EventArgs^  e) {
             panel1->Refresh();
             auto g = panel1->CreateGraphics();
             SolidBrush^ myBrush = gcnew SolidBrush(Color::FromArgb(colorBox1->BackColor.A,colorBox1->BackColor.R,colorBox1->BackColor.G,colorBox1->BackColor.B) );
             Pen^ myPen = gcnew Pen(Color::FromArgb(colorBox2->BackColor.A,colorBox2->BackColor.R,colorBox2->BackColor.G,colorBox2->BackColor.B) );
             myPen->Width = iPix;

             switch(iShape)
             {
             case 1:
                 g->DrawLine(myPen,firstPoint,finalPoint);
                 break;
             case 2:
                 g->FillRectangle(myBrush,firstPoint.X,firstPoint.Y,(finalPoint.X-firstPoint.X),(finalPoint.Y-firstPoint.Y));
                 g->DrawRectangle(myPen,firstPoint.X,firstPoint.Y,(finalPoint.X-firstPoint.X),(finalPoint.Y-firstPoint.Y));
                 break;
             case 3:
                 g->FillEllipse(myBrush,firstPoint.X,firstPoint.Y,(finalPoint.X-firstPoint.X),(finalPoint.Y-firstPoint.Y));
                 g->DrawEllipse(myPen,firstPoint.X,firstPoint.Y,(finalPoint.X-firstPoint.X),(finalPoint.Y-firstPoint.Y));
                 break;
             default:break;
            } 
     }

};
}

  • 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-06-14T02:06:38+00:00Added an answer on June 14, 2026 at 2:06 am

    If you’re not fixated on having a function called push_back, but are ok with Add, you can use the .NET-provided collections to store .NET data in.

    using namespace System::Collections::Generic;
    
    List<int> vShape;
    List<Point> vfirstPoint;
    List<Point> vSize;
    List<float> vPix;
    List<String^> vfillColor;
    List<String^> vlineColor;
    

    System::Collections::Generic::List<T> is analogous to std::vector. System::Collections::Generic::LinkedList<T> to std::list, and System::Collections::Generic::Dictionary<TKey, TValue> to std::unordered_map.

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

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I am trying to understand how to use SyndicationItem to display feed which is
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.