简体   繁体   English

如何在Visual Studio 2010 WinForm对象中添加到C ++控制台应用程序项目

[英]how to add in Visual Studio 2010 WinForm Object to a C++ Console Application Project

I am building a C++ Console Application which makes some OpenGL printing. 我正在构建一个进行一些OpenGL打印的C ++控制台应用程序。
The entire thing is done by glut and gl libraries. 整个过程由glut和gl库完成。 My new goal is to add some Windows Forms to the project so one could "configure" the 'game' with some textbox and other controls provided by VS before the console appliction starts. 我的新目标是向项目添加一些Windows窗体,以便在控制台应用程序开始之前,可以使用VS提供的一些文本框和其他控件来“配置”“游戏”。
I know that the best solution for the current problem is to add Win32 API, but I don't know how to integrate console application project with win32 API alltogether. 我知道针对当前问题的最佳解决方案是添加Win32 API,但我不知道如何将控制台应用程序项目与Win32 API集成在一起。
I know that in C# it's done quite easily with the .ShowDialog() command. 我知道在C#中,使用.ShowDialog()命令很容易完成。

Although launching a window from a console application is perfectly doable, that window will not be responsive, because your console application does not have a message queue. 尽管从控制台应用程序启动窗口是完全可行的,但是该窗口将不会响应,因为您的控制台应用程序没有消息队列。 (Or rather, it has a message queue, but it is implemented by code that you have no control over.) So, you can open up a window, draw in it, and force it to manually update, but you cannot receive user input in it. (或者,它有一个消息队列,但是它是由您无法控制的代码实现的。)因此,您可以打开一个窗口,在其中绘制窗口,并强制其手动更新,但是您无法收到用户输入在里面。

I would suggest that you forget about doing it this way, and you write a little windowed application instead, which prompts for the configuration and then launches the console application passing it the configuration as command-line parameters, or fills-in a configuration file for the console application to read. 我建议您不要这样做,而是编写一个小窗口应用程序,该应用程序会提示您进行配置,然后启动控制台应用程序,将配置作为命令行参数传递给该应用程序,或者填写用于控制台应用程序读取。

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

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