Duilib学习(一)

#pragmaonce#includeusingnamespaceDuiLib;#ifdef_DEBUG#ifdef_UNICODE#pragmacomment(lib,&

大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。

全栈程序员社区此处内容已经被作者隐藏,请输入验证码查看内容
验证码:
请关注本站微信公众号,回复“验证码”,获取验证码。在微信里搜索“全栈程序员社区”或者“www_javaforall_cn”或者微信扫描右侧二维码都可以关注本站微信公众号。

#pragma once
#include <UIlib.h>
using namespace DuiLib;

#ifdef _DEBUG
#   ifdef _UNICODE
#       pragma comment(lib, "DuiLib_ud.lib")
#   else
#       pragma comment(lib, "DuiLib_d.lib")
#   endif
#else
#   ifdef _UNICODE
#       pragma comment(lib, "DuiLib_u.lib")
#   else
#       pragma comment(lib, "DuiLib.lib")
#   endif
#endif

class CDuiFrameWnd : public CWindowWnd, public INotifyUI
{
public:
    virtual LPCTSTR GetWindowClassName() const { return _T("DUIMainFrame"); }
    virtual void    Notify(TNotifyUI& msg) 
    {
        if (msg.sType == _T("click"))
        {
            if (msg.pSender->GetName() == _T("btnHello"))
            {
                ::MessageBox(NULL, _T("我是按钮"), _T("点击了按钮"), NULL);
            }
        }
    }

    virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
        LRESULT lRes = 0;

        if (uMsg == WM_CREATE)
        {
            // 方法1
            //CControlUI *pWnd = new CButtonUI;
            //pWnd->SetName(_T("btnHello"));   // 控件的唯一标识
            //pWnd->SetText(_T("Hello World"));   // 设置文字
            //pWnd->SetBkColor(0xFF00FF00);       // 设置背景色

            //m_PaintManager.Init(m_hWnd);
            //m_PaintManager.AttachDialog(pWnd);

            //m_PaintManager.AddNotifier(this);  // 添加控件响应消息,这样消息就会达到duilib的消息循环

            // 方法2
            m_PaintManager.Init(m_hWnd);

            CDialogBuilder builder;
            CControlUI *pRoot = builder.Create(_T("duilib.xml"), NULL, NULL, &m_PaintManager, NULL);
            ASSERT(pRoot && "Failed to parse XML");

            m_PaintManager.AttachDialog(pRoot);
            m_PaintManager.AddNotifier(this);
            return lRes;
        }
        // 以下三个消息用于屏蔽系统标题栏
        // WM_NCACTIVETE WM_NCCALCSIZE WM_NCPAINT
        else if (uMsg == WM_NCACTIVATE)
        {
            if (!::IsIconic(m_hWnd))
            {
                return (wParam == 0) ? TRUE : FALSE;
            }
        }
        else if (uMsg == WM_NCCALCSIZE)
        {
            return 0;
        }
        else if (uMsg == WM_NCPAINT)
        {
            return 0;
        }

        if (m_PaintManager.MessageHandler(uMsg, wParam, lParam, lRes))
        {
            return lRes;
        }

        return __super::HandleMessage(uMsg, wParam, lParam);
    }

protected:
    CPaintManagerUI m_PaintManager;
};


class CDuiXmlFrameWnd : public WindowImplBase
{
public:
    // 实现以下三个纯虚函数
    virtual LPCTSTR GetWindowClassName()const { return _T("DUIMainFrame"); }
    virtual CDuiString GetSkinFile(){ return _T("duilib.xml"); }
    virtual CDuiString GetSkinFolder(){ return _T(""); }

    // 将事件添加到消息队列
    virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
        LRESULT lRes = 0;

        if (uMsg == WM_CREATE)
        {
            // 方法1
            //CControlUI *pWnd = new CButtonUI;
            //pWnd->SetName(_T("btnHello"));   // 控件的唯一标识
            //pWnd->SetText(_T("Hello World"));   // 设置文字
            //pWnd->SetBkColor(0xFF00FF00);       // 设置背景色

            //m_PaintManager.Init(m_hWnd);
            //m_PaintManager.AttachDialog(pWnd);

            //m_PaintManager.AddNotifier(this);  // 添加控件响应消息,这样消息就会达到duilib的消息循环

            // 方法2
            m_PaintManager.Init(m_hWnd);

            CDialogBuilder builder;
            CControlUI *pRoot = builder.Create(_T("duilib.xml"), NULL, NULL, &m_PaintManager, NULL);
            ASSERT(pRoot && "Failed to parse XML");

            m_PaintManager.AttachDialog(pRoot);
            m_PaintManager.AddNotifier(this);
            return lRes;
        }
        // 以下三个消息用于屏蔽系统标题栏
        // WM_NCACTIVETE WM_NCCALCSIZE WM_NCPAINT
        else if (uMsg == WM_NCACTIVATE)
        {
            if (!::IsIconic(m_hWnd))
            {
                return (wParam == 0) ? TRUE : FALSE;
            }
        }
        else if (uMsg == WM_NCCALCSIZE)
        {
            return 0;
        }
        else if (uMsg == WM_NCPAINT)
        {
            return 0;
        }

        if (m_PaintManager.MessageHandler(uMsg, wParam, lParam, lRes))
        {
            return lRes;
        }

        return __super::HandleMessage(uMsg, wParam, lParam);
    }

    // 实现控件响应事件
    virtual void Notify(TNotifyUI& msg)
    {
        if (msg.pSender->GetName() == _T("editHello"))
        {
            // 获取控件对象方法
            CEditUI *pEdit = static_cast<CEditUI *>(m_PaintManager.FindControl(_T("editHello")));
        }
        // 处理控件响应事件
        if (msg.sType == _T("click"))
        {
            if (msg.pSender->GetName() == _T("btnHello"))
            {
                ::MessageBox(NULL, _T("我是按钮"), _T("点击了按钮"), NULL);

                // 人为修改控件焦点
                CEditUI *pEdit2 = static_cast<CEditUI *>(m_PaintManager.FindControl(_T("editWorld")));
                m_PaintManager.SetFocus(pEdit2, TRUE);
            }
        }
    }
};

int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
    // 实例句柄与渲染类关联
    CPaintManagerUI::SetInstance(hInstance);

    // 设置资源的默认路径(设置和exe在同一个目录)
    CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath());

    /*CDuiFrameWnd duiFrame;
    duiFrame.Create(NULL, _T("DUIWnd"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE);
    duiFrame.CenterWindow();
    duiFrame.ShowModal();*/

    // 方法2
    CDuiXmlFrameWnd duixmlFrame;
    duixmlFrame.Create(NULL, _T("DuiWnd"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE);
    duixmlFrame.CenterWindow();
    duixmlFrame.ShowModal();
    
    return 0;
}

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/120245.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • PMF 培训[通俗易懂]

    PMF 培训[通俗易懂]IBM有一些很有名的培训,也很有效,真的是有立竿见影的效果.过去很长时间之后,可能不记得培训的那些细节,但是培训中传达的工作方式,能给你很大的影响.进公司后3个月的时候接受了第一个,有关customerfacing的,其实是为你提供了一个商务沟通的基本模式,现在培训的内容忘记了,但是这个模式还记得:调查-承诺-执行-反馈.一个有效的商务沟通,哪怕是和客户的一个电话,都需要艺…

    2022年6月22日
    36
  • whl文件安装方法

    whl文件安装方法   whl格式本质上是一个压缩包,里面包含了py文件,以及经过编译的pyd文件。使得可以在不具备编译环境的情况下,选择合适自己的python环境进行安装问题描述:whl下载了后不会安装解决方法:1.把下载的文件拖到桌面2.进入cmd命令行3.使用cd进入whl文件属性标识的目录)(红色框)4.使用“pipinstall文件名”安装下载的文件(绿色框)5.安装完成…

    2022年5月30日
    52
  • matlab三维拟合曲面_热传导的三种边界条件

    matlab三维拟合曲面_热传导的三种边界条件1第三类边界条件的热传导方程1.1热传导方程热传导在一维的各向同性介质里的传播可用以下方程表达:∂u∂t=a∂2u∂x2(1)\frac{\partialu}{\partialt}=a\frac{\partial^{2}u}{\partialx^{2}}\tag{1}∂t∂u​=a∂x2∂2u​(1)其中,u=u(x,t)u=u(x,t)u=u(x,t),a=λcρa=\frac{\lambda}{c\rho}a=cρλ​,λ\lambdaλ表示介质的热传导率,ccc表

    2025年7月31日
    4
  • Lightroom人像磨皮滤镜插件portraiture Mac版

    Lightroom人像磨皮滤镜插件portraiture Mac版本次小编为您带来了Portraiture3forLightroomforMac,这是一款适用于Lightroom的lr人像磨皮滤镜插件。lr磨皮插件portraitureMac版功能非常强大,能够快速对图像中的皮肤,眉毛,头发,眼睛瞪部位进行磨皮修饰,去除瑕疵,同时为您保持皮肤的色泽!链接:https://pan.baidu.com/s/1U0QVMQ6Qa8F5NITbBVr3…

    2022年7月22日
    17
  • TransactionScope使用说明

    TransactionScope使用说明参考MSDN:http://msdn.microsoft.com/zh-cn/library/system.transactions.transactionscope.aspx转载自:http://www.cnblogs.com/blsong/archive/2010/08/13/1798987.html感谢原作者。TransactionScope是.NetFramework

    2022年7月19日
    15
  • 字符串反转的实现方法总结「建议收藏」

    文章目录方法1:对称交换法方法2:函数递归法方法3:列表反转法方法4:循环反向迭代法方法5:倒序切片法方法6:遍历索引法方法7:反向遍历索引法方法8:列表弹出法方法9:反向循环迭代法方法10:累积相加法方法11:匿名函数法方法12:列表倒序法方法13:双向队列排序法方法14:双向队列反转法方法1:对称交换法str=’abcdef’deff(s):s=list(s)…

    2022年4月16日
    41

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号