简体   繁体   English

如何在Visual C ++ 2008中将MFC应用程序项目添加到Win32应用程序项目

[英]How to add MFC application project to Win32 application project in Visual C++ 2008

I've spent most of my day trying to figure out why this error is occurring but it continues to mystify me. 我花了大部分时间试图弄清楚为什么会出现这种错误,但这仍然让我感到困惑。

I created a console application in Visual C++ and created one MFC application.Now, I want to add them into single project such way that when i compile the project ,it should open the console then will open Dialog box depending upon my commands...... 我在Visual C ++中创建了一个控制台应用程序并创建了一个MFC应用程序。现在,我想将它们添加到单个项目中,这样当我编译项目时,它应该打开控制台然后根据我的命令打开对话框... ...

I've added afx headers files,set configuration settings. 我添加了afx头文件,设置配置设置。

I want to know where to start whether starting point would in winmain() or int main()? 我想知道从哪里开始是在winmain()还是int main()? Is there any examples.? 有没有例子? Give me some links to know. 给我一些知道的链接。 the solution Thank you in advance. 解决方案提前谢谢你。

Create MFC dialog-based application. 创建基于MFC对话框的应用程序。 Project - Properties - Configuration Properies- Linker - Advanced - Entry Point, set wWinMainCRTStartup (assuming that project is Unicode). 项目 - 属性 - 配置属性 - 链接器 - 高级 - 入口点,设置wWinMainCRTStartup(假设项目是Unicode)。 Linker - System - select Console. 链接器 - 系统 - 选择控制台。 Build application. 构建应用程序 Now it opens Console window and the dialog from it. 现在它打开控制台窗口和它的对话框。

Add some logic. 添加一些逻辑。 For example, in my Application class cpp file I added the following: 例如,在我的Application类cpp文件中,我添加了以下内容:

#include "stdafx.h"
#include "testmfc.h"
#include "testmfcDlg.h"
#include <iostream>      // add
#include <string>        // add
using namespace std;     // add

...

BOOL CtestmfcApp::InitInstance()
{
     ...

     SetRegistryKey(_T("Local AppWizard-Generated Applications"));

     // ****** add this
     string s;
     cout << "Start application?" << endl;
     cin >> s;

     if ( s == "y" )
     {
         CtestmfcDlg dlg;
         m_pMainWnd = &dlg;
         dlg.DoModal();
     }
     // ****** 

    // Delete the shell manager created above.
    if (pShellManager != NULL)
    {
        delete pShellManager;
    }

    return FALSE;
}

Now run application. 现在运行应用程序 If you answer "y" in the Console window, dialog is shown. 如果在控制台窗口中回答“y”,则会显示对话框。 Otherwise, application exits immediately. 否则,应用程序立即退出。 Implement your own logic based on this sample. 基于此示例实现您自己的逻辑。

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

相关问题 将C ++ Win32 Console项目类集成到Visual Studio 2008中的Visual C ++(Windows窗体应用程序)项目中 - Integrate C++ Win32 Console project classes into Visual C++ (Windows forms application) project in Visual Studio 2008 C ++,MFC,选项卡式文档界面应用程序,Win32 - C++, MFC, tabbed document interface application, Win32 如何将项目win32控制台应用程序转换为C ++ Windows窗体? - How can I convert project win32 console application into C++ Windows Form? VS2017中缺少Win32控制台应用程序。 如何创建C ++空项目? - Win32 Console Application missing in VS2017. How to create C++ Empty Project? 将MFC gui添加到Win32 C ++命令行应用程序的好方法是什么? - What is a good way to add MFC gui to a Win32 C++ command line application? 我如何决定对新的 C++ 项目使用 ATL、MFC、Win32 还是 CLR? - How do I decide whether to use ATL, MFC, Win32 or CLR for a new C++ project? 向安装项目Win32应用程序Visual Studio添加依赖项 - Adding dependencies to a setup project Win32 application Visual Studio 如何在 Win32 应用程序中通过 C++/MFC 在鼠标 cursor 上显示动态文本 - How do I display dynamic text at the mouse cursor via C++/MFC in a Win32 application 什么是Visual C ++中的Win32项目? - What is win32 project in visual c++? 是Visual C ++ Win32还是MFC C ++? - Visual C++ Win32 or MFC C++?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM