MFC程式更換XP皮膚

來源:互聯網
上載者:User

有兩種方法可以使vc6或者vc2003編譯出來的MFC程式具有XP的風格,當然這需要在Windows XP系統下運行。

 

方法一,使用外置的manifest描述檔案

在exe檔案所在目錄中建立一個同名的.manifest檔案。假設你有一個可執行檔app1.exe,則建立app1.exe.manifest。注意該檔案的檔案名稱是在exe的完整檔案名稱後加.manifest。該檔案的內容如下:

Code:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
   version="1.0.0.0"
   processorArchitecture="X86"
   name="Microsoft.Windows.dummy"
   type="win32"
/>
<description>Your app description here</description>
<dependency>
   <dependentAssembly>
   <assemblyIdentity
   type="win32"
   name="Microsoft.Windows.Common-Controls"
   version="6.0.0.0"
   processorArchitecture="X86"
   publicKeyToken="6595b64144ccf1df"
   language="*"
   />
   </dependentAssembly>
</dependency>
</assembly>

方法二,使用內建的manifest描述檔案

這種方法可以將manifest檔案編譯到exe檔案當中,發布的時候不需要額外增加一個.manifest檔案。
步驟如下:

首先,在程式的RES目錄下建一個檔案,命名xp.manifest,檔案內容為:

Code:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
   version="1.0.0.0"
   processorArchitecture="X86"
   name="Microsoft.Windows.dummy"
   type="win32"
/>
<description>Your app description here</description>
<dependency>
   <dependentAssembly>
   <assemblyIdentity
   type="win32"
   name="Microsoft.Windows.Common-Controls"
   version="6.0.0.0"
   processorArchitecture="X86"
   publicKeyToken="6595b64144ccf1df"
   language="*"
   />
   </dependentAssembly>
</dependency>
</assembly>

然後,在VC中匯入資源,匯入xp.manifest,類型為24,並且修改ID為IDR_MANIFEST。
最後,通過菜單View-Resources Symbol …或者直接修改resource.h,將IDR_MANIFEST的值改為1。

編譯後運行,程式就有xp的風格了。

 

PS:這裡我再多解釋一下,“1”代表資源ID,必須是“1”。“24”代表資源類型,我想我們對RT_ACCELERATOR、RT_BITMAP、RT_MENU、RT_STRING等資源都非常熟悉,而“24”實際上是RT_MANIFEST。

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.