1。 在SkinMagic包里拷贝:SkinMagicLib.h、SkinMagicLib.lib、SkinMagicLib.dll 到当前的工作目录下
2。 在VC的Project目录下选择“Add To Project” 菜单的“Files...”。把这三个文件添加到工程中。
3。在Stdafx.h文件,添加:#include "SkinMagicLib.h"
关键的开始喽~
4。在你的***。cpp中首部添加
#include "SkinMagicLib.h"
#pragma comment(lib,"SkinMagic.lib") //注意这里的lib文件名要和你拷贝到工作目录里的一致哦
5。下面代码蓝色部分为添加代码,其他为MFC自动生成:
BOOL CAESApp::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
//add by jane
VERIFY(InitSkinMagicLib(AfxGetInstanceHandle(),NULL,NULL,NULL));
if(LoadSkinFromResource(AfxGetInstanceHandle(),(LPCTSTR)IDR_SKINMAGIC4,"SKINMAGIC"))
{
SetDialogSkin("Dialog");
}
//add by jane
CAESDlg 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
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
说明:
if(LoadSkinFromResource(AfxGetInstanceHandle(),(LPCTSTR)IDR_SKINMAGIC4,"SKINMAGIC"))中IDR_SKINMAGIC4即为你所设置的皮肤的资源名称,在工程resources中可以import一个资源名为SKINMAGIC,并将拷贝到当前工作目录下的。smf文件import到SKINMAGIC下,在这里我导入了多个。smf文件,我使用了第四个皮肤所以为IDR_SKINMAGIC4
另外:
int InitSkinMagicLib( //初始化SkinMagic工具库
HINSTANCE hInstance, //应用程序句柄
char* szApplication , //皮肤文件中定义的应用程序名,置为NULL即可
char* szRegCode, //SkinMagic的使用注册码。若无置为NULL
char* szReserved2 //保留位,为NULL
);
5。最后在**。cpp中添加如下代码:
int C**App::ExitInstance()
{
ExitSkinMagicLib();
return CWinApp::ExitInstance();
}
6。别忘了再申明中申明函数ExitInstance()
virtual int ExitInstance()
好啦 ,是不是有很漂亮的皮肤了呢,就是skinmagic会要求注册,所以在你的程序执行之前都会弹出它们要求注册的窗口,各位如果可以将就就将就吧,不行的话我们以后再讨论啦