对话框换肤

来源:互联网 发布:宝安西乡网络推广公司 编辑:程序博客网 时间:2024/06/02 16:52

在较新版本的BCGControlBar之中增加了对对话框和文档中窗体的form进行换肤。更改了一些控件的显示样式,其中有类似office 2007、office 2010 等等之类的皮肤。下面开始进行换肤,在此先要做好准备,必须安装有BCGControlBar(可以看这里的文章[url]http://blog.csdn.net/akof1314/archive/2010/03/20/5399928.aspx[/url] )

首先:利用BCG向导 建立一个基于对话框的程序,然后删去不需要的文件,如下图所示:
[attach]3328[/attach]
然后,因为我们这次要进行对话框换肤的界面为office 2007蓝色效果 ,所以我们在资源里面导入C:/Program Files/BCGSoft/BCGControlBarPro/BCGCBPro/Styles/BCGPStyle2007Aqua.rc,其他界面再对应加入即可。
接着,在对话框的初始化函数OnInitDialog() 中,加入以下代码
BOOL  CThe_Bcg_DialogDlg:: OnInitDialog()
{
    CBCGPDialog:: OnInitDialog();
    //```````````
    CBCGPVisualManager2007:: SetStyle ( CBCGPVisualManager2007:: VS2007_LunaBlue);
    CBCGPVisualManager:: SetDefaultManager ( RUNTIME_CLASS ( CBCGPVisualManager2007));
    EnableVisualManagerStyle();
    return  TRUE ;   // return TRUE  unless you set the focus to a control
}

接着,只要在对话框上放置自己想要的控件即可。下面分别是不同系统上的效果。
Windows 7系统下:
[attach]3330[/attach]
Windows XP系统下:
[attach]3329[/attach]
我们可以看到界面上的一些控件都变掉了,相对好看了些。但是在Windows XP下,标题栏显得特别不协调。如果想要在XP系统下也使标题栏达到换肤的话,请看下一篇《[url=http://blog.csdn.net/akof1314/archive/2010/05/14/5593802.aspx]BCGControlBar MFC对话框换肤(续)[/url] 》

原创粉丝点击