掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
線を引くには? Part2 (ID:69613)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
失礼しました。 グラフ表示がふたつありましたね。 一応、線を引くことができたのですが、Form1上に線を引いてしまいます。 Form2上に線はどのようにして引けばよいのでしょうか? #pragma once namespace test000000 { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); } protected: ~Form1() { if (components) { delete components; } } private: System::Windows::Forms::Button^ button1; protected: private: System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code void InitializeComponent(void) { this->button1 = (gcnew System::Windows::Forms::Button()); this->SuspendLayout(); // button1 this->button1->Location = System::Drawing::Point(98, 100); this->button1->Name = L"button1"; this->button1->Size = System::Drawing::Size(75, 23); this->button1->TabIndex = 0; this->button1->Text = L"グラフ表示"; this->button1->UseVisualStyleBackColor = true; this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click); // Form1 this->AutoScaleDimensions = System::Drawing::SizeF(6, 12); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(292, 266); this->Controls->Add(this->button1); this->Name = L"Form1"; this->Text = L"Form1"; this->ResumeLayout(false); } #pragma endregion //グラフ表示ボタン押下 private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { System::Windows::Forms::Form^ Form2 = gcnew Form; System::Windows::Forms::PictureBox^ pictureBox1; pictureBox1 = gcnew PictureBox; pictureBox1->Dock = DockStyle::Fill; pictureBox1->BackColor = Color::White; pictureBox1->Paint += gcnew System::Windows::Forms::PaintEventHandler ( this, &Form1::pictureBox1_Paint ); this->Controls->Add( pictureBox1 ); Form2->ShowIcon = false; Form2->MinimizeBox = false; Form2->MaximizeBox = false; Form2->Text = L"GrapthShow"; Form2->Width = 300; Form2->Height = 300; Form2->MinimumSize = System::Drawing::Size(300,300); Form2->MaximumSize = System::Drawing::Size(300,300); Form2->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen; Form2->Activate(); Form2->Show(); Form2->Refresh(); } void pictureBox1_Paint( Object^ , System::Windows::Forms::PaintEventArgs^ e ) { Graphics^ g = e->Graphics; g->DrawLine( System::Drawing::Pens::Red, 10,10,100,100 ); } }; }
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.