2010年10月18日 星期一

Manifest Style

從.Net 2005之後,AppWizard在產生MFC application時,多了[Common Control Manifest]的選項

使用Manifest產生的對話盒元件看起來比較圓滑舒服,不像之前的3D按鈕那樣的生硬,下圖左是使用Manifest產生的About對話盒,下圖右為傳統的Style。

使用Manifest的project,在stdafx.h中會多出一段碼:

#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

如果是使用Multi-Byte的project,即使選擇了Manifest,產生的對話盒元件就仍然是傳統型式。

事實上,我把#ifdef _UNICODE這行直接註解掉,Multi-Byte程式還是可以正常執行,而且對話盒就變成Manifest的Style了。所以,這段的UNICODE保護到底有沒有用仍然是個謎?

沒有留言:

張貼留言