简体   繁体   English

使用CLR和C ++程序制作Windows窗体

[英]Making windows form with CLR and C++ program

So I have this project called "Detection" written in c++, the project is all set, it has class, function and of course a main function to call all the function and class written in Main.cpp . 因此,我有一个用c ++编写的名为“检测”的项目,该项目已全部设置好,它具有类,函数,当然还有一个主函数来调用用Main.cpp编写的所有函数和类。 The problem is, when I want to make GUI using windows form with CLR for this project (that I already made earlier), the MyForm.cpp (default name for windows form) also has main function. 问题是,当我要使用带有CLR的Windows窗体为此项目创建GUI(我之前已经做过)时,MyForm.cpp(Windows窗体的默认名称)也具有主要功能。 So I have some question : 所以我有一个问题:

  1. How can I overload these main functions? 如何重载这些主要功能?
  2. If I can overload them, how can I called the main function in Main.cpp through a button? 如果可以重载它们,如何通过按钮在Main.cpp中调用main函数? (after the button clicked, the program run) (单击按钮后,程序将运行)

I'am very sorry if my questions doesn't make sense because I'am new to CLR and C++. 如果我的问题没有道理,我感到非常抱歉,因为我是CLR和C ++的新手。 Thank you 谢谢

The approach you take isn't the correct one. 您采用的方法不正确。 Look up how to write functions in c++. 查找如何用c ++编写函数。

There should be one main function in your programme. 您的程序中应该有一个主要功能。 Other code should be written in an appropriately named function and called as per required; 其他代码应使用适当命名的函数编写,并按要求进行调用; for eg : 例如:

public static void main(char[]args){
//initialisation codes only
}

public void onButtonClicked()
{ 
   //your button clicked code 
   onPlaySound();
}

public void onPlaySound()
{ 
   //your play sound code 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM