zoukankan      html  css  js  c++  java
  • 基于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;
    }
  • 相关阅读:
    Spark算子--join
    Spark算子--filter
    Spark算子--reduceByKey
    Spark算子--mapPartitions和mapPartitionsWithIndex
    Spark算子--map和flatMap
    Flume环境搭建_五种案例
    枚举深入剖析
    Oracle_基本函数查询综合
    Oracle_复杂查询综合
    softmax 杂谈
  • 原文地址:https://www.cnblogs.com/cnchengv/p/14819165.html
Copyright © 2011-2022 走看看