winform使用mfc產生異常的解決方案

It replaces the entry-point with the "unmanaged" entry in CWinApp, which correctly initialize the CRT/MFC/ATL.

1. Change the "entry point" in you linker settings from "main" to "wWinMainCRTStartup"
2. Add "#include <afxwin.h>" to your "stdafx.h"
3. Replace your "main" method with the following:
class CMFCApp : public CWinApp
{
public:
virtual BOOL InitInstance()
{
    // Enabling Windows XP visual effects before any controls are created
    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault(false);
    // Create the main window and run it
    Application::Run(gcnew Form1());
    return FALSE;
}
} theApp;

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章