| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- #pragma once
- #include "../pch/pch.h"
- #include "CMainWnd.h"
- class CMessageboxWnd : public CWindowWnd, public INotifyUI, public IMessageFilterUI
- {
- public:
- LPCTSTR GetWindowClassName() const
- {
- return _T("UIMessageboxFrame");
- };
- UINT GetClassStyle() const
- {
- return UI_CLASSSTYLE_DIALOG;
- };
- void OnFinalMessage(HWND /*hWnd*/)
- {
- //WindowImplBase::OnFinalMessage(hWnd);
- m_pm.RemovePreMessageFilter(this);
- //delete this;
- };
- void Init()
- {
- }
- void Notify(TNotifyUI& msg)
- {
- if(msg.sType == _T("click"))
- {
- DuiLib::CDuiString senderName = msg.pSender->GetName();
- if(senderName == _T("messagebox_dlg_closebtn"))
- {
- Close(IDCANCEL);
- return;
- }
- }
- }
- LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- LONG styleValue = ::GetWindowLong(*this, GWL_STYLE);
- styleValue &= ~WS_CAPTION;
- ::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
- // 把自己的窗口句柄与窗口绘制管理器挂接在一起
- m_pm.Init(m_hWnd);
- m_pm.AddPreMessageFilter(this);
- CDialogBuilder builder;
- CControlUI* pRoot = builder.Create(_T("messagebox_dlg.xml"), (UINT)0, NULL, &m_pm);
- ASSERT(pRoot && "Failed to parse XML");
- // 把这些控件绘制到本窗口上
- m_pm.AttachDialog(pRoot);
- // 把自己加入到CPaintManagerUI的m_aNotifiers数组中,用于处理Notify函数
- m_pm.AddNotifier(this);
- Init();
- return 0;
- }
- LRESULT OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- if(::IsIconic(*this))
- {
- bHandled = FALSE;
- }
- return (wParam == 0) ? TRUE : FALSE;
- }
- LRESULT OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- return 0;
- }
- LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- return 0;
- }
- LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
- LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
- public:
- CPaintManagerUI m_pm;
- };
|