利用AppFace美化VC程序(对话框或文档视图结构)

    到 http://www.appface.com 去下载AppFace的安装程序,安装好后,你会发现它的include文件夹下有个appface.h文件,lib文件夹下有appface.libappfaceu.libUNICODE版本),并且在 skins文件夹的子文件(basicpowerful)下有以.urf皮肤文件,这三(四)个文件都是我们将要用到的。

下面我讲讲怎么把它加入到我们的程序中

1。首先我建立自己的程序这里我用建立Skin的对话框程序。保证能正常运行

2。将appface.h文件复制到MFC对话框程序的源文件文件夹下,(这里是myproject\skin\skin),同时在应用类的实现文件“工程名.cpp”或StdAfx.h中添加#include "appface.h"引用,

3。现在我们要添加工程对.lib库文件的引用 ,在VC中选择project->Add to Project->File选择appface.lib和appfaceu.lib,将他添加到工程中。

4。最后就是使用皮肤文件了,现在你把appface下skins\basic_urf文件夹下的*.urf皮肤文件拷贝到你的工程下的res目录下

5。现在在程序的CSkinApp::InitInstance()中添加这个函数

SKINSTART(_T("res\\onion_af.urf"), WINDOW_TYPE_VC, NULL, GTP_LOAD_FILE, NULL, NULL);

添加位置在

#ifdef _AFXDLL

    Enable3dControls();  // Call this when using MFC in a shared DLL

#else

    Enable3dControlsStatic();   // Call this when linking to MFC statically

#endif

之下

这里是使用皮肤文件,现在运行程序就能出现美化后的程序了

6。不过官方文件上说,要在上面代码的后面加上SkinRemove() 函数来清理,否则会内存泄漏的!!!!

if (nResponse == IDOK)
{
   // TODO: Place code here to handle when the dialog is
   // dismissed with OK
}
else if (nResponse == IDCANCEL)
{
   // TODO: Place code here to handle when the dialog is
   // dismissed with Cancel
}


//--------------------------------------------------
//For AppFace
//Line 2 , cleanup
SkinRemove() ;

到这里,现在运行程序,程序是不是比原来要好看多了呀

我这里使用的是静态链接库方法,动态的还在试,呵呵

 

应用类的InitInstance()函数实现的示例代码如下:

BOOL CSampleMFCApp::InitInstance()

{

    AfxEnableControlContainer();

 

    // Standard initialization

    // If you are not using these features and wish to reduce the size

    //  of your final executable, you should remove from the following

    //  the specific initialization routines you do not need.

 

#ifdef _AFXDLL

    Enable3dControls();         // Call this when using MFC in a shared DLL

#else

    Enable3dControlsStatic();   // Call this when linking to MFC statically

#endif

 

    //--------------------------------------------------

    //For AppFace

    //Line 1  , load the skin

    SkinStart(_T("..\\..\\skins\\basic_urf\\belv_af.urf"),WINDOW_TYPE_VC,"",GTP_LOAD_FILE,NULL,NULL);

    //--------------------------------------------------

 

    CSampleMFCDlg dlg;

    m_pMainWnd = &dlg;

    int nResponse = dlg.DoModal();

    if (nResponse == IDOK)

    {

        // TODO: Place code here to handle when the dialog is

        //  dismissed with OK

    }

    else if (nResponse == IDCANCEL)

    {

        // TODO: Place code here to handle when the dialog is

        //  dismissed with Cancel

    }

 

    //--------------------------------------------------

    //For AppFace

    //Line 2  , cleanup

    SkinRemove() ;

    //--------------------------------------------------

 

    // Since the dialog has been closed, return FALSE so that we exit the

    //  application, rather than start the application's message pump.

    return FALSE;

}

注意:

(1)在单文档视图类程序中,要在view类的实现文件“含对话框的单文档View.cpp”

中添加#include "appface.h",在view类的初始化函数OnInitialUpdate()中加载皮肤:

SKINSTART(_T("res\\pipe_af.urf"), WINDOW_TYPE_VC, NULL , GTP_LOAD_FILE, NULL, NULL);在响应WM_DESTROY的函数OnDestroy()中移除皮肤:

SkinRemove();

(2)多文档视图结构中和单文档视图中相同,不过要是在视图类的OnDestroy()函数中是否皮肤的话,关闭视图时则皮肤会消失。所以目前我还不清楚该在哪里释放皮肤。

你可能感兴趣的:(null,application,文档,mfc,dialog,initialization)