Duilib是一个Windows下免费开源的DirectUI界面库

Related tags

GUI duilib
Overview

Duilib

Duilib是一个Windows下免费开源的DirectUI界面库,由于简约易扩展的设计以及稳定高效的实现被各大互联网公司普遍接受,广泛应用于包括IM、视频客户端、股票行情软件、导航软件、手机辅助软件、安全软件等多个行业的众多pc客户端软件。Duilib还在不断的发展中,在文档、例子、动画、渲染引擎等多个方面将持续改进。

欢迎为Duilib提供功能改进、代码修补、bug反馈、使用文档和献计献策,让我们一起把Duilib做的更好!

快速安装

您可以使用vcpkg库管理器下载并安装duilib:

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install duilib

vcpkg中的duilib库由Microsoft团队成员和社区贡献者保持最新状态。如果版本过时,请在vcpkg存储库上创建问题或请求请求

基于Duilib的软件不完全列表

Duilib自2010年8月21日发布以来,获得了众多开发者和大公司的信赖,在各行各业的软件中得到了广泛应用,以下是一个作者知道不完全列表,欢迎大家补充指正 https://github.com/duilib/duilib/wiki/%E5%9F%BA%E4%BA%8EDuilib%E7%9A%84%E8%BD%AF%E4%BB%B6%E4%B8%8D%E5%AE%8C%E5%85%A8%E5%88%97%E8%A1%A8

下面两个修改版本大家可以参考一下

腾讯使用的的duilib修改版

https://github.com/tencentyun/TIMSDK/tree/master/cross-platform/Windows/IMApp/Basic/duilib

网易使用的duilib修改版

https://github.com/netease-im/NIM_Duilib_Framework/tree/master/duilib

Comments
  • Is there something similar to SetWindowText to work with duilib

    Is there something similar to SetWindowText to work with duilib

    Hello.

    First - this is an AMAZING project. kudus!. Second - Is there anything similar/equivalent to SetWindowText or WM_SETTEXT that works on Applications created with duilib?

    Thanks in advance! 😄

    Apologies for not writing in Chinese...

    opened by itsho 9
  • Layered=true时,在CRichEditUI中

    Layered=true时,在CRichEditUI中"文本被选中的位置",点右键,无法收到DUI_MSGTYPE_MENU消息;文本不选中的位置则正常。

    有2个关于CRichEditUI事情。

    首先: 说明下,窗口是Layered=true的。

    第一: 就是标题里说的。CRichEditUI中,文本被选中的位置,点右键,就无法收到DUI_MSGTYPE_MENU消息。文本没有选中的位置点右键则正常收到DUI_MSGTYPE_MENU消息。

    第二: CRichEditUI中,全选或选择一部分文本后,插入光标不隐藏,还是在闪啊闪!

    配图: bug

    @juhuaguai @wangchyz @672399809

    opened by shithappens2016 6
  • 增加Style标签,可定义风格模板,强化Default标签

    增加Style标签,可定义风格模板,强化Default标签

    • 增加Style标签,可以通过$1、$2等占位符定义属性模板
    • Default,Style标签,支持各属性单独定义,不用放到在value属性的值中
      • Default或Style标签可定义folderattr,itemattr等复杂属性
      • width,height等属性也可单独定义,使得定义更直观,且定义内容过长时可以换行
    • 可以改变图像的source,dest的属性风格为left,top,width,height
    • 添加Style标签使用的xml配置示例(test_style.xml)

    详细请用法见test_style.xml,转义相关内容见前一个PR。 https://github.com/duilib/duilib/pull/76

    opened by slorelee 5
  • 增加Style类型,可为多个类似控件定义风格

    增加Style类型,可为多个类似控件定义风格

    • 增加Style类型,可为多个类似控件定义风格
    • 可以改变图像的source,dest的属性风格为left,top,width,height

    *使用方法如下:

    <Style imagerectstyle="l,t,w,h" /> ★没有name属性的Style元素才生效,此为全局风格
    <Style share="true" name="LTNavOpt" value="width=&quot;100&quot; height=&quot;60&quot; group=&quot;LTNav&quot; name=&quot;SM:LTNav:%s&quot; foreimage=&quot;file='Navi_%s.png' dest='26,0,48,48'&quot; selectedimage=&quot;color='#FF0000F0' dest='0,54,100,6'&quot; hotimage=&quot;color='#FF00F000' dest='0,54,100,6'&quot;" />
    
    <Option styleref="Favorite,Favorite" style="LTNavOpt" selected="true" />
    <Option styleref="Apps,Apps" style="LTNavOpt" />
    <Option styleref="Refresh,Refresh" style="LTNavOpt" />
    
    opened by slorelee 5
  • CDelegateBase::equal问题

    CDelegateBase::equal问题

    template <class O, class T> class CDelegate : public CDelegateBase的实现写的有问题

    实际equal的时候,比较的是CDelegateBase的m_pFn,而 CDelegateBase的m_pFn则是一个形参的栈地址,传入的时候之前是这么写的CDelegate(O* pObj, Fn pFn) : CDelegateBase(pObj, &pFn)

    我猜之前写这块的人不知道怎么转换指针类型,所以写的这么别扭 我自己修改的实现 template <class O, class T> class CDelegate : public CDelegateBase { typedef bool (T::* Fn)(void_); public: CDelegate(O_ pObj, Fn pFn) : CDelegateBase(pObj, (void_)&pFn) { } CDelegate(const CDelegate& rhs) : CDelegateBase(rhs) { } virtual CDelegateBase_ Copy() const { return new CDelegate(*this); }

    protected: virtual bool Invoke(void* param) { O* pObject = (O_) GetObject(); union { void_ ptr; Fn fn; }func = { GetFn() }; return (pObject->*func.fn)(param); }

    };

    opened by nustxujun 5
  • 使用资源压缩包并且皮肤目录有多个子文件夹要如何实现

    使用资源压缩包并且皮肤目录有多个子文件夹要如何实现

    需求有两点:

    • 使用资源压缩包的方式打包到程序中
    • 皮肤目录有多级目录分级方便管理,如下
    └─theme
        ├─about
        ├─login
        ├─messagebox
        ├─public
        └─settings
    

    about、login、messagebox、settings 都是单独的窗口,分别继承于 WindowImplBase 类。我不知道是自己使用有误还是代码目前无法实现。我试着实现了 GetSkinFolder 和一系列关于皮肤的函数,并设置每个窗口都使用资源压缩包(能否一次性设置?),却无法正确加载资源。先不说我调试的过程,因为这个带有自己的一些主观理解,可能是有误的。所以希望用过类似结构的朋友你们是如何实现的?

    opened by nmgwddj 4
  • RBG 误用,颜色格式和代码之间存在设计问题!

    RBG 误用,颜色格式和代码之间存在设计问题!

    代码里大量的误用 RGB 这个宏

    请注意这个宏是这样定义的:

    #define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))

    但本项目是这样用的:

    lg.lopnColor = RGB(GetBValue(dwPenColor), GetGValue(dwPenColor), GetRValue(dwPenColor));

    2013 年就发现这个 bug,至今都没改啊?

    opened by UMU618 4
  • [Duilib_Static] Add duilib static project

    [Duilib_Static] Add duilib static project

    • Added the duilib_static project to duilib solution.
    • Updated UIlib.h that added static library for duilib_static project.

    Signed-off-by: JiaJia [email protected]

    opened by nmgwddj 4
  • 如何使用图片实现窗口阴影效果?

    如何使用图片实现窗口阴影效果?

    我看到 duilib 的代码中已经集成了 CWndShadow 类,在提供的 test1 例子中也写了一个使用图片做阴影的例子。可移植到我的程序中时,就没有效果了,我的代码是这样写的。

    LRESULT CMainFrameWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
        __super::OnCreate(uMsg, wParam, lParam, bHandled);
    
        CWndShadow::Initialize(m_PaintManager.GetInstance());
        m_pWndShadow = new CWndShadow;
        m_pWndShadow->Create(m_hWnd);
    
    #if 0
        RECT rcCorner = { 5,5,5,5 };
        RECT rcHoleOffset = { 0,0,0,0 };
        m_pWndShadow->SetImage(_T("bg_main_shadow.png"), rcCorner, rcHoleOffset);
    #else
        m_pWndShadow->SetDarkness(80);
        m_pWndShadow->SetSize(4);
        m_pWndShadow->SetPosition(0, 0);
    #endif
    
        return 0;
    }
    

    CMainFrameWnd 继承于 WindowImplBase 类,其中使用 SetSize 方法并在 xml 中增加 roundcorner 描述,是可以让窗口显示阴影的,可当使用 SetImage 时就没有效果了,请问这是什么原因,要如何处理?

    opened by nmgwddj 4
  • Duilib_Static 项目编译后生成的 lib 库编译时报错

    Duilib_Static 项目编译后生成的 lib 库编译时报错

    报错内容如下,请问是什么原因?

    1>MainFrameWnd.obj : warning LNK4217: 本地定义的符号 ??0CDuiString@DuiLib@@QAE@XZ (public: __thiscall DuiLib::CDuiString::CDuiString(void)) 在函数 "protected: virtual class DuiLib::CDuiString __thiscall CMainFrameWnd::GetSkinFile(void)" (?GetSkinFile@CMainFrameWnd@@MAE?AVCDuiString@DuiLib@@XZ) 中导入
    1>MainFrameWnd.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __thiscall DuiLib::WindowImplBase::WindowImplBase(void)" (__imp_??0WindowImplBase@DuiLib@@QAE@XZ),该符号在函数 "public: __thiscall CMainFrameWnd::CMainFrameWnd(void)" (??0CMainFrameWnd@@QAE@XZ) 中被引用
    1>MainFrameWnd.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: virtual __thiscall DuiLib::WindowImplBase::~WindowImplBase(void)" (__imp_??1WindowImplBase@DuiLib@@UAE@XZ),该符号在函数 "public: virtual __thiscall CMainFrameWnd::~CMainFrameWnd(void)" (??1CMainFrameWnd@@UAE@XZ) 中被引用
    1>MainFrameWnd.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall DuiLib::WindowImplBase::InitWindow(void)" (?InitWindow@WindowImplBase@DuiLib@@UAEXXZ)
    

    我仅继承了 WindowTmpBase 类覆写了下面三个方法:

    class CMainFrameWnd : public WindowImplBase
    {
    public:
        CMainFrameWnd();
        ~CMainFrameWnd();
    
    protected:
        virtual CDuiString GetSkinFolder();
        virtual CDuiString GetSkinFile();
        virtual LPCTSTR GetWindowClassName(void) const;
    };
    
    opened by nmgwddj 4
  • padding属性和List控件

    padding属性和List控件

    1、padding属性在某些大多数情况下有问题,一般是右、下有问题,padding变得非常大,是很严重的BUG。

    2、List控件的SelectItem在某些情况下无效,即选中不了。比如在切换tab后用代码就选中不了了。

    3、此外,友好性建议,建议支持VS2008编译平台,因为做VC开发的大部分使用08平台。

    @wangchyz

    去年的老版本没有这样的问题。

    opened by SevenWow 4
  • vc6 编译duilib遇到的问题求助

    vc6 编译duilib遇到的问题求助

    在编译中遇到两个问题:

    1. UIBase和WinImplBase中使用messagemap会报错 类似:error C2496: 'private: static struct DuiLib::DUI_MSGMAP_ENTRY const * const DuiLib::CNotifyPump::_messageEntries' : 'selectany' can only be applied to statically initialized data items with ext
    2. WindowImplBase::OnCreate 中 使用 pRoot = builder.Create(GetSkinFile().GetData(), (UINT)0, this, &m_PaintManager);报错,提示为: error C2664: 'class DuiLib::CControlUI *__thiscall DuiLib::CDialogBuilder::Create(class DuiLib::STRINGorID,const char *,class DuiLib::IDialogBuilderCallback *,class DuiLib::CPaintManager UI *,class DuiLib::CControlUI *)' : cannot convert parameter 2 from 'unsigned int' to 'const char ' 我把这个地方改成:pRoot = builder.Create(GetSkinFile().GetData(), _T("xml"), this, &m_PaintManager); 后,可以编译通过,但是在使用CControlUI pRoot=builder.Create(_T("duilib.xml"),"",NULL,&m_PaintManager);不会弹错,使用virtual CDuiString GetSkinFile() { return _T("duilib.xml"); }定义会出错。 有人能帮忙解决吗?谢谢! 我的邮箱是[email protected]
    opened by Taiyulu 0
  • vc6 can be use duilib? i meet some error  when build it, is there anyone can help me?

    vc6 can be use duilib? i meet some error when build it, is there anyone can help me?

    error C2496: 'private: static struct DuiLib::DUI_MSGMAP_ENTRY const * const DuiLib::CNotifyPump::_messageEntries' : 'selectany' can only be applied to statically initialized data items with ext WinImplBase.cpp UIBase.cpp

    two file UIBase and WinImplBase,when i shield all messagemap , it can build with no error. is there anyone can tell me ,how to deal about it?

    opened by Taiyulu 0
  • UiControl.cpp中画边框计算错误导致边框消失,因为是所有控件的父类,影响应该比较大

    UiControl.cpp中画边框计算错误导致边框消失,因为是所有控件的父类,影响应该比较大

    UiControl.cpp画边框函数 PaintBorder

    void CControlUI::PaintBorder(HDC hDC)
    {
    	if(m_rcBorderSize.left > 0 && (m_dwBorderColor != 0 || m_dwFocusBorderColor != 0)) {
    

    此处只判断了left大于0,如果边框设置的是0,1,1,1 这种情况就画不了了, 另外画边框时把各宽度除了2,如果宽度为1 1/2 就会得到0,导致边框画出控件边界显示不出来,如下

    if(m_rcBorderSize.bottom > 0) {
    	rcBorder		= m_rcItem;
    	rcBorder.top	= m_rcItem.bottom - m_rcBorderSize.bottom / 2;
        rcBorder.bottom = rcBorder.top;
        rcBorder.left  += m_rcBorderSize.left;
        rcBorder.right -= m_rcBorderSize.right;
    	if (IsFocused() && m_dwFocusBorderColor != 0)
    		CRenderEngine::DrawLine(hDC,rcBorder,m_rcBorderSize.bottom,GetAdjustColor(m_dwFocusBorderColor),m_nBorderStyle);
    	else
    		CRenderEngine::DrawLine(hDC,rcBorder,m_rcBorderSize.bottom,GetAdjustColor(m_dwBorderColor),m_nBorderStyle);
    }
    

    处理方法 rcBorder.top = m_rcItem.bottom - ceil((float)m_rcBorderSize.bottom / (float)2);

    其它几个边也类似,按情况使用 ceil floor可解决,

    水平有限,有不对的地方望指正

    opened by zhaokeli 0
Owner
null