• duilib学习笔记01:一个简单的Duilib程序的基本框架


    // 一个简单的Duilib程序的基本框架


    // Duilib使用设置部分
    #pragma once
    
    #define WIN32_LEAN_AND_MEAN    
    #define _CRT_SECURE_NO_DEPRECATE
    
    #include <windows.h>
    #include <objbase.h>
    
    #include "..\DuiLib\UIlib.h"
    
    using namespace DuiLib;
    
    #ifdef _DEBUG
    #   ifdef _UNICODE
    #       pragma comment(lib, "..\\bin\\DuiLib_ud.lib")
    #   else
    #       pragma comment(lib, "..\\bin\\DuiLib_d.lib")
    #   endif
    #else
    #   ifdef _UNICODE
    #       pragma comment(lib, "..\\bin\\DuiLib_u.lib")
    #   else
    #       pragma comment(lib, "..\\bin\\DuiLib.lib")
    #   endif
    #endif
    
    // 窗口实例及消息响应部分
    class CFrameWindowWnd : public CWindowWnd, public INotifyUI
    {
    public:
        CFrameWindowWnd() { };
        LPCTSTR GetWindowClassName() const { return _T("UIMainFrame"); };
        UINT GetClassStyle() const { return UI_CLASSSTYLE_FRAME | CS_DBLCLKS; };
        void OnFinalMessage(HWND /*hWnd*/) { delete this; };
    
        void Notify(TNotifyUI& msg)
        {
            if( msg.sType == _T("click") ) {
                if( msg.pSender->GetName() == _T("closebtn") ) {
                    Close();
                }
            }
        }
    
        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);
        }
    
    public:
        CPaintManagerUI m_pm;
    };
    
    // 程序入口及Duilib初始化部分
    int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow)
    {
        CPaintManagerUI::SetInstance(hInstance);
        CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath());
    
        CFrameWindowWnd* pFrame = new CFrameWindowWnd();
        if( pFrame == NULL ) return 0;
        pFrame->Create(NULL, _T("测试"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE);
        pFrame->ShowWindow(true);
        CPaintManagerUI::MessageLoop();
    
        return 0;
    }

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

  • 相关阅读:
    openswitch db files
    openstack中虚拟机和其网络的联系方法 instance and network
    python操作db2和mysql ,ibm_db
    yum安装mariadb
    python 连接 db2
    db2操作 连接、备份、恢复db2
    su su
    linux 后台运行进程 fg bg ctrl+z nohup
    mysql 命令行
    IDEA-使用技巧
  • 原文地址:https://www.cnblogs.com/xuejianhui/p/2782824.html
Copyright © 2020-2023  润新知