Graphics^graphics = panel->CreateGraphics();
Pen^ penCurrent = gcnew Pen(Color::Red);
Point p1(10,10);
Point p2(20,20);
graphics->DrawLine(penCurrent,p1,p2);
delete graphics;
次の完全な例では、仕事と描くラインに
#include "windows.h"
#using <mscorlib.dll>
#using <System.dll>
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>
using namespace System::Windows::Forms;
using namespace System;
using namespace System::Drawing;
ref class MyForm : public Form
{
public:
MyForm()
{
Text = "Hello, Windows Forms!";
auto button = gcnew Button();
button->Text = "Click Me!";
button->Click += gcnew EventHandler(this, &MyForm::button_click);
this->Controls->Add(button);
}
void button_click(Object^ sender, EventArgs^ e)
{
auto g = this->CreateGraphics();
g->DrawLine(Pens::Black, Point(10, 10), Point(50, 50));
delete g;
}
};
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
Application::Run(gcnew MyForm);
}
エラーエラーC2039です: '廃棄は': –
':: ::グラフィックス描画システム' のメンバーではありませんいいえ、作品を削除しても、パネルには何も表示されません。パネルに何かを描く他の方法はありますか?私は前のコードで間違っているかもしれません.. –