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

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

本文关键字:应用程序 项目 2008 Win32 中的 Visual 添加 MFC      更新时间:2023-10-16

我已经花了大部分时间试图弄清楚为什么会发生这个错误,但它继续使我感到惊讶。

我在Visual C 中创建了一个控制台应用程序,并创建了一个MFC应用程序。......

我添加了AFX标头文件,设置配置设置。

我想知道从winmain()还是int main()中的起点是从哪里开始?有例子吗?给我一些链接来知道。解决方案预先感谢您。

创建基于MFC对话框的应用程序。项目 - 属性 - 配置工作人员 - 链接器 - 高级 - 入口点,设置wwinmaincrtstartup(假设该项目是Unicode)。链接器 - 系统 - 选择控制台。构建应用程序。现在它打开控制台窗口和对话框。

添加一些逻辑。例如,在我的应用程序类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;
}

现在运行应用程序。如果您在控制台窗口中回答" Y",则显示对话框。否则,申请立即退出。根据此样本实现自己的逻辑。