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입니다 : '폐기'가 : –
':: :: 그래픽 그리기 시스템'을의 구성원이 아닌 좋아, 작품을 삭제하지만 패널에는 아무 것도 없습니다. 패널에 무언가를 그릴 수있는 다른 방법이 있습니까? 이전 코드에서 잘못되었을 수 있습니다 .. –