• 大小: 24KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-06-16
  • 语言: 其他
  • 标签: Duilib  gif  

资源简介

让Duilib完美支持gif,GDI+实现,支持文件或zip,资源加载。

资源截图

代码片段和文件信息

#include “StdAfx.h“

namespace DuiLib {

CDialogBuilder::CDialogBuilder() : m_pCallback(NULL) m_pstrtype(NULL)
{

}

CControlUI* CDialogBuilder::Create(STRINGorID xml LPCTSTR type IDialogBuilderCallback* pCallback 
                                   CPaintManagerUI* pManager CControlUI* pParent)
{
//资源ID为0-65535,两个字节;字符串指针为4个字节
//字符串以<开头认为是xml字符串,否则认为是xml文件

    if( HIWORD(xml.m_lpstr) != NULL ) {
        if( *(xml.m_lpstr) == _T(‘<‘) ) {
            if( !m_xml.Load(xml.m_lpstr) ) return NULL;
        }
        else {
            if( !m_xml.LoadFromFile(xml.m_lpstr) ) return NULL;
        }
    }
    else {
        HRSRC hResource = ::FindResource(CPaintManagerUI::GetResourceDll() xml.m_lpstr type);
        if( hResource == NULL ) return NULL;
        HGLOBAL hGlobal = ::LoadResource(CPaintManagerUI::GetResourceDll() hResource);
        if( hGlobal == NULL ) {
            FreeResource(hResource);
            return NULL;
        }

        m_pCallback = pCallback;
        if( !m_xml.LoadFromMem((BYTE*)::LockResource(hGlobal) ::SizeofResource(CPaintManagerUI::GetResourceDll() hResource) )) return NULL;
        ::FreeResource(hResource);
        m_pstrtype = type;
    }

    return Create(pCallback pManager pParent);
}

CControlUI* CDialogBuilder::Create(IDialogBuilderCallback* pCallback CPaintManagerUI* pManager CControlUI* pParent)
{
    m_pCallback = pCallback;
    CMarkupNode root = m_xml.GetRoot();
    if( !root.IsValid() ) return NULL;

    if( pManager ) {
        LPCTSTR pstrClass = NULL;
        int nAttributes = 0;
        LPCTSTR pstrName = NULL;
        LPCTSTR pstrValue = NULL;
        LPTSTR pstr = NULL;
        for( CMarkupNode node = root.GetChild() ; node.IsValid(); node = node.GetSibling() ) {
            pstrClass = node.GetName();
            if( _tcscmp(pstrClass _T(“Image“)) == 0 ) {
                nAttributes = node.GetAttributeCount();
                LPCTSTR pImageName = NULL;
                LPCTSTR pImageResType = NULL;
                DWORD mask = 0;
                for( int i = 0; i < nAttributes; i++ ) {
                    pstrName = node.GetAttributeName(i);
                    pstrValue = node.GetAttributeValue(i);
                    if( _tcscmp(pstrName _T(“name“)) == 0 ) {
                        pImageName = pstrValue;
                    }
                    else if( _tcscmp(pstrName _T(“restype“)) == 0 ) {
                        pImageResType = pstrValue;
                    }
                    else if( _tcscmp(pstrName _T(“mask“)) == 0 ) {
                        if( *pstrValue == _T(‘#‘)) pstrValue = ::CharNext(pstrValue);
                        mask = _tcstoul(pstrValue &pstr 16);
                    }
                }
                if( pImageName ) pManager->AddImage(pImageName pImageResType mask);
            }
            else if( _tcscmp(pstrClass _T(“Font“)) == 0 ) {
                nAttribute

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      10901  2014-09-01 16:08  UIDefine.h

     文件      21324  2014-09-01 16:07  UIDlgBuilder.cpp

     文件       6347  2014-09-02 11:24  UIGifAnim.cpp

     文件        797  2014-09-01 19:25  UIGifAnim.h

     文件       3982  2014-09-01 16:07  UIlib.h

     文件      92507  2014-09-02 11:45  UIRender.cpp

     文件       2558  2014-09-02 11:27  UIRender.h

----------- ---------  ---------- -----  ----

               138416                    7


评论

共有 条评论