请教ActiveSkin如何用?(200分相送)

解决方案 »

  1.   


    哈哈,小弟刚刚完成ActiveSkin的应用,请参照以下步骤:  1、安装Active Skin控件,如需要留下Email;(安装很简单)
      2、在VC中安装此控件: project->Add to Project->Commponents and control->Registered ActiveX Controls->ActiveSkin Control
      3、利用资源编辑器新建一个对话框,在对话框中插入ActiveSkin (在Control工具栏中,将其拖至对话框中则可)。
      4、在应用程序类的头文件中如下加入源码:
        
         #include "SkinDialog.h"
         //////////////////////////////////////////////////////
         // CWExam01App:
         // See WExam01.cpp for the implementation of this class
         //      class CWExam01App : public CWinApp
           {
             public:
    CWExam01App(); CSkinDialog m_dlgSkin;
    CComQIPtr<ISkin> m_pSkin; 
             ..............
       5、在应用程序中CPP文件 BOOL CWExam01App::InitInstance() 入如下源码  
          m_dlgSkin.Create(IDD_SKINDIALOG);
         // Tries to create an ActiveSkin control at startup
       m_pSkin = m_dlgSkin.GetDlgItem(IDC_SKIN)->GetControlUnknown();
    if (!m_pSkin)
    {
    MessageBox(NULL, "Can't create a Skin control. Make sure ActiveSkin is installed properly.", "Error", MB_ICONERROR | MB_OK);
    return false;
    }      6、利用ClassWizard为应用程序类加入消息函数ExitInstance() 
    int CWExam01App::ExitInstance() 
    {
    // TODO: Add your specialized code here and/or call the base class
    m_pSkin.Release(); // We need to release the reference to the Skin component prior destructor is called
    m_dlgSkin.DestroyWindow();
        
         return CWinApp::ExitInstance();
    }     7、在主窗口中可以通过消息响应函数来换肤:
    //======================================================================================
    //
    //                                      更换皮肤
    //
    //======================================================================================void CMainFrame::OnSkin() 
    {
    // TODO: Add your command handler code here
        CWExam01App *pApp=(CWExam01App *)AfxGetApp(); static char BASED_CODE szFilter[] = "ActiveSkin Files (*.skn)|*.skn||";
    CFileDialog dlg(FALSE, ".skn", NULL, OFN_HIDEREADONLY, szFilter);
    if (dlg.DoModal() == IDOK)
    {
    USES_CONVERSION;
    pApp->m_pSkin->LoadSkin(T2W(dlg.GetPathName()));
    pApp->m_pSkin->ApplySkin((long)m_hWnd);

               
    }

    }
        8、在对话框中若换肤可采用如下语句(以About Dialog为例)
    BOOL CAboutDlg::OnInitDialog() 
    {
    CDialog::OnInitDialog();

    // TODO: Add extra initialization here
    CWExam01App *pApp=(CWExam01App *)AfxGetApp();
    pApp->m_pSkin->ApplySkin((long)m_hWnd);    return TRUE;  // return TRUE unless you set the focus to a control
                  // EXCEPTION: OCX Property Pages should return FALSE
    }  老兄若有问题,欢迎保持联系。
      

  2.   

    以上为VC代码。
    若需 Delphi 代码请留邮箱。
      

  3.   

    我的邮箱为: [email protected]请你发delphi的。
      

  4.   

    您所做的工作为:
    1、安装控件。2、在主窗体中加入Skin1:TSkin 在窗体中的OnShow函数中加入如下代码。  //........
      Skin1.LoadSkin(CurrentPath+'Skin\Green.skn');  
                     //CurrentPath+'Skin\Green.skn'为 皮肤文件路径。
      Skin1.ApplySkin(Handle);
      //......3、在对话框中若更改皮肤可以在对话框的OnShow函数中
      加入如下代码:
       MainFrame.Skin1.ApplySkin(Handle);    若有问题欢迎与我联系。