zoukankan      html  css  js  c++  java
  • duilib学习笔记02:界面布局

    ★:带有系统标题框和边框:

    //函数原型
    LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
        if( uMsg == WM_CREATE ) {
            m_pm.Init(m_hWnd);
            CControlUI *pButton = new CButtonUI;
            pButton->SetName(_T("closebtn"));
            pButton->SetBkColor(0xFFFF0000);
            m_pm.AttachDialog(pButton);
            m_pm.AddNotifier(this);
            return 0;
        }
        else if( uMsg == WM_DESTROY ) {
            ::PostQuitMessage(0);
        }
    
        LRESULT lRes = 0;
        if( m_pm.MessageHandler(uMsg, wParam, lParam, lRes) ) {
            return lRes;
        }
    
        return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
    }

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

    ★:去掉系统标题框和边框:

    //函数修改
    LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
        if( uMsg == WM_CREATE ) {
            m_pm.Init(m_hWnd);
            CControlUI *pButton = new CButtonUI;
            pButton->SetName(_T("closebtn"));
            pButton->SetBkColor(0xFFFF0000);
            m_pm.AttachDialog(pButton);
            m_pm.AddNotifier(this);
            return 0;
        }
        else if( uMsg == WM_DESTROY ) {
            ::PostQuitMessage(0);
        }
        //NewAdd...Start..For delect the title frame and the rim provide by system.
        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;
        }
        //NewAdd...End..............................................................
    
        LRESULT lRes = 0;
        if( m_pm.MessageHandler(uMsg, wParam, lParam, lRes) ) {
            return lRes;
        }
    
        return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
    }

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

    ★:使用XML进行页面布局:

    //函数修改
    LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
        if( uMsg == WM_CREATE ) {
            m_pm.Init(m_hWnd);
    
            //New Change...Start..For get a new layout by oneself...................
            CDialogBuilder builder;
            CControlUI* pRoot = builder.Create(_T("test1.xml"), (UINT)0, NULL, &m_pm);
            ASSERT(pRoot && "Failed to parse XML");
            m_pm.AttachDialog(pRoot);
            //New Change...End......................................................
    
            m_pm.AddNotifier(this);
    
            return 0;
        }
        else if( uMsg == WM_DESTROY ) {
            ::PostQuitMessage(0);
        }
        //NewAdd...Start..For delect the title frame and the rim provide by system.
        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;
        }
        //NewAdd...End..............................................................
    
        LRESULT lRes = 0;
        if( m_pm.MessageHandler(uMsg, wParam, lParam, lRes) ) {
            return lRes;
        }
    
        return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
    }

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

    test1.xml文件内容:

    <?xml version="1.0" encoding="UTF-8"?>
    <Window mininfo="200,360" size=" 480,320 ">
            <Font name="幼圆" size="16" default="true" />
            <VerticalLayout bkcolor="#FFFF00FF">
                <Button name="changeskinbtn" height="20" text="测试按钮" maxwidth="120" />
                <RichEdit name="testrichedit" bordercolor="#FF0000" bordersize="0" borderround="18,18" inset="4,2,4,2" bkcolor="#A0F2F5FA" bkcolor2="#A0FF0000" bkcolor3="#A0F2F5FA" font="1" multiline="true" vscrollbar="true" autovscroll="true" enabled="true" rich="true" readonly="false" text="测试richedit">
                </RichEdit>
                <Edit name="testedit" text="测试编辑框" />
            </VerticalLayout>
            //添加下面一行内容,以修改按钮外观。
            //然后将button_nor.bmp、button_over.bmp、button_down.bmp(可在Duilib发行包中找到)放到exe目录下。
            <Default name="Button" value="normalimage=&quot;file='button_nor.bmp' corner='4,2,4,2' fade='200' hsl='true'&quot; hotimage=&quot;file='button_over.bmp' corner='4,2,4,2' fade='200' hsl='true'&quot; pushedimage=&quot;file='button_down.bmp' corner='4,2,4,2' fade='200' hsl='true' &quot; " />
    </Window>

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

  • 相关阅读:
    Selenium2Library+ride学习笔记
    windbg 调试技巧
    LINUX常用命令--重定向、管道篇(四)
    Linux文件系统与结构
    windbg命令学习4
    windbg命令学习3
    windbg命令学习2
    MySQL常用操作命令
    Httpwatch 工具介绍
    windows平台上用python 远程线程注入,执行shellcode
  • 原文地址:https://www.cnblogs.com/xuejianhui/p/2782833.html
Copyright © 2011-2022 走看看