• 基于WindowImplBase 更简单 以及 可变大小的,才是标准的


    dui界面基于

    https://github.com/dingyuanhong/dui_ffplay/

    常用的教程  https://github.com/jiangrongbo/duilib-tutorial

    extern "C"
    {
    #include "common.h" //ff相关
    }
    
    #include <Windows.h>
    
    #include "../DuiLib/UIlib.h"
    
    using namespace DuiLib;
    #pragma comment(lib,"../lib/DuiLib_u.lib")
    
    class MyWnd : public WindowImplBase{
        LPCTSTR GetWindowClassName() const{
            return L"MyWnd";
        }
        UINT GetClassStyle() const{
            return UI_CLASSSTYLE_FRAME | CS_DBLCLKS;
        }
        CDuiString GetSkinFile(){
            return L"UFPlayer.xml";
        }
        CDuiString GetSkinFolder(){
            return CPaintManagerUI::GetResourcePath();
        }
        void Notify(TNotifyUI& msg){
            if (msg.sType == L"click"){
                if (msg.pSender->GetName() == L"IDCLOSE"){
                    ::PostQuitMessage(0);
                }
                else if (msg.pSender->GetName() == L"IDSTOP"){
                    ::SendMessage(m_hWnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
                }
            }
        }
    };
    
    int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow){
        CPaintManagerUI::SetInstance(hInstance);
        CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetResourcePath());
        //创建主窗口
        MyWnd* pFrame = new MyWnd();
        pFrame->Create(NULL, L"Tutorial5", UI_WNDSTYLE_FRAME^WS_THICKFRAME, WS_EX_WINDOWEDGE);
        pFrame->CenterWindow();
        pFrame->ShowWindow(true);
        CPaintManagerUI::MessageLoop();
        return 0;
    }

     可变大小的

    class CFrameWindowWnd : public CWindowWnd, public INotifyUI//, public CDwm, public CDPI
    {
    public:
        CFrameWindowWnd()  { };
        LPCTSTR GetWindowClassName() const { return _T("UIMainFrame"); };
        UINT GetClassStyle() const { return UI_CLASSSTYLE_FRAME | CS_DBLCLKS; };
        void OnFinalMessage(HWND /*hWnd*/) { delete this; };
    
        void Init() { }
    
        void OnPrepare(){
            CCheckBoxUI* pcheck = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("uid46CheckBox")));
            //pcheck->SetEnabled(false);
    
        }
    
    
        void Notify(TNotifyUI& msg)
        {
            if (msg.sType == _T("windowinit")) OnPrepare();
            else if (msg.sType == L"click"){
                if (msg.pSender->GetName() == L"IDCLOSE"){
                    ::PostQuitMessage(0);
                }
                else if (msg.pSender->GetName() == L"IDSTOP"){
                    ::SendMessage(m_hWnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
                }
            }
        }
    
        LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
        {
            if (uMsg == WM_CREATE) {
                m_pm.Init(m_hWnd);
                CDialogBuilder builder;
                CControlUI* pRoot = builder.Create(_T("UFPlayer.xml"), (UINT)0, NULL, &m_pm);
                ASSERT(pRoot && "Failed to parse XML");
                m_pm.AttachDialog(pRoot);
                m_pm.AddNotifier(this);
    
                Init();
                return 0;
            }
            else if (uMsg == WM_DESTROY) {
                ::PostQuitMessage(0L);
            }
            else if (uMsg == WM_NCACTIVATE) {
                if (!::IsIconic(*this)) return (wParam == 0) ? TRUE : FALSE;
            }
            LRESULT lRes = 0;
            if (m_pm.MessageHandler(uMsg, wParam, lParam, lRes)) return lRes;
            return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
        }
    
    public:
        CPaintManagerUI m_pm;
    
    };
    
    
    int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow)
    {
        CPaintManagerUI::SetInstance(hInstance);
        CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath());
        /*
        HRESULT Hr = ::CoInitialize(NULL);
        if( FAILED(Hr) ) return 0;
        */
        CWndShadow::Initialize(hInstance);
    
        CFrameWindowWnd* pFrame = new CFrameWindowWnd();
        if (pFrame == NULL) return 0;
        pFrame->Create(NULL, _T("mywnd"), UI_WNDSTYLE_FRAME | WS_CLIPCHILDREN, WS_EX_WINDOWEDGE);
        pFrame->CenterWindow();
        pFrame->ShowWindow(true);
        CPaintManagerUI::MessageLoop();
    
        //::CoUninitialize();
        return 0;
    }
  • 相关阅读:
    form表单的两种提交方式,submit和button的用法
    ORACLE SEQUENCE用法(转)
    hive优化
    Hive分区表创建、分类
    Hive体系结构
    Hive入门指南
    mysql统计表中条目个数的方法举例
    mysql如何快速创建相同结构的表
    VMware Workstation下VMnet1等虚拟网卡与主机网卡之间的关系
    linux命令详解——lsof
  • 原文地址:https://www.cnblogs.com/cnchengv/p/14819165.html
Copyright © 2020-2023  润新知