Jump to content
  • Advertisement
Sign in to follow this  
Xpyder

GDI+ in Visual C++.Net 2005

This topic is 4859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey - i am trying to use the mouse to draw rectangles in VC++.net 2005, but it doesnt work - i need to do it in this picture box. It comes up with an error in run time saying that object is not referenced or something like that - can someone just run over it and find a solution?

#pragma once
int NumImagesOpen = 0;

	int StartX;
	int StartY;

	int FinishX;
	int FinishY;
	System::Drawing::Rectangle CurrRect;
#using <mscorlib.dll>
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>




namespace MAGSoftImageSlicer
{
	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
	using namespace System::Drawing::Drawing2D;

	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:


		Form1(void)
		{
			InitializeComponent();

		}

	protected:
	
		virtual void Dispose(Boolean disposing) override
		{
			if (disposing && components)
			{
				delete components;
			}
			__super::Dispose(disposing);
		}

	private: System::Drawing::Pen^ MyPen;
	private: System::Windows::Forms::MenuStrip^  MainMenu;
	private: System::Windows::Forms::ToolStripMenuItem^  MainMenu_File;
	private: System::Windows::Forms::ToolStripMenuItem^  MainMenu_Edit;
	private: System::Windows::Forms::ToolStripMenuItem^  MainMenu_View;
	private: System::Windows::Forms::ToolStripMenuItem^  MainMenu_Help;
	private: System::Windows::Forms::ToolStripMenuItem^  MainMenu_File_Open;
	private: System::Windows::Forms::ToolStripMenuItem^  MainMenu_File_Export;
	private: System::Windows::Forms::ToolStripMenuItem^  MainMenu_File_Exit;
	private: System::Windows::Forms::ToolStripMenuItem^  MainMenu_Edit_Box;
	private: System::Windows::Forms::ToolStripMenuItem^  MainMenu_Edit_Sprite;
	private: System::Windows::Forms::ToolStripMenuItem^  MainMenu_View_FullScreen;
	private: System::Windows::Forms::ToolStripMenuItem^  MainMenu_View_Contents;
	private: System::Windows::Forms::ToolStripMenuItem^  MainMenu_Help_About;
	private: System::Windows::Forms::ToolStrip^  ToolBar_Top;



	private: System::Windows::Forms::StatusStrip^  StatusStrip;
	private: System::Windows::Forms::ToolStripStatusLabel^  StatusBar;

	private: System::Windows::Forms::SplitContainer^  MainSplit;

	private: System::Windows::Forms::GroupBox^  Box_Options;
	private: System::Windows::Forms::Button^  Options_Bound;
	private: System::Windows::Forms::Button^  Options_Create;
	private: System::Windows::Forms::GroupBox^  groupBox1;
	private: System::Windows::Forms::Button^  View_Full;
	private: System::Windows::Forms::Label^  NameLabel;

	private: System::Windows::Forms::Panel^  panel1;
	private: System::Windows::Forms::HScrollBar^  hScrollBar1;
	private: System::Windows::Forms::TextBox^  SpriteName_Input;
	private: System::Windows::Forms::GroupBox^  Box_Export;
	private: System::Windows::Forms::Button^  Export_All;
	private: System::Windows::Forms::Button^  Export_Selected;

	private: System::Windows::Forms::OpenFileDialog^  openFileDialog1;
	private: System::Windows::Forms::SaveFileDialog^  saveFileDialog1;

	private: System::Drawing::Graphics^ GraphicsObj;
	private: System::Windows::Forms::ToolStripPanel^  BottomToolStripPanel;
	private: System::Windows::Forms::ToolStripPanel^  TopToolStripPanel;
	private: System::Windows::Forms::ToolStripPanel^  RightToolStripPanel;
	private: System::Windows::Forms::ToolStripPanel^  LeftToolStripPanel;
	private: System::Windows::Forms::ToolStripContentPanel^  ContentPanel;
	private: System::Windows::Forms::ToolStripButton^  newToolStripButton1;
	private: System::Windows::Forms::ToolStripButton^  openToolStripButton1;
	private: System::Windows::Forms::ToolStripButton^  saveToolStripButton1;
	private: System::Windows::Forms::ToolStripButton^  printToolStripButton1;
	private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator2;
	private: System::Windows::Forms::ToolStripButton^  cutToolStripButton1;
	private: System::Windows::Forms::ToolStripButton^  copyToolStripButton1;
	private: System::Windows::Forms::ToolStripButton^  pasteToolStripButton1;
	private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator3;
	private: System::Windows::Forms::ToolStripButton^  helpToolStripButton1;
	private: System::Windows::Forms::TabControl^  tabControl1;
	private: System::Windows::Forms::TabPage^  tabPage1;
	private: System::Windows::Forms::PictureBox^  pictureBox1;
	private: System::Windows::Forms::HScrollBar^  hScrollBar2;
	private: System::Windows::Forms::VScrollBar^  vScrollBar1;
	private: System::Windows::Forms::ToolStripStatusLabel^  MouseX;
	private: System::Windows::Forms::ToolStripStatusLabel^  toolStripStatusLabel1;

	protected: 

	private:
		/// <summary>
		/// Required designer variable.
		/// </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->MainMenu = (gcnew System::Windows::Forms::MenuStrip());
			this->MainMenu_File = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->MainMenu_File_Open = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->MainMenu_File_Export = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->MainMenu_File_Exit = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->MainMenu_Edit = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->MainMenu_Edit_Box = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->MainMenu_Edit_Sprite = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->MainMenu_View = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->MainMenu_View_FullScreen = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->MainMenu_Help = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->MainMenu_View_Contents = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->MainMenu_Help_About = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->ToolBar_Top = (gcnew System::Windows::Forms::ToolStrip());
			this->newToolStripButton1 = (gcnew System::Windows::Forms::ToolStripButton());
			this->openToolStripButton1 = (gcnew System::Windows::Forms::ToolStripButton());
			this->saveToolStripButton1 = (gcnew System::Windows::Forms::ToolStripButton());
			this->printToolStripButton1 = (gcnew System::Windows::Forms::ToolStripButton());
			this->toolStripSeparator2 = (gcnew System::Windows::Forms::ToolStripSeparator());
			this->cutToolStripButton1 = (gcnew System::Windows::Forms::ToolStripButton());
			this->copyToolStripButton1 = (gcnew System::Windows::Forms::ToolStripButton());
			this->pasteToolStripButton1 = (gcnew System::Windows::Forms::ToolStripButton());
			this->toolStripSeparator3 = (gcnew System::Windows::Forms::ToolStripSeparator());
			this->helpToolStripButton1 = (gcnew System::Windows::Forms::ToolStripButton());
			this->StatusStrip = (gcnew System::Windows::Forms::StatusStrip());
			this->StatusBar = (gcnew System::Windows::Forms::ToolStripStatusLabel());
			this->toolStripStatusLabel1 = (gcnew System::Windows::Forms::ToolStripStatusLabel());
			this->MouseX = (gcnew System::Windows::Forms::ToolStripStatusLabel());
			this->MainSplit = (gcnew System::Windows::Forms::SplitContainer());
			this->Box_Export = (gcnew System::Windows::Forms::GroupBox());
			this->Export_Selected = (gcnew System::Windows::Forms::Button());
			this->Export_All = (gcnew System::Windows::Forms::Button());
			this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
			this->SpriteName_Input = (gcnew System::Windows::Forms::TextBox());
			this->NameLabel = (gcnew System::Windows::Forms::Label());
			this->panel1 = (gcnew System::Windows::Forms::Panel());
			this->hScrollBar1 = (gcnew System::Windows::Forms::HScrollBar());
			this->View_Full = (gcnew System::Windows::Forms::Button());
			this->Box_Options = (gcnew System::Windows::Forms::GroupBox());
			this->Options_Create = (gcnew System::Windows::Forms::Button());
			this->Options_Bound = (gcnew System::Windows::Forms::Button());
			this->tabControl1 = (gcnew System::Windows::Forms::TabControl());
			this->tabPage1 = (gcnew System::Windows::Forms::TabPage());
			this->hScrollBar2 = (gcnew System::Windows::Forms::HScrollBar());
			this->vScrollBar1 = (gcnew System::Windows::Forms::VScrollBar());
			this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
			this->openFileDialog1 = (gcnew System::Windows::Forms::OpenFileDialog());
			this->saveFileDialog1 = (gcnew System::Windows::Forms::SaveFileDialog());
			this->BottomToolStripPanel = (gcnew System::Windows::Forms::ToolStripPanel());
			this->TopToolStripPanel = (gcnew System::Windows::Forms::ToolStripPanel());
			this->RightToolStripPanel = (gcnew System::Windows::Forms::ToolStripPanel());
			this->LeftToolStripPanel = (gcnew System::Windows::Forms::ToolStripPanel());
			this->ContentPanel = (gcnew System::Windows::Forms::ToolStripContentPanel());
			this->MainMenu->SuspendLayout();
			this->ToolBar_Top->SuspendLayout();
			this->StatusStrip->SuspendLayout();
			this->MainSplit->Panel1->SuspendLayout();
			this->MainSplit->Panel2->SuspendLayout();
			this->MainSplit->SuspendLayout();
			this->Box_Export->SuspendLayout();
			this->groupBox1->SuspendLayout();
			this->panel1->SuspendLayout();
			this->Box_Options->SuspendLayout();
			this->tabControl1->SuspendLayout();
			this->tabPage1->SuspendLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->BeginInit();
			this->SuspendLayout();
			// 
			// MainMenu
			// 
			this->MainMenu->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(4) {this->MainMenu_File, this->MainMenu_Edit, 
				this->MainMenu_View, this->MainMenu_Help});
			this->MainMenu->Location = System::Drawing::Point(0, 0);
			this->MainMenu->Name = L"MainMenu";
			this->MainMenu->Size = System::Drawing::Size(735, 24);
			this->MainMenu->TabIndex = 1;
			this->MainMenu->Text = L"Main Menu";
			// 
			// MainMenu_File
			// 
			this->MainMenu_File->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {this->MainMenu_File_Open, 
				this->MainMenu_File_Export, this->MainMenu_File_Exit});
			this->MainMenu_File->Name = L"MainMenu_File";
			this->MainMenu_File->Text = L"File";
			// 
			// MainMenu_File_Open
			// 
			this->MainMenu_File_Open->Name = L"MainMenu_File_Open";
			this->MainMenu_File_Open->Text = L"Open";
			this->MainMenu_File_Open->Click += gcnew System::EventHandler(this, &Form1::File_Open_Click);
			// 
			// MainMenu_File_Export
			// 
			this->MainMenu_File_Export->Name = L"MainMenu_File_Export";
			this->MainMenu_File_Export->Text = L"Export";
			this->MainMenu_File_Export->Click += gcnew System::EventHandler(this, &Form1::MainMenu_File_Export_Click);
			// 
			// MainMenu_File_Exit
			// 
			this->MainMenu_File_Exit->Name = L"MainMenu_File_Exit";
			this->MainMenu_File_Exit->Text = L"Exit";
			this->MainMenu_File_Exit->Click += gcnew System::EventHandler(this, &Form1::MainMenu_File_Exit_Click);
			// 
			// MainMenu_Edit
			// 
			this->MainMenu_Edit->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {this->MainMenu_Edit_Box, 
				this->MainMenu_Edit_Sprite});
			this->MainMenu_Edit->Name = L"MainMenu_Edit";
			this->MainMenu_Edit->Text = L"Edit";
			// 
			// MainMenu_Edit_Box
			// 
			this->MainMenu_Edit_Box->Name = L"MainMenu_Edit_Box";
			this->MainMenu_Edit_Box->Text = L"BoundBox";
			// 
			// MainMenu_Edit_Sprite
			// 
			this->MainMenu_Edit_Sprite->Name = L"MainMenu_Edit_Sprite";
			this->MainMenu_Edit_Sprite->Text = L"Create Sprite";
			// 
			// MainMenu_View
			// 
			this->MainMenu_View->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) {this->MainMenu_View_FullScreen});
			this->MainMenu_View->Name = L"MainMenu_View";
			this->MainMenu_View->Text = L"View";
			// 
			// MainMenu_View_FullScreen
			// 
			this->MainMenu_View_FullScreen->Name = L"MainMenu_View_FullScreen";
			this->MainMenu_View_FullScreen->Text = L"Full Screen";
			// 
			// MainMenu_Help
			// 
			this->MainMenu_Help->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {this->MainMenu_View_Contents, 
				this->MainMenu_Help_About});
			this->MainMenu_Help->Name = L"MainMenu_Help";
			this->MainMenu_Help->Text = L"Help";
			// 
			// MainMenu_View_Contents
			// 
			this->MainMenu_View_Contents->Name = L"MainMenu_View_Contents";
			this->MainMenu_View_Contents->Text = L"Contents";
			// 
			// MainMenu_Help_About
			// 
			this->MainMenu_Help_About->Name = L"MainMenu_Help_About";
			this->MainMenu_Help_About->Text = L"About";
			// 
			// ToolBar_Top
			// 
			this->ToolBar_Top->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(10) {this->newToolStripButton1, 
				this->openToolStripButton1, this->saveToolStripButton1, this->printToolStripButton1, this->toolStripSeparator2, this->cutToolStripButton1, 
				this->copyToolStripButton1, this->pasteToolStripButton1, this->toolStripSeparator3, this->helpToolStripButton1});
			this->ToolBar_Top->Location = System::Drawing::Point(0, 24);
			this->ToolBar_Top->Name = L"ToolBar_Top";
			this->ToolBar_Top->RenderMode = System::Windows::Forms::ToolStripRenderMode::Professional;
			this->ToolBar_Top->Size = System::Drawing::Size(735, 25);
			this->ToolBar_Top->TabIndex = 2;
			this->ToolBar_Top->Text = L"toolStrip1";
			this->ToolBar_Top->ItemClicked += gcnew System::Windows::Forms::ToolStripItemClickedEventHandler(this, &Form1::ToolBar_Top_ItemClicked);
			// 
			// newToolStripButton1
			// 
			this->newToolStripButton1->Displaystyle = System::Windows::Forms::ToolStripItemDisplaystyle::Image;
			this->newToolStripButton1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"newToolStripButton1.Image")));
			this->newToolStripButton1->ImageTransparentColor = System::Drawing::Color::Magenta;
			this->newToolStripButton1->Name = L"newToolStripButton1";
			this->newToolStripButton1->Text = L"&New";
			// 
			// openToolStripButton1
			// 
			this->openToolStripButton1->Displaystyle = System::Windows::Forms::ToolStripItemDisplaystyle::Image;
			this->openToolStripButton1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"openToolStripButton1.Image")));
			this->openToolStripButton1->ImageTransparentColor = System::Drawing::Color::Magenta;
			this->openToolStripButton1->Name = L"openToolStripButton1";
			this->openToolStripButton1->Text = L"&Open";
			// 
			// saveToolStripButton1
			// 
			this->saveToolStripButton1->Displaystyle = System::Windows::Forms::ToolStripItemDisplaystyle::Image;
			this->saveToolStripButton1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"saveToolStripButton1.Image")));
			this->saveToolStripButton1->ImageTransparentColor = System::Drawing::Color::Magenta;
			this->saveToolStripButton1->Name = L"saveToolStripButton1";
			this->saveToolStripButton1->Text = L"&Save";
			// 
			// printToolStripButton1
			// 
			this->printToolStripButton1->Displaystyle = System::Windows::Forms::ToolStripItemDisplaystyle::Image;
			this->printToolStripButton1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"printToolStripButton1.Image")));
			this->printToolStripButton1->ImageTransparentColor = System::Drawing::Color::Magenta;
			this->printToolStripButton1->Name = L"printToolStripButton1";
			this->printToolStripButton1->Text = L"&Print";
			// 
			// toolStripSeparator2
			// 
			this->toolStripSeparator2->Name = L"toolStripSeparator2";
			// 
			// cutToolStripButton1
			// 
			this->cutToolStripButton1->Displaystyle = System::Windows::Forms::ToolStripItemDisplaystyle::Image;
			this->cutToolStripButton1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"cutToolStripButton1.Image")));
			this->cutToolStripButton1->ImageTransparentColor = System::Drawing::Color::Magenta;
			this->cutToolStripButton1->Name = L"cutToolStripButton1";
			this->cutToolStripButton1->Text = L"C&ut";
			// 
			// copyToolStripButton1
			// 
			this->copyToolStripButton1->Displaystyle = System::Windows::Forms::ToolStripItemDisplaystyle::Image;
			this->copyToolStripButton1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"copyToolStripButton1.Image")));
			this->copyToolStripButton1->ImageTransparentColor = System::Drawing::Color::Magenta;
			this->copyToolStripButton1->Name = L"copyToolStripButton1";
			this->copyToolStripButton1->Text = L"&Copy";
			// 
			// pasteToolStripButton1
			// 
			this->pasteToolStripButton1->Displaystyle = System::Windows::Forms::ToolStripItemDisplaystyle::Image;
			this->pasteToolStripButton1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pasteToolStripButton1.Image")));
			this->pasteToolStripButton1->ImageTransparentColor = System::Drawing::Color::Magenta;
			this->pasteToolStripButton1->Name = L"pasteToolStripButton1";
			this->pasteToolStripButton1->Text = L"&Paste";
			// 
			// toolStripSeparator3
			// 
			this->toolStripSeparator3->Name = L"toolStripSeparator3";
			// 
			// helpToolStripButton1
			// 
			this->helpToolStripButton1->Displaystyle = System::Windows::Forms::ToolStripItemDisplaystyle::Image;
			this->helpToolStripButton1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"helpToolStripButton1.Image")));
			this->helpToolStripButton1->ImageTransparentColor = System::Drawing::Color::Magenta;
			this->helpToolStripButton1->Name = L"helpToolStripButton1";
			this->helpToolStripButton1->Text = L"He&lp";
			// 
			// StatusStrip
			// 
			this->StatusStrip->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {this->StatusBar, this->toolStripStatusLabel1, 
				this->MouseX});
			this->StatusStrip->Layoutstyle = System::Windows::Forms::ToolStripLayoutstyle::Table;
			this->StatusStrip->Location = System::Drawing::Point(0, 457);
			this->StatusStrip->Name = L"StatusStrip";
			this->StatusStrip->RenderMode = System::Windows::Forms::ToolStripRenderMode::Professional;
			this->StatusStrip->Size = System::Drawing::Size(735, 27);
			this->StatusStrip->Stretch = false;
			this->StatusStrip->TabIndex = 3;
			this->StatusStrip->Text = L"statusStrip1";
			// 
			// StatusBar
			// 
			this->StatusBar->Name = L"StatusBar";
			this->StatusBar->Padding = System::Windows::Forms::Padding(0, 0, 3, 0);
			this->StatusBar->Text = L"Awaiting file input";
			// 
			// toolStripStatusLabel1
			// 
			this->toolStripStatusLabel1->Name = L"toolStripStatusLabel1";
			this->toolStripStatusLabel1->Text = L"                 ";
			// 
			// MouseX
			// 
			this->MouseX->Margin = System::Windows::Forms::Padding(3);
			this->MouseX->Name = L"MouseX";
			this->MouseX->Padding = System::Windows::Forms::Padding(2);
			this->MouseX->RightToLeft = System::Windows::Forms::RightToLeft::No;
			this->MouseX->Text = L"(0,0)";
			this->MouseX->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
			// 
			// MainSplit
			// 
			this->MainSplit->Borderstyle = System::Windows::Forms::Borderstyle::Fixed3D;
			this->MainSplit->Dock = System::Windows::Forms::Dockstyle::Fill;
			this->MainSplit->Location = System::Drawing::Point(0, 49);
			this->MainSplit->Name = L"MainSplit";
			// 
			// MainSplit.Panel1
			// 
			this->MainSplit->Panel1->BackColor = System::Drawing::SystemColors::ControlLight;
			this->MainSplit->Panel1->Controls->Add(this->Box_Export);
			this->MainSplit->Panel1->Controls->Add(this->groupBox1);
			this->MainSplit->Panel1->Controls->Add(this->Box_Options);
			// 
			// MainSplit.Panel2
			// 
			this->MainSplit->Panel2->Controls->Add(this->tabControl1);
			this->MainSplit->Panel2->Cursor = System::Windows::Forms::Cursors::Cross;
			this->MainSplit->Panel2->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::MainSplit_Panel2_Paint);
			this->MainSplit->Size = System::Drawing::Size(735, 408);
			this->MainSplit->SplitterDistance = 191;
			this->MainSplit->TabIndex = 5;
			this->MainSplit->Text = L"splitContainer1";
			this->MainSplit->SplitterMoved += gcnew System::Windows::Forms::SplitterEventHandler(this, &Form1::MainSplit_SplitterMoved);
			// 
			// Box_Export
			// 
			this->Box_Export->Controls->Add(this->Export_Selected);
			this->Box_Export->Controls->Add(this->Export_All);
			this->Box_Export->Location = System::Drawing::Point(4, 303);
			this->Box_Export->Name = L"Box_Export";
			this->Box_Export->Size = System::Drawing::Size(180, 87);
			this->Box_Export->TabIndex = 2;
			this->Box_Export->TabStop = false;
			this->Box_Export->Text = L"Export";
			// 
			// Export_Selected
			// 
			this->Export_Selected->Location = System::Drawing::Point(0, 57);
			this->Export_Selected->Name = L"Export_Selected";
			this->Export_Selected->Size = System::Drawing::Size(180, 23);
			this->Export_Selected->TabIndex = 1;
			this->Export_Selected->Text = L"Export Seleted";
			// 
			// Export_All
			// 
			this->Export_All->Location = System::Drawing::Point(0, 28);
			this->Export_All->Name = L"Export_All";
			this->Export_All->Size = System::Drawing::Size(180, 23);
			this->Export_All->TabIndex = 0;
			this->Export_All->Text = L"Export All";
			// 
			// groupBox1
			// 
			this->groupBox1->Controls->Add(this->SpriteName_Input);
			this->groupBox1->Controls->Add(this->NameLabel);
			this->groupBox1->Controls->Add(this->panel1);
			this->groupBox1->Controls->Add(this->View_Full);
			this->groupBox1->Location = System::Drawing::Point(4, 105);
			this->groupBox1->Name = L"groupBox1";
			this->groupBox1->Size = System::Drawing::Size(180, 189);
			this->groupBox1->TabIndex = 1;
			this->groupBox1->TabStop = false;
			this->groupBox1->Text = L"View";
			// 
			// SpriteName_Input
			// 
			this->SpriteName_Input->AcceptsReturn = true;
			this->SpriteName_Input->AcceptsTab = true;
			this->SpriteName_Input->Location = System::Drawing::Point(43, 165);
			this->SpriteName_Input->MaxLength = 32;
			this->SpriteName_Input->Name = L"SpriteName_Input";
			this->SpriteName_Input->Size = System::Drawing::Size(126, 20);
			this->SpriteName_Input->TabIndex = 5;
			// 
			// NameLabel
			// 
			this->NameLabel->AutoSize = true;
			this->NameLabel->Location = System::Drawing::Point(6, 168);
			this->NameLabel->Name = L"NameLabel";
			this->NameLabel->Size = System::Drawing::Size(34, 13);
			this->NameLabel->TabIndex = 4;
			this->NameLabel->Text = L"Name:";
			this->NameLabel->Click += gcnew System::EventHandler(this, &Form1::label1_Click);
			// 
			// panel1
			// 
			this->panel1->Borderstyle = System::Windows::Forms::Borderstyle::Fixed3D;
			this->panel1->Controls->Add(this->hScrollBar1);
			this->panel1->Location = System::Drawing::Point(9, 54);
			this->panel1->Name = L"panel1";
			this->panel1->Size = System::Drawing::Size(160, 96);
			this->panel1->TabIndex = 3;
			// 
			// hScrollBar1
			// 
			this->hScrollBar1->Location = System::Drawing::Point(0, 77);
			this->hScrollBar1->Name = L"hScrollBar1";
			this->hScrollBar1->Size = System::Drawing::Size(160, 15);
			this->hScrollBar1->TabIndex = 0;
			// 
			// View_Full
			// 
			this->View_Full->Location = System::Drawing::Point(0, 19);
			this->View_Full->Name = L"View_Full";
			this->View_Full->Size = System::Drawing::Size(180, 23);
			this->View_Full->TabIndex = 2;
			this->View_Full->Text = L"Full Screen";
			// 
			// Box_Options
			// 
			this->Box_Options->Controls->Add(this->Options_Create);
			this->Box_Options->Controls->Add(this->Options_Bound);
			this->Box_Options->Location = System::Drawing::Point(4, 14);
			this->Box_Options->Name = L"Box_Options";
			this->Box_Options->Size = System::Drawing::Size(180, 85);
			this->Box_Options->TabIndex = 0;
			this->Box_Options->TabStop = false;
			this->Box_Options->Text = L"Options";
			// 
			// Options_Create
			// 
			this->Options_Create->Location = System::Drawing::Point(0, 48);
			this->Options_Create->Name = L"Options_Create";
			this->Options_Create->Size = System::Drawing::Size(180, 23);
			this->Options_Create->TabIndex = 1;
			this->Options_Create->Text = L"Create Sprite";
			// 
			// Options_Bound
			// 
			this->Options_Bound->Location = System::Drawing::Point(0, 19);
			this->Options_Bound->Name = L"Options_Bound";
			this->Options_Bound->Size = System::Drawing::Size(180, 23);
			this->Options_Bound->TabIndex = 0;
			this->Options_Bound->Text = L"Set Area";
			// 
			// tabControl1
			// 
			this->tabControl1->Controls->Add(this->tabPage1);
			this->tabControl1->Dock = System::Windows::Forms::Dockstyle::Fill;
			this->tabControl1->Location = System::Drawing::Point(0, 0);
			this->tabControl1->Name = L"tabControl1";
			this->tabControl1->SelectedIndex = 0;
			this->tabControl1->Size = System::Drawing::Size(536, 404);
			this->tabControl1->SizeMode = System::Windows::Forms::TabSizeMode::FillToRight;
			this->tabControl1->TabIndex = 0;
			// 
			// tabPage1
			// 
			this->tabPage1->Controls->Add(this->hScrollBar2);
			this->tabPage1->Controls->Add(this->vScrollBar1);
			this->tabPage1->Controls->Add(this->pictureBox1);
			this->tabPage1->Location = System::Drawing::Point(4, 22);
			this->tabPage1->Name = L"tabPage1";
			this->tabPage1->Padding = System::Windows::Forms::Padding(3);
			this->tabPage1->Size = System::Drawing::Size(528, 378);
			this->tabPage1->TabIndex = 0;
			this->tabPage1->Text = L"Awaiting File";
			// 
			// hScrollBar2
			// 
			this->hScrollBar2->Dock = System::Windows::Forms::Dockstyle::Bottom;
			this->hScrollBar2->Location = System::Drawing::Point(20, 358);
			this->hScrollBar2->Name = L"hScrollBar2";
			this->hScrollBar2->Size = System::Drawing::Size(505, 17);
			this->hScrollBar2->TabIndex = 2;
			// 
			// vScrollBar1
			// 
			this->vScrollBar1->Dock = System::Windows::Forms::Dockstyle::Left;
			this->vScrollBar1->Location = System::Drawing::Point(3, 3);
			this->vScrollBar1->Name = L"vScrollBar1";
			this->vScrollBar1->Size = System::Drawing::Size(17, 372);
			this->vScrollBar1->TabIndex = 1;
			this->vScrollBar1->Scroll += gcnew System::Windows::Forms::ScrollEventHandler(this, &Form1::vScrollBar1_Scroll);
			// 
			// pictureBox1
			// 
			this->pictureBox1->AutoSize = true;
			this->pictureBox1->Dock = System::Windows::Forms::Dockstyle::Fill;
			this->pictureBox1->Location = System::Drawing::Point(3, 3);
			this->pictureBox1->Name = L"pictureBox1";
			this->pictureBox1->Size = System::Drawing::Size(522, 372);
			this->pictureBox1->SizeMode = System::Windows::Forms::PictureBoxSizeMode::AutoSize;
			this->pictureBox1->TabIndex = 0;
			this->pictureBox1->TabStop = false;
			this->pictureBox1->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::pictureBox1_OnMouseMove);
			this->pictureBox1->MouseUp += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::pictureBox1_OnMouseUp);
			this->pictureBox1->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::pictureBox1_OnMouseDown);
			// 
			// openFileDialog1
			// 
			this->openFileDialog1->FileName = L"openFileDialog1";
			this->openFileDialog1->Filter = L"JPEG Files (*.jpg)|*.jpg|PNG Files (*.png)|*.png|BMP Files (*.bmp)|*.bmp|TIFF Fil" 
				L"es (*.tff)|*.tff|All Files|";
			this->openFileDialog1->FilterIndex = 3;
			this->openFileDialog1->InitialDirectory = L"C:\\Documents & Settings\\User";
			this->openFileDialog1->FileOk += gcnew System::ComponentModel::CancelEventHandler(this, &Form1::openFileDialog1_FileOk);
			// 
			// saveFileDialog1
			// 
			this->saveFileDialog1->Filter = L"Binary Files (*.bin)|*.bin|All Files|";
			this->saveFileDialog1->FilterIndex = 2;
			this->saveFileDialog1->FileOk += gcnew System::ComponentModel::CancelEventHandler(this, &Form1::saveFileDialog1_FileOk);
			// 
			// BottomToolStripPanel
			// 
			this->BottomToolStripPanel->Location = System::Drawing::Point(0, 0);
			this->BottomToolStripPanel->Name = L"BottomToolStripPanel";
			this->BottomToolStripPanel->Orientation = System::Windows::Forms::Orientation::Horizontal;
			this->BottomToolStripPanel->RowMargin = System::Windows::Forms::Padding(0);
			this->BottomToolStripPanel->Size = System::Drawing::Size(0, 0);
			// 
			// TopToolStripPanel
			// 
			this->TopToolStripPanel->Location = System::Drawing::Point(0, 0);
			this->TopToolStripPanel->Name = L"TopToolStripPanel";
			this->TopToolStripPanel->Orientation = System::Windows::Forms::Orientation::Horizontal;
			this->TopToolStripPanel->RowMargin = System::Windows::Forms::Padding(0);
			this->TopToolStripPanel->Size = System::Drawing::Size(0, 0);
			// 
			// RightToolStripPanel
			// 
			this->RightToolStripPanel->Location = System::Drawing::Point(0, 0);
			this->RightToolStripPanel->Name = L"RightToolStripPanel";
			this->RightToolStripPanel->Orientation = System::Windows::Forms::Orientation::Horizontal;
			this->RightToolStripPanel->RowMargin = System::Windows::Forms::Padding(0);
			this->RightToolStripPanel->Size = System::Drawing::Size(0, 0);
			// 
			// LeftToolStripPanel
			// 
			this->LeftToolStripPanel->Location = System::Drawing::Point(0, 0);
			this->LeftToolStripPanel->Name = L"LeftToolStripPanel";
			this->LeftToolStripPanel->Orientation = System::Windows::Forms::Orientation::Horizontal;
			this->LeftToolStripPanel->RowMargin = System::Windows::Forms::Padding(0);
			this->LeftToolStripPanel->Size = System::Drawing::Size(0, 0);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(735, 484);
			this->Controls->Add(this->MainSplit);
			this->Controls->Add(this->ToolBar_Top);
			this->Controls->Add(this->StatusStrip);
			this->Controls->Add(this->MainMenu);
			this->IsMdiContainer = true;
			this->MainMenuStrip = this->MainMenu;
			this->Name = L"Form1";
			this->Text = L"Image Slicer - James Gupta";
			this->Load += gcnew System::EventHandler(this, &Form1::Window_Load);
			this->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::Form1_OnPaint);
			this->MainMenu->ResumeLayout(false);
			this->ToolBar_Top->ResumeLayout(false);
			this->StatusStrip->ResumeLayout(false);
			this->MainSplit->Panel1->ResumeLayout(false);
			this->MainSplit->Panel2->ResumeLayout(false);
			this->MainSplit->ResumeLayout(false);
			this->Box_Export->ResumeLayout(false);
			this->groupBox1->ResumeLayout(false);
			this->groupBox1->PerformLayout();
			this->panel1->ResumeLayout(false);
			this->Box_Options->ResumeLayout(false);
			this->tabControl1->ResumeLayout(false);
			this->tabPage1->ResumeLayout(false);
			this->tabPage1->PerformLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->EndInit();
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	private: System::Void Window_Load(System::Object^  sender, System::EventArgs^  e) {
			 }
private: System::Void splitContainer1_Panel1_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {
		 }
private: System::Void label1_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void File_Open_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			 openFileDialog1->ShowDialog();
			 this->pictureBox1->Image = Image::FromFile(openFileDialog1->FileName);
			 hScrollBar1->Maximum = this->pictureBox1->Image->Width - this->pictureBox1->Width +
				 hScrollBar1->Height;
			
			 vScrollBar1->Maximum = this->pictureBox1->Image->Height - this->pictureBox1->Height +
				 hScrollBar1->Width;
			 if (this->pictureBox1->Height > this->pictureBox1->Image->Height)
				 vScrollBar1->Visible = false;
			 if (this->pictureBox1->Width > this->pictureBox1->Image->Width)
				 hScrollBar1->Visible = false;
			 tabPage1->Text = openFileDialog1->FileName;


		 }

private: System::Void MainMenu_File_Export_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			 saveFileDialog1->ShowDialog();
		 }
private: System::Void MainMenu_File_Exit_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			 Form1::Close();
		 }
private: System::Void openFileDialog1_FileOk(System::Object^  sender, System::ComponentModel::CancelEventArgs^  e) {
		 }
private: System::Void saveFileDialog1_FileOk(System::Object^  sender, System::ComponentModel::CancelEventArgs^  e) {
		 }
private: System::Void MainSplit_SplitterMoved(System::Object^  sender, System::Windows::Forms::SplitterEventArgs^  e) {
		 }
private: System::Void MainSplit_Panel2_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {
		 }
private: System::Void ToolBar_Top_ItemClicked(System::Object^  sender, System::Windows::Forms::ToolStripItemClickedEventArgs^  e) {
		 }

//void OpenFile()
//{
//	
//}
//
//void CreateChild(Object Sender, EventArgs Args)
//{
//			// Create an instance of the Child
//		//		COneChild OC = gcnew COneChild();
//				COneChild OC;
//				OC.Text = "Child";
//				OC.MdiParent = this;
//				OC.Show();
//}
private: System::Void pictureBox1_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void tabPage2_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void pictureBox1_Click_1(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void vScrollBar1_Scroll(System::Object^  sender, System::Windows::Forms::ScrollEventArgs^  e) 
		 {
		/*	 Graphics gphpictureBox = pictureBox1->CreateGraphics();
			 gphpictureBox.DrawImage(pictureBox1->Image, 
				 new Rectangle (0,0,pictureBox1->Width - hScrollBar1->Height,
				 pictureBox1->Height - vScrollBar1->Width),
				 new Rectangle (hScrollBar1->Value,vScrollBar1->Value,
				 pictureBox1->Width - hScrollBar1->Height
				 ,pictureBox1->Height - vScrollBar1->Width),
				 GraphicsUnit::Pixel);*/
		 }
private: System::Void pictureBox1_OnMouseMove(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
		 {
			 MouseX->Text = "(";
			 MouseX->Text +=  e->X.ToString();
			 MouseX->Text += ",";
			 MouseX->Text += e->Y.ToString();
			 MouseX->Text += ")";
		 }

private: System::Void pictureBox1_OnMouseUp(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
		 {
			 FinishX = e->X;
			 FinishY = e->Y;
			CurrRect = Rectangle(StartX,StartY, (FinishX - StartX),(FinishY - StartY));
			GraphicsObj->DrawRectangle(Pens::Red,200,200,100,100);
			 }
private: System::Void pictureBox1_OnMouseDown(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
		 {
		 StartX = e->X;
		 StartY = e->Y;
		 }
private: System::Void pictureBox1_OnPaint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) 
		 {
		 System::Drawing::Rectangle ARect = Rectangle(200,200,100,100);

		 }
private: System::Void Form1_OnPaint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) 
		 {
	//		 Form1::GraphicsObj->DrawRectangle(MyPen,200,200,100,100);
		 }
};





the problem is at the bottom where the picture box event handlers are [Edited by - SiCrane on July 25, 2005 10:06:33 AM]

Share this post


Link to post
Share on other sites
Advertisement
OnPaint when i try to get it to use the rect constructed from the mouse coords - i just need someone to type an example system for it

Share this post


Link to post
Share on other sites
Well, the problem is that GraphicsObj is not initialized to anything. It's just a null pointer.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!