今天在网上偶得 SkinBeauty 换肤为,想拿来测试一下,
环境: vs 2005,Unicode,
步骤如下:新建对话框工程,CtestAPP在 stdafx.h 中,导入库文件/////stdafx.h
.....
......
#include "global.h"
#include  "SkinBeautyExport.h"
#include "ExtendClass\\BeautyGroupCtrlEx.h"
#pragma  comment(lib,"SkinBeauty.lib")
.....
...
//库文件对应的导出接口为:
=========================================================SkinBeautyExport.h=============================================
#ifndef __SKINBEAUTY__EXPORT__H__
#define __SKINBEAUTY__EXPORT__H__#ifdef SKINBEAUTY_LIB_EXPORT
#define SKINBEAUTY__API extern "C" __declspec(dllexport)
#else
#define SKINBEAUTY__API extern "C" __declspec(dllimport)
#endif
//the Windows control typed by ID
//控件窗口类型编号
#define  TYPE_UNKNOWN  -1
#define  TYPE_BUTTON   1
#define  TYPE_EDIT                    2
#define  TYPE_COMBOBOX                3
#define  TYPE_SCROLLBAR               4
#define  TYPE_LISTBOX                 5
#define  TYPE_STATIC                  6
#define  TYPE_RADIO                   7
#define  TYPE_CHECK                   8
#define  TYPE_DLG                     9
#define  TYPE_PROGRESS                10
#define  TYPE_MENU           11
#define  TYPE_SPIN   12
#define  TYPE_SLIDER       13
#define  TYPE_GROUP                   14
#define  TYPE_TREECTRL                15
#define  TYPE_LISTCTRL                16
#define  TYPE_TOOLTIPCTRL             17
#define  TYPE_HEADCTRL                18
#define  TYPE_IPCTRL                  19
#define  TYPE_HOTKEY                  20
#define  TYPE_RICHEDIT                21#define  TYPE_ANIMATECTRL             22
#define  TYPE_TABCTRL                 23
#define  TYPE_MONTHCALCTRL            24
#define  TYPE_DATETIMECTRL            25
#define  TYPE_STATUSBAR               26#define  TYPE_TOOLBAR                 27
#define  TYPE_REBAR                   28
#define  TYPE_CONTROLBAR              29
#define  TYPE_FRAMEWND                30#define  TYPE_MINI_FRAMEWND           31//
////  Load & UnLoad Skin               Fun.Group
////load the skin with a skin-file from a path.
//[IN]:absolute file path 
SKINBEAUTY__API BOOL SkinLoad(char* szSkinPath);//
//unload the skin. 
//
//COMMENT: normally, it's unnecessory to call this function,
//just when the user expect to force the process to unload the skin.
//the Skin-Engine will automatically unload itself before exit.
//
SKINBEAUTY__API BOOL SkinUnLoad(void);//
////  User Config                      Fun.Group
////build the unSkin-Ctrl-List by Ctrl's type or ID. 
//[IN]:the count of Ctrl type/ID that to be set; Ctrl type/ID array
SKINBEAUTY__API void BuildUnSkinCtrlType(int nCount, int aCtrlType[]);
SKINBEAUTY__API void BuildUnSkinCtrlID(int nCount, DWORD aCtrlID[]);
//bind a skin_resource with a Ctrl by Ctrl ID or by handle
//[IN]:user resource define in the skin-file; the ID/handle of Ctrl to be set 
SKINBEAUTY__API void BindRes2CtrlbyID(int nUserResID,DWORD dwCtrlID);
SKINBEAUTY__API BOOL BindRes2CtrlbyHWND(int nUserResID,HWND hWnd);
//is skin the owner/custom-draw style ctrl?  get and set the Flag 
SKINBEAUTY__API BOOL GetIsSkinOwnerDrawCtrl(void);
SKINBEAUTY__API void SetSkinOwnerCrawCtrl(BOOL bSkin);
//
//all the functions above are very easy to understand it's usage
//for more detail, U could see the help-files adhere with the product,
// www.afe-soft.com
//
#endif //__SKINBEAUTY__EXPORT__H__
//                     另外还有三个头文件,分别为
=================================================BeautyGroupCtlEx.h===========================
#ifndef AFX_BEAUTYGROUPCTRLEX_H__FBI_MAN__INCLUDED_
#define AFX_BEAUTYGROUPCTRLEX_H__FBI_MAN__INCLUDED_#ifdef SKINBEAUTY_LIB_EXPORT
#define SKINBEAUTY__CLASS    __declspec(dllexport)
#else
#define SKINBEAUTY__CLASS    __declspec(dllimport)
#endif//********************************************************************
//*****************************NOTICE*********************************
//the extend-class is  bad-designed, with bad-mechanism,
//without any tested. it's just for a demo only,
//and the extend-class just in demo/test-Debug-version,
//if you(client) want, we could send you the source.
//********************************************************************
//********************************************************************#include <vector>
using std::vector;#define  CLASSNAME_GQGROUPCTRL       _T("SKIN_BEAUTY_GROUPCTRL_EX")    
#define  WM_GROUPCTRL_RBUTTONUP  666// 组信息结构
class TGroupInfo
{
public:
TGroupInfo():m_szName(_T("")), m_pWnd(NULL){}
virtual ~TGroupInfo(){}
public:
CString m_szName; // 组名称
CWnd *m_pWnd; // 组窗口指针
};// 分组控件
class SKINBEAUTY__CLASS CBeautyGroupCtrlEx : public CWnd
{
// Construction
public:
CBeautyGroupCtrlEx();// Implementation
public:
virtual ~CBeautyGroupCtrlEx(); // Generated message map functions
protected:
//{{AFX_MSG(CBeautyGroupCtrlEx)
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
afx_msg void OnPaint();
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnDestroy();
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
public:
const unsigned short * GetItemText(int iIndex); // 获取指定索引组的名称
const unsigned short * GetSelectText(); // 获取当前选中的组名
void SetMsgWnd(CWnd *pMsgWnd); // 设置消息处理窗口
void SetFontColor(COLORREF clrFont); // 设置前景色
virtual BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT &rect,
CWnd *pParentWnd, UINT uID);
bool AddOneGroup(TCHAR* szName, CWnd *pWnd = NULL); // 添加一组
bool SetCurGroup(int iIndex); // 设置当前组,通过索引
bool SetCurGroup(TCHAR* szName); // 设置当前组,通过名称
static bool LoadFace(TCHAR* szNormal, TCHAR* szOver, TCHAR* szDown); // 加载皮肤
void EnableBorder(BOOL bHaveBorder); // 显示边框色
void SetBorderColor(COLORREF clrBorder); // 设置边框色
void SetBackColor(COLORREF clrBack); // 设置背景色
protected:
void DrawGroupText(CDC *pDC, CString szName, CRect rtRect); // 画组名称
BOOL RegisterWindowClass(); // 注册窗口类
void DrawCtrl(CDC *pDC); // 画控件
void DrawBorders(CDC *pDC); // 画控件边框
void DrawBack(CDC *pDC); // 画控件背景
void DrawGroups(CDC *pDC); // 画所有组
void DrawOneGroupNormal(CDC *pDC, CRect &rtRect); // 画一个正常状态下的组
void DrawOneGroupOver(CDC *pDC, CRect &rtRect);      // 画一个鼠标over下的组
void DrawOneGroupDown(CDC *pDC, CRect &rtRect); // 画一个鼠标按下的组
void GetIndexRect(int iIndex, CRect &rRect); // 获取指定索引的矩形坐标
void ChangeSize(); // 窗体变化处理函数
void HandleDestroy(); // 窗体销毁处理函数
void SetOver(int iIndex); // 设置当前Over的索引
void SetDown(int iIndex); // 设置当前鼠标按下的索引
private:
BOOL m_bHide; // 2次点击同一个按钮隐藏或显示窗口
vector<TGroupInfo*> m_vecGroups; // 组信息列表
int m_iOver; // 当前over的索引
int m_iDown; // 当前鼠标按下的索引
int m_iSel; // 当前被展开的组索引
COLORREF m_clrFont; // 字体颜色
COLORREF m_clrBack; // 背景色
COLORREF m_clrBorder; // 边框色
BOOL m_bHaveBorder; // 是否有边框
static CBitmap * m_pbmpNormal; // 正常状态下组的背景
static  CBitmap * m_pbmpOver; // 鼠标over时的组的背景
static CBitmap * m_pbmpDown; // 鼠标按下的组的背景
CRect m_rtClient; // 客户区大小
CWnd *m_pMsg; // 消息处理窗口
CWnd                *m_selfWnd;                                 //记录自己的窗口
void OnNodeLDBDown(WPARAM wParam, LPARAM lParam); virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
};#endif //AFX_BEAUTYGROUPCTRLEX_H__FBI_MAN__INCLUDED_

解决方案 »

  1.   

    ============================================================BeautyTabCtrl.h=====================================
    #ifndef AFX_BEAUTYTABCTRLEX_H__FBI_MAN__INCLUDED_
    #define AFX_BEAUTYTABCTRLEX_H__FBI_MAN__INCLUDED_
    #ifdef SKINBEAUTY_LIB_EXPORT
    #define SKINBEAUTY__CLASS    __declspec(dllexport)
    #else
    #define SKINBEAUTY__CLASS    __declspec(dllimport)
    #endif//********************************************************************
    //*****************************NOTICE*********************************
    //the extend-class is  bad-designed, with bad-mechanism,
    //without any tested. it's just for a demo only,
    //and the extend-class just in demo/test-Debug-version,
    //if you(client) want, we could send you the source.
    //********************************************************************
    //********************************************************************#include <deque>
    using std::deque;#define  CLASSNAME_LEFT_TAB_EX       _T("SKIN_BEAUTY_TAB_EX")   class TTabInfo
    {
    public:
    TTabInfo()
    {
    m_szTip = _T("");
    m_szTab = _T("");
    m_hIcon = NULL;
    m_pWnd = NULL;
    m_iTip = -1;
    }
    virtual ~TTabInfo()
    {
    if (m_hIcon)
    {
    DeleteObject(m_hIcon);
    m_hIcon = NULL;
    }
    }
    public:
    int m_iTip;
    CString m_szTip;
    CString m_szTab;
    HICON m_hIcon;
    CWnd *m_pWnd;
    };class  SKINBEAUTY__CLASS CBeautyTabCtrlEx : public CWnd
    {
    // Construction
    public:
    CBeautyTabCtrlEx();
    virtual ~CBeautyTabCtrlEx();public:
    void SetBorderColor(COLORREF clrBorder); // 设置边框色
    void SetTabBack(COLORREF clrBack); // 设置tab背景色
    static void LoadTabBmps(TCHAR* szNormal, TCHAR* szOver, TCHAR* szSel);     // 加载tab图片
    BOOL CreateTab(CRect rtTab, CWnd *pParent, UINT uID); // 建立tab控件
    BOOL AddOneTab(CWnd *pWnd, TCHAR* szTitle, HICON hIcon, TCHAR* szTip=NULL); // 添加一个tab页面
    void GetCurTabRect(int iIndex, CRect &rtTab); // 获取指定索引tab的矩形protected :
    CString ASCIIToUnicode(CString szTemp); // 从ascII到Unicode的转化
    void DrawColorTabs(CDC *pDC); // 画颜色tab
    void DrawDownText(CDC *pDC, CRect rtText, CString szText); // 画竖形文本

    // Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CBeautyTabCtrlEx)
    public:
    virtual BOOL PreTranslateMessage(MSG* pMsg);
    protected:
    virtual void PreSubclassWindow();
    //}}AFX_VIRTUALprotected:
    void SetOver(int iIndex); // 设置over索引
    void SetCur(int i); // 设置当前tab页面
    void DrawContent(CDC *pDC, CRect rtTab, CString szTxt, BOOL bHaveIcon = FALSE); // 画文本
    void DrawIcon(CDC *pDC, CRect rtTab, HICON hIcon); // 画图标
    void DrawBmp(CBitmap *pBmp, CDC *pDC, RECT rtWnd); // 画位图
    void ChangeSize(); // 窗体变化处理函数
    void DrawTabs(CDC *pDC); // 画所有tab
    void DrawBorder(CDC *pDC); // 画边框
    //{{AFX_MSG(CBeautyTabCtrlEx)
    afx_msg BOOL OnEraseBkgnd(CDC* pDC);
    afx_msg void OnPaint();
    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
    afx_msg void OnMouseMove(UINT nFlags, CPoint point);
    afx_msg void OnSize(UINT nType, int cx, int cy);
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    static  CBitmap  *m_pTabNormal;
    static  CBitmap  *m_pTabSel;
    static  CBitmap  *m_pTabOver;
    static  COLORREF m_clrNormHigh; // 亮色
    static  COLORREF m_clrNormLow; // 暗色
    static  COLORREF m_clrOverHigh;
    static  COLORREF m_clrOverLow;
    static  COLORREF m_clrSelHigh;
    static  COLORREF m_clrSelLow;private:
    deque<TTabInfo*>    m_dequeTab; // tab 数组
    int              m_iSel;            // 当前显示Tab;
    CRect            m_rtClient;        // 客户区矩形
    int              m_iTabWidth;       // tab宽度
    int              m_iTabHeight;      // tab高度
    int              m_iOver;           // 当前鼠标移过那个Tab
    CRect            m_rtTemp;
    int              m_iIconWidth;      // 显示图标的大小
    int              m_iFontSize; // tab字体的大小
    CFont            m_tFont;
    int              m_iStep; // 间距
    COLORREF         m_clrBack;
    COLORREF         m_clrLine;
    BOOL             m_bUseBmp;
    CToolTipCtrl  m_wndTip; // 工具栏提示
    };#endif //AFX_BEAUTYTABCTRLEX_H__FBI_MAN__INCLUDED_
      

  2.   

    ==========================================================BeautyTooCtl.h===============================
    #ifndef _AFX_BEAUTYTOOLBAREX_H__FBI_MAN__INCLUDED_
    #define _AFX_BEAUTYTOOLBAREX_H__FBI_MAN__INCLUDED_#ifdef SKINBEAUTY_LIB_EXPORT
    #define SKINBEAUTY__CLASS    __declspec(dllexport)
    #else
    #define SKINBEAUTY__CLASS    __declspec(dllimport)
    #endif//********************************************************************
    //*****************************NOTICE*********************************
    //the extend-class is  bad-designed, with bad-mechanism,
    //without any tested. it's just for a demo only,
    //and the extend-class just in demo/test-Debug-version,
    //if you(client) want, we could send you the source.
    //********************************************************************
    //********************************************************************
    #define  CLASSNAME_BEAUTYTOOLBAREX       _T("SKIN_BEAUTY_TOOLBAR_EX")  
      
    #include <vector>
    using std::vector;// 每个按钮的信息
    class TButtonInfo
    {
    public:
    TButtonInfo(): m_szText(_T("")), m_uID(0),
    m_uImage(-1), m_bIsChecked(FALSE), m_bEnabled(TRUE), m_bLine(FALSE){}
    virtual ~TButtonInfo(){}
    public:
    CString m_szText; // 按钮上的文本
    UINT m_uID; // 按钮对应的命令ID
    int    m_uImage; // 按钮对应的图标索引 -1, 表示没有图标
    BOOL m_bIsChecked; // 按钮是否显示按下状态
    BOOL m_bEnabled; // 按钮是否是可用状态
    BOOL m_bLine; // 是否是分割线
    int         m_nTextLen;                                     //记录文本的char*形态长度
    };class SKINBEAUTY__CLASS CBeautyToolBarEx : public CWnd
    {
    // Construction
    public:
    CBeautyToolBarEx();
    virtual ~CBeautyToolBarEx();
    protected:
    //{{AFX_MSG(CBeautyToolBarExImp)
    afx_msg void OnMouseMove(UINT nFlags, CPoint point);
    afx
    DECLARE_MESSAGE_MAP()public:
    void SetTransparent(BOOL bTrans);
    void SetBorderColor(COLORREF clrBorder); // 设置边框色
    void AddOneLine(); // 加一个分割线
    void SetMsgParent(CWnd *pParent); // 设置消息处理窗口
    virtual BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT &rect,
    CWnd *pParentWnd, UINT uID); // 创建
    void SetBackColor(COLORREF clrBack); // 设置背景色
    void SetLineColor(COLORREF clrTop, COLORREF clrBottom); // 设置边框色
    void SetTextAlign(UINT uAlgin); // 设置对齐方式
    void SetImageList(int iHeight, CImageList *pImage); // 设置图像列表
    void AddOneButton(UINT uID, char* szText, int iImage=-1); // 添加一个按钮
    bool EnableButton(UINT uID, BOOL bEnable); // 设置制定ID的灰化状态protected:
    void DrawOneLine(CDC *pDC, int iIndex); // 画分割线
    BOOL RegisterWindowClass(); // 注册窗口类
    void // 在鼠标按下没有释放时该值为true};
    #endif // _AFX_BEAUTYTOOLBAREX_H__FBI_MAN__INCLUDED_
    ===================================================================
    我想着,这三个头文件,是从lib文件中,导出来的类
    ====================================================我在 应用程序的 .cpp文件中 的=========================================
    //
    CtestApp::InitInstance()
    {
            //初始化控件
    CString strPath;
    CString strFilename;
    strPath = GetModulePath();
            .......
    szNormal = strPath +_T("\\skin\\btn_normal.bmp");
    szOver   = strPath +_T("\\skin\\btn_over.bmp");
    szDown   = strPath +_T("\\skin\\btn_down.bmp"); CBeautyGroupCtrlEx::LoadFace(szNormal.GetBuffer(0), szOver.GetBuffer(0), szDown.GetBuffer(0));
    }
    //当编译的时候,提示 
    CBeautyGroupCtrlEx::LoadFace  是无效的符号,
    于是,我式着 extern "C" CBeautyGroupCtrlEx::LoadFace(...);
    确说是重复定义,
    到此卡住了,请高手指点,
    但是此库在给的示例中运行正常,示例下载地址是:
    http://www.afe-soft.com/download/BeautyQQ_source.rar
    郁闷一天了,同学告诉我可能是 VC6下的dll,在vs2005下用,版本的问题,
    可我不理解,既然发行出来,厂商应该测试过的.不好意思,太长了
      

  3.   

    另外的帖子已经回复过了,导出类的dll是不通用的东西,建议使用同一个版本的编译器.
      

  4.   

    珍爱生命 远离导出类的dll