.NET Winform中,启用XP主题外观执行以下语句即可:
Application.EnableVisualStyles();
VC Win32项目,默认是不启用XP主题外观的,并不是每个人都喜欢简洁的Windows经典主题外观。
启用XP主题外观,需要用资源文件。有种更简单的方式:
头文件里加入以下语句:
#include
<
CommCtrl.h
>
#pragma comment(lib, "ComCtl32.Lib")
#pragma comment(linker, "/manifestdependency:/"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'/"")
#pragma comment(lib, "ComCtl32.Lib")
#pragma comment(linker, "/manifestdependency:/"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'/"")
在main函数最前面调用InitCommonControls函数:
int
APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
InitCommonControls();
MessageBox(NULL, L " Windows XP theme was enabled. " , L " http://www.xianfen.net " , 0 );
return 0 ;
}
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
InitCommonControls();
MessageBox(NULL, L " Windows XP theme was enabled. " , L " http://www.xianfen.net " , 0 );
return 0 ;
}
运行程序已经启用了XP主题外观,如图: