如何更改VC ++应用程序的视觉外观类似于Windows 7

问题描述:



我一直在将旧的VC ++ 6.0应用程序迁移到Windows 7的Visual Studio2005.它运行良好.我已经用谷歌搜索并将以下代码添加到"StdAfx.h",以将用户界面更改为类似于Windows 7的界面,

Hi,

I have been migrating my old VC++ 6.0 application to Visual Studio 2005 for Windows 7. It''s Functioning well. I have googled and added the below code to "StdAfx.h" to change the UI look like windows 7,

#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")



但是,对话框,工具栏和菜单栏的背景仍然是相同的旧样式.我想使整个应用程序具有win 7的外观.有什么方法可以将win 7主题应用于整个应用程序????



But, Still the background of dialog boxes,toolbar and menu bars are in the same old style. I want to make the entire application with win 7 look and feel. is there any way to apply the win 7 theme for the entire application????

我想您的控件需要XP样式的控件.要获得XP样式的控件,您必须执行以下操作.
在StdAfx.h中添加以下行.

I guess you need XP-style controls for your controls. To get XP-Style controls, you have to do the following things.
In StdAfx.h add the following lines.

#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_IA64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' 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



而App类的InitInstance()应该调用InitCommonControlsEx().



And InitInstance() of App class you should call InitCommonControlsEx().

App::InitInstance()
{
	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);
}



http://msdn.microsoft.com/zh-我们/library/windows/desktop/bb773175%28v=vs.85%29.aspx



http://msdn.microsoft.com/en-us/library/windows/desktop/bb773175%28v=vs.85%29.aspx