Windwos XP风格,对话框有半透明,圆角效果

来源:互联网 发布:淘宝助理与千牛的区别 编辑:程序博客网 时间:2024/06/05 19:28

一、XP风格

1)创建manifest文件,首先在RES目录下建一个文件,命名Master.manifest然后用记事本打开放入 

[html] view plaincopyprint?
  1. <?xmlversion="1.0"encoding="UTF-8"standalone="yes"?>  
  2. <assembly xmlns="urn:schemas-microsoft-com:asm.v1"manifestVersion="1.0">  
  3. <assemblyIdentity  
  4. name="Microsoft.Windows.XXXX"  
  5. processorArchitecture="x86"  
  6. version="5.1.0.0"  
  7. type="win32"/>  
  8. <description>Windows Shell</description>  
  9. <dependency>  
  10. <dependentAssembly>  
  11. <assemblyIdentity  
  12. type="win32"  
  13. name="Microsoft.Windows.Common-Controls"  
  14. version="6.0.0.0"  
  15. processorArchitecture="x86"  
  16. publicKeyToken="6595b64144ccf1df"  
  17. language="*"  
  18. />  
  19. </dependentAssembly>  
  20. </dependency>  
  21. </assembly> 
2,然后VC导入资源,把这个新建的文件导入,类型为24  

3,用记事本打开rc 文件, 找到自定义资源的地方,改成如下句子
IDR_MANIFEST 24 MOVEABLE PURE "res\\Master.manifest" ,MOVABLE PURE是一定不能少的。

4, 进入VC, 把这个自定义资源IDR_MANIFEST的ID改为1(没有引号) 


编译,,你的程序就有了XP的风格


二、对话框透明效果

在ONINITIALDIALOG中加入一下代码

[cpp] view plaincopyprint?
  1. //设置透明 
  2. HINSTANCE hInst = LoadLibrary("User32.DLL"); 
  3. if(hInst) 
  4. {  
  5.     ModifyStyleEx(0,0x00080000); 
  6.     typedef BOOL (WINAPI *MYFUNC)(HWND,COLORREF,BYTE,DWORD); 
  7.     MYFUNC fun = NULL; 
  8.     //取得SetLayeredWindowAttributes()函数指针 
  9.     fun=(MYFUNC)GetProcAddress(hInst, "SetLayeredWindowAttributes"); 
  10.     if(fun)fun(this->GetSafeHwnd(),0,220,2); 
  11.     FreeLibrary(hInst); 
那个 fun的第3个参数为ALPHA


三、对话框圆角特效

[cpp] view plaincopyprint?
  1. CRect rt;   
  2. this->GetWindowRect(&rt);   
  3. CRgn rg;   
  4. rg.CreateRoundRectRgn(rt.left, rt.top, rt.right, rt.bottom, 55, 55);   
  5. this->SetWindowRgn(rg, FALSE);    

原创粉丝点击