問題已經解決,今天有點發癲了。
原因如下,是因為在建立工程的時候,把下面這個勾沒有帶:
如果要在現在已經存在的工程上面修改的話,需要使用到比較工具合入下面的代碼,解決方案如下:
1、在類Cxxxapp比如CMFCApplication1App的初始化函數InitInstance()裡面添加如下東西
在CWinAppEx::InitInstance();之前寫入:
// 如果一個運行在 Windows XP 上的應用程式資訊清單指定要// 使用 ComCtl32.dll 版本 6 或更高版本來啟用可視化方式,//則需要 InitCommonControlsEx()。否則,將無法建立視窗。INITCOMMONCONTROLSEX InitCtrls;InitCtrls.dwSize = sizeof(InitCtrls);// 將它設定為包括所有要在應用程式中使用的// 公用控制項類。InitCtrls.dwICC = ICC_WIN95_CLASSES;InitCommonControlsEx(&InitCtrls);
然後在:
CWinAppEx::InitInstance();// Initialize OLE librariesif (!AfxOleInit()){AfxMessageBox(IDP_OLE_INIT_FAILED);return FALSE;}
之後,補上這句:
AfxEnableControlContainer();
2、修改標頭檔:stdafx.h,添加這一段:
#include <afxdisp.h> // MFC 自動化類
#ifdef _UNICODE#if defined _M_IX86#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")#elif defined _M_X64#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")#else#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")#endif#endif
直接搞定!
問題描述如下:
windows 7的:
windows 經典的: