- Start Microsoft Visual Studio .NET
- On the Start Page, click New Project (alternatively, on the main menu, you can
click File -> New -> Project...)
- On the New Project dialog box, in the Project Types tree list, click
Visual C++ Projects
- In the Templates list, click Managed C++ Empty Project
- In the Name edit box, replace the <Enter name> content with Dialog
Caller
- In the Location combo box, accept the suggestion or type your own.
If you don't have any, type C:\Programs\MSVC.NET
- Click OK
- On the main menu, click Project -> Add New Item...
- In the Add New Item dialog box, in the Templates list, click C++
File
- In the Name box, replace <Enter name> with MainForm and click OK
- To start with a simple form, the main form, replace the contents of the empty file with the following:
#using <mscorlib.dll>
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>
using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
__gc class CMainForm : public Form
{
public:
CMainForm();
};
CMainForm::CMainForm()
{
// This is the caption of the form
this->Text = S"Main Form";
// The size of the form Size(Width, Height)
this->Size = Drawing::Size(540, 420);
// When the form displays, position it to the center of the screen
this->StartPosition = FormStartPosition::CenterScreen;
}
int __stdcall WinMain()
{
CMainForm *MF = new CMainForm();
Application::Run(MF);
return 0;
}
|
- Press Ctrl + F5 to test the form
|