を使用しているとき、私は次のコードを持っているとVisual Studio C++は、2つのエラー報告:のVisual Studio C++/CLIの構文エラーの.Net Windowsフォーム
#include "windows.h"
#using <mscorlib.dll>
#using <System.dll>
#using <System.Windows.Forms.dll>
using namespace System::Windows::Forms;
__gc class MyForm : public Form
{
public:
MyForm()
{
Text = "Hello, Windows Forms!";
Button* button = new Button();
button->Text = "Click Me!";
button->Click += new EventHandler(this, button_click);
this->Controls->Add(button);
}
void button_click(Object* sender, EventArgs* e)
{
MessageBox::Show("Ouch!");
}
};
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
Application::Run(new MyForm);
}
とエラー: エラーC2061構文エラー:イベントのArgs エラーをC2061構文エラー:EventHandler
コードを実行するにはどうすればよいですか? Thanxは事前に
、 "C++" などのマネージC++のための質問をタグ付けしていません - それはまったく別の言語です。私が見ているのは、あなたが '名前空間システムを使う 'ことを忘れたことです。しかし、代わりにC++/CLI(またはC#)を使用することを実際に考慮する必要があります.Managed C++は廃止予定です。 –
Windowsフォームには 'WinMain'は必要ありません。 'main'も使うことができます。 – ApprenticeHacker
問題が見つかりました。編集を確認してください。 – ApprenticeHacker