Visual c++ 在表单代码之外调用表单方法
我有以下申请表格:Visual c++ 在表单代码之外调用表单方法,visual-c++,Visual C++,我有以下申请表格: #include "MyForm.h" using namespace System; using namespace System::Windows::Forms; [STAThread] void Main(array<String^>^ args) { Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false);
#include "MyForm.h"
using namespace System;
using namespace System::Windows::Forms;
[STAThread]
void Main(array<String^>^ args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
CppWinForm1::MyForm form;
Application::Run(%form);
}
如何在表单代码之外调用表单方法?您应该考虑使用无模式表单。我应该使用MFC构建表单吗?
#include "MyForm.h"
using namespace System;
using namespace System::Windows::Forms;
CppWinForm1::MyForm form;
[STAThread]
void Main(array<String^>^ args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Application::Run(%form);
}
Severity Code Description Project File Line Suppression State
Error C3145 'form': global or static variable may not have managed type 'CppWinForm1::MyForm' CppWinForm1
Error (active) a variable with static storage duration cannot have a ref class type CppWinForm1