VC++6 實現介面使用XP風格
看到有人需要這個東西,在英文下有很多文章,中文搜尋發現不是很好,因此特意介紹下。
1.實現原理
微軟為Windows
XP提供了Themes服務。Themes可以讓程式具有“XP風格”,看起來更美觀,因為微軟更新了Comctl32.dll(ver
6.0)這個“XP風格”的控制項。微軟還為了保留傳統的Windows介面風格,特地留下了Comctl32.dll v5.8。VC6的推出時間早於WinXP,因此VC6的程式預設是不使用“xp風格”的。
程式使用xp風格主要是內建了manifest這東東。因此只要讓VC6的程式中包含即可。包含可以外置,也可以內建為資源。
2.實現方法:
1.開啟你的VC6 工程,找到資源試圖(ResourceView),然後在視圖中的樹的根結點上點滑鼠右鍵,選擇菜單“插入(Insert)”。
2.在彈出的“插入資源(Insert Resource)”對話方塊中選擇“Custom”,在新對話方塊(“New Custom Resource”)輸入框中輸入 24。 因為manifest的類型是24, 點擊“OK”按鈕。
3.在資源檢視的樹上面選擇24下方的條目“DDR_DEFAULT1”上點右鍵,選擇“Properties”,將ID:修改為1.
4.雙擊剛才修改的“1”條目,然後在右方的編輯器視窗中輸入下面的代碼:
- <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
- <assembly
- xmlns="urn:schemas-microsoft-com:asm.v1"
- manifestVersion="1.0">
- <assemblyIdentity
- processorArchitecture="x86"
- version="5.1.0.0"
- type="win32"
- name="test.exe"/>
- <description>Test Application</description>
- <dependency>
- <dependentAssembly>
- <assemblyIdentity
- type="win32"
- name="Microsoft.Windows.Common-Controls"
- version="6.0.0.0"
- publicKeyToken="6595b64144ccf1df"
- language="*"
- processorArchitecture="x86"/>
- </dependentAssembly>
- </dependency>
- </assembly>
5.儲存工程,重新編譯
附,前後對比圖: