Visual studio 2013 配置属性=>Linker=>Advanced。在属性窗口的右侧,将“入口点”设置为“主”。如果看不到“入口点”,只需重新打开“属性”窗口。这是下面给出的函数“main”。这是您的应用程序开始运行的地方
最后,双击表单设计器并将光标移动到代码底部“namespace Project1”的右括号之前。粘贴以下代码。请记住根据您的项目需要重命名此代码的变量,以使其使用空表单Visual studio 2013 配置属性=>Linker=>Advanced。在属性窗口的右侧,将“入口点”设置为“主”。如果看不到“入口点”,只需重新打开“属性”窗口。这是下面给出的函数“main”。这是您的应用程序开始运行的地方,visual-studio-2013,Visual Studio 2013,最后,双击表单设计器并将光标移动到代码底部“namespace Project1”的右括号之前。粘贴以下代码。请记住根据您的项目需要重命名此代码的变量,以使其使用空表单 [STAThread] void main(array<String^>^ arg) { Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); MyForm form
[STAThread]
void main(array<String^>^ arg) {
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
MyForm form;
Application::Run(%form);
}
[STAThread]
void main(数组^arg){
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
我的形式;
应用程序::运行(%form);
}
这个答案归功于@superlinux。以下是制作这样一个项目的步骤:
[STAThread]
void main(array<String^>^ arg) {
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
MyForm form;
Application::Run(%form);
}
[STAThread]
void main(数组^arg){
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
我的形式;
应用程序::运行(%form);
}
这个答案要归功于@superlinux。这个指南对我不起作用,所以我在YouTube上搜索,很容易将下面的代码放在
MyForm.cpp
中,而不是帖子给出的代码中,这样做很有效
using namespace System;
using namespace System::Windows::Forms;
[STAThread]
void main(array<String^>^ args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Project1::MyForm form;
Application::Run(%form);
}
使用名称空间系统;
使用命名空间System::Windows::Forms;
[状态线程]
void main(数组^args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Project1::MyForm;
应用程序::运行(%form);
}
指南对我不起作用,所以我在YouTube上搜索,很容易将下面的代码放在MyForm.cpp
中,而不是帖子给出的代码,它很有效
using namespace System;
using namespace System::Windows::Forms;
[STAThread]
void main(array<String^>^ args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Project1::MyForm form;
Application::Run(%form);
}
使用名称空间系统;
使用命名空间System::Windows::Forms;
[状态线程]
void main(数组^args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Project1::MyForm;
应用程序::运行(%form);
}
指南对我不起作用,所以我在YouTube上搜索,很容易将下面的代码放在MyForm.cpp
中,而不是帖子给出的代码,它很有效
using namespace System;
using namespace System::Windows::Forms;
[STAThread]
void main(array<String^>^ args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Project1::MyForm form;
Application::Run(%form);
}
使用名称空间系统;
使用命名空间System::Windows::Forms;
[状态线程]
void main(数组^args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Project1::MyForm;
应用程序::运行(%form);
}
指南对我不起作用,所以我在YouTube上搜索,很容易将下面的代码放在MyForm.cpp
中,而不是帖子给出的代码,它很有效
using namespace System;
using namespace System::Windows::Forms;
[STAThread]
void main(array<String^>^ args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Project1::MyForm form;
Application::Run(%form);
}
使用名称空间系统;
使用命名空间System::Windows::Forms;
[状态线程]
void main(数组^args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Project1::MyForm;
应用程序::运行(%form);
}
我知道这可能会很晚,但其他用户可能会好奇如何在保持终端窗口打开的同时做到这一点。这样,您可以使用cout
测试次要内容。无论如何,您可以创建另一个.cpp文件(只是cpp文件,而不是一个全新的类),而不是将int main()
放在UI中,在其中您可以有如下内容:
#include "MainWindow.h" //which is the name of the UI file
using namespace Projectname //you can check this at the top of the UI file says something like namespace Projectname { ui code }
[STATHREADATTRIBUTE] //you need this otherwise your window can't run things like the webbrowser
int main(){
MainWindow mw; //the name of the header file
mw.ShowDialog(); //this brings up the window, you can use mw.Hide() to close it
return 0;
}
这样,您就不必干扰配置,并且可以保持终端窗口打开。我相信您可以稍后通过配置属性关闭终端窗口。但我通常更喜欢这种方式,因为它更容易测试我的代码。我知道这可能会很晚,但其他用户可能会好奇如何在保持终端窗口打开的同时做到这一点。这样,您可以使用
cout
测试次要内容。无论如何,您可以创建另一个.cpp文件(只是cpp文件,而不是一个全新的类),而不是将int main()
放在UI中,在其中您可以有如下内容:
#include "MainWindow.h" //which is the name of the UI file
using namespace Projectname //you can check this at the top of the UI file says something like namespace Projectname { ui code }
[STATHREADATTRIBUTE] //you need this otherwise your window can't run things like the webbrowser
int main(){
MainWindow mw; //the name of the header file
mw.ShowDialog(); //this brings up the window, you can use mw.Hide() to close it
return 0;
}
这样,您就不必干扰配置,并且可以保持终端窗口打开。我相信你可以通过窗户把候机楼的窗户关上