|
|
@@ -5,263 +5,396 @@
|
|
|
class CGameFrameWnd : public CWindowWnd, public INotifyUI
|
|
|
{
|
|
|
public:
|
|
|
- CGameFrameWnd() { };
|
|
|
- LPCTSTR GetWindowClassName() const { return _T("UIMainFrame"); };
|
|
|
- UINT GetClassStyle() const { return CS_DBLCLKS; };
|
|
|
- void OnFinalMessage(HWND /*hWnd*/) { delete this; };
|
|
|
+ CGameFrameWnd() { };
|
|
|
+ LPCTSTR GetWindowClassName() const
|
|
|
+ {
|
|
|
+ return _T("UIMainFrame");
|
|
|
+ };
|
|
|
+ UINT GetClassStyle() const
|
|
|
+ {
|
|
|
+ return CS_DBLCLKS;
|
|
|
+ };
|
|
|
+ void OnFinalMessage(HWND /*hWnd*/)
|
|
|
+ {
|
|
|
+ delete this;
|
|
|
+ };
|
|
|
|
|
|
- void Init();
|
|
|
+ void Init();
|
|
|
|
|
|
- void OnPrepare()
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
+ void OnPrepare()
|
|
|
+ {
|
|
|
|
|
|
- void Notify(TNotifyUI& msg)
|
|
|
- {
|
|
|
- if (msg.sType == _T("windowinit"))
|
|
|
- {
|
|
|
- OnPrepare();
|
|
|
- }
|
|
|
- else if (msg.sType == _T("click"))
|
|
|
- {
|
|
|
- if (msg.pSender == m_pCloseBtn)
|
|
|
- {
|
|
|
- COptionUI* pControl = static_cast<COptionUI*>(m_pm.FindControl(_T("hallswitch")));
|
|
|
- if (pControl && pControl->IsSelected() == false)
|
|
|
- {
|
|
|
- CControlUI* pFadeControl = m_pm.FindControl(_T("fadeEffect"));
|
|
|
- if (pFadeControl) pFadeControl->SetVisible(true);
|
|
|
- }
|
|
|
- else {
|
|
|
- /*Close()*/PostQuitMessage(0); // 因为activex的原因,使用close可能会出现错误
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
- else if (msg.pSender == m_pMinBtn) { SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0); return; }
|
|
|
- else if (msg.pSender == m_pMaxBtn) { SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0); return; }
|
|
|
- else if (msg.pSender == m_pRestoreBtn) { SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0); return; }
|
|
|
- CDuiString name = msg.pSender->GetName();
|
|
|
- if (name == _T("quitbtn")) {
|
|
|
- /*Close()*/PostQuitMessage(0); // 因为activex的原因,使用close可能会出现错误
|
|
|
- }
|
|
|
- else if (name == _T("returnhallbtn")) {
|
|
|
- CControlUI* pFadeControl = m_pm.FindControl(_T("fadeEffect"));
|
|
|
- if (pFadeControl) pFadeControl->SetVisible(false);
|
|
|
+ }
|
|
|
|
|
|
- COptionUI* pControl = static_cast<COptionUI*>(m_pm.FindControl(_T("hallswitch")));
|
|
|
- pControl->Activate();
|
|
|
- pControl = static_cast<COptionUI*>(m_pm.FindControl(_T("roomswitch")));
|
|
|
- if (pControl) pControl->SetVisible(false);
|
|
|
- }
|
|
|
- else if (name == _T("fontswitch")) {
|
|
|
- TFontInfo* pFontInfo = m_pm.GetDefaultFontInfo();
|
|
|
- if (pFontInfo->iSize < 18) {
|
|
|
- TFontInfo* pFontInfo = m_pm.GetFontInfo(0);
|
|
|
- if (pFontInfo)m_pm.SetDefaultFont(pFontInfo->sFontName, pFontInfo->iSize, pFontInfo->bBold,
|
|
|
- pFontInfo->bUnderline, pFontInfo->bItalic);
|
|
|
- }
|
|
|
- else {
|
|
|
- TFontInfo* pFontInfo = m_pm.GetFontInfo(1);
|
|
|
- if (pFontInfo)m_pm.SetDefaultFont(pFontInfo->sFontName, pFontInfo->iSize, pFontInfo->bBold,
|
|
|
- pFontInfo->bUnderline, pFontInfo->bItalic);
|
|
|
- }
|
|
|
- m_pm.GetRoot()->NeedUpdate();
|
|
|
- }
|
|
|
- else if (name == _T("leaveBtn") || name == _T("roomclosebtn")) {
|
|
|
- COptionUI* pControl = static_cast<COptionUI*>(m_pm.FindControl(_T("hallswitch")));
|
|
|
- if (pControl) {
|
|
|
- pControl->Activate();
|
|
|
- pControl = static_cast<COptionUI*>(m_pm.FindControl(_T("roomswitch")));
|
|
|
- if (pControl) pControl->SetVisible(false);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else if (msg.sType == _T("selectchanged")) {
|
|
|
- CDuiString name = msg.pSender->GetName();
|
|
|
- if (name == _T("hallswitch")) {
|
|
|
- CTabLayoutUI* pControl = static_cast<CTabLayoutUI*>(m_pm.FindControl(_T("switch")));
|
|
|
- if (pControl && pControl->GetCurSel() != 0) pControl->SelectItem(0);
|
|
|
- }
|
|
|
- }
|
|
|
- else if (msg.sType == _T("itemclick")) {
|
|
|
+ void Notify(TNotifyUI& msg)
|
|
|
+ {
|
|
|
+ if(msg.sType == _T("windowinit"))
|
|
|
+ {
|
|
|
+ OnPrepare();
|
|
|
+ }
|
|
|
+ else if(msg.sType == _T("click"))
|
|
|
+ {
|
|
|
+ if(msg.pSender == m_pCloseBtn)
|
|
|
+ {
|
|
|
+ COptionUI* pControl = static_cast<COptionUI*>(m_pm.FindControl(_T("hallswitch")));
|
|
|
+ if(pControl && pControl->IsSelected() == false)
|
|
|
+ {
|
|
|
+ CControlUI* pFadeControl = m_pm.FindControl(_T("fadeEffect"));
|
|
|
+ if(pFadeControl)
|
|
|
+ {
|
|
|
+ pFadeControl->SetVisible(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ /*Close()*/PostQuitMessage(0); // 因为activex的原因,使用close可能会出现错误
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else if(msg.pSender == m_pMinBtn)
|
|
|
+ {
|
|
|
+ SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else if(msg.pSender == m_pMaxBtn)
|
|
|
+ {
|
|
|
+ SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else if(msg.pSender == m_pRestoreBtn)
|
|
|
+ {
|
|
|
+ SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ CDuiString name = msg.pSender->GetName();
|
|
|
+ if(name == _T("quitbtn"))
|
|
|
+ {
|
|
|
+ /*Close()*/PostQuitMessage(0); // 因为activex的原因,使用close可能会出现错误
|
|
|
+ }
|
|
|
+ else if(name == _T("returnhallbtn"))
|
|
|
+ {
|
|
|
+ CControlUI* pFadeControl = m_pm.FindControl(_T("fadeEffect"));
|
|
|
+ if(pFadeControl)
|
|
|
+ {
|
|
|
+ pFadeControl->SetVisible(false);
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
- else if (msg.sType == _T("itemactivate")) {
|
|
|
+ COptionUI* pControl = static_cast<COptionUI*>(m_pm.FindControl(_T("hallswitch")));
|
|
|
+ pControl->Activate();
|
|
|
+ pControl = static_cast<COptionUI*>(m_pm.FindControl(_T("roomswitch")));
|
|
|
+ if(pControl)
|
|
|
+ {
|
|
|
+ pControl->SetVisible(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(name == _T("fontswitch"))
|
|
|
+ {
|
|
|
+ TFontInfo* pFontInfo = m_pm.GetDefaultFontInfo();
|
|
|
+ if(pFontInfo->iSize < 18)
|
|
|
+ {
|
|
|
+ TFontInfo* pFontInfo = m_pm.GetFontInfo(0);
|
|
|
+ if(pFontInfo)m_pm.SetDefaultFont(pFontInfo->sFontName, pFontInfo->iSize, pFontInfo->bBold,
|
|
|
+ pFontInfo->bUnderline, pFontInfo->bItalic);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ TFontInfo* pFontInfo = m_pm.GetFontInfo(1);
|
|
|
+ if(pFontInfo)m_pm.SetDefaultFont(pFontInfo->sFontName, pFontInfo->iSize, pFontInfo->bBold,
|
|
|
+ pFontInfo->bUnderline, pFontInfo->bItalic);
|
|
|
+ }
|
|
|
+ m_pm.GetRoot()->NeedUpdate();
|
|
|
+ }
|
|
|
+ else if(name == _T("leaveBtn") || name == _T("roomclosebtn"))
|
|
|
+ {
|
|
|
+ COptionUI* pControl = static_cast<COptionUI*>(m_pm.FindControl(_T("hallswitch")));
|
|
|
+ if(pControl)
|
|
|
+ {
|
|
|
+ pControl->Activate();
|
|
|
+ pControl = static_cast<COptionUI*>(m_pm.FindControl(_T("roomswitch")));
|
|
|
+ if(pControl)
|
|
|
+ {
|
|
|
+ pControl->SetVisible(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(msg.sType == _T("selectchanged"))
|
|
|
+ {
|
|
|
+ CDuiString name = msg.pSender->GetName();
|
|
|
+ if(name == _T("hallswitch"))
|
|
|
+ {
|
|
|
+ CTabLayoutUI* pControl = static_cast<CTabLayoutUI*>(m_pm.FindControl(_T("switch")));
|
|
|
+ if(pControl && pControl->GetCurSel() != 0)
|
|
|
+ {
|
|
|
+ pControl->SelectItem(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(msg.sType == _T("itemclick"))
|
|
|
+ {
|
|
|
|
|
|
- }
|
|
|
- else if (msg.sType == _T("itemselect")) {
|
|
|
- if (msg.pSender->GetName() == _T("chatCombo")) {
|
|
|
- CEditUI* pChatEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("chatEdit")));
|
|
|
- if (pChatEdit) pChatEdit->SetText(msg.pSender->GetText());
|
|
|
- static_cast<CComboUI*>(msg.pSender)->SelectItem(-1);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ else if(msg.sType == _T("itemactivate"))
|
|
|
+ {
|
|
|
|
|
|
- LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
|
|
+ }
|
|
|
+ else if(msg.sType == _T("itemselect"))
|
|
|
+ {
|
|
|
+ if(msg.pSender->GetName() == _T("chatCombo"))
|
|
|
+ {
|
|
|
+ CEditUI* pChatEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("chatEdit")));
|
|
|
+ if(pChatEdit)
|
|
|
+ {
|
|
|
+ pChatEdit->SetText(msg.pSender->GetText());
|
|
|
+ }
|
|
|
+ static_cast<CComboUI*>(msg.pSender)->SelectItem(-1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
- {
|
|
|
- bHandled = FALSE;
|
|
|
- return 0;
|
|
|
- }
|
|
|
+ LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
|
|
|
|
|
- LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
- {
|
|
|
- ::PostQuitMessage(0L);
|
|
|
+ LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+ {
|
|
|
+ bHandled = FALSE;
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
|
|
|
- bHandled = FALSE;
|
|
|
- return 0;
|
|
|
- }
|
|
|
+ LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+ {
|
|
|
+ ::PostQuitMessage(0L);
|
|
|
|
|
|
- LRESULT OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
- {
|
|
|
- if (::IsIconic(*this)) bHandled = FALSE;
|
|
|
- return (wParam == 0) ? TRUE : FALSE;
|
|
|
- }
|
|
|
+ bHandled = FALSE;
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
|
|
|
- LRESULT OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
- {
|
|
|
- return 0;
|
|
|
- }
|
|
|
+ LRESULT OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+ {
|
|
|
+ if(::IsIconic(*this))
|
|
|
+ {
|
|
|
+ bHandled = FALSE;
|
|
|
+ }
|
|
|
+ return (wParam == 0) ? TRUE : FALSE;
|
|
|
+ }
|
|
|
|
|
|
- LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
- {
|
|
|
- return 0;
|
|
|
- }
|
|
|
+ LRESULT OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+ {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
|
|
|
- LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
- {
|
|
|
- POINT pt; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam);
|
|
|
- ::ScreenToClient(*this, &pt);
|
|
|
+ LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+ {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
|
|
|
- RECT rcClient;
|
|
|
- ::GetClientRect(*this, &rcClient);
|
|
|
+ LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+ {
|
|
|
+ POINT pt;
|
|
|
+ pt.x = GET_X_LPARAM(lParam);
|
|
|
+ pt.y = GET_Y_LPARAM(lParam);
|
|
|
+ ::ScreenToClient(*this, &pt);
|
|
|
|
|
|
- if (!::IsZoomed(*this)) {
|
|
|
- RECT rcSizeBox = m_pm.GetSizeBox();
|
|
|
- if (pt.y < rcClient.top + rcSizeBox.top) {
|
|
|
- if (pt.x < rcClient.left + rcSizeBox.left) return HTTOPLEFT;
|
|
|
- if (pt.x > rcClient.right - rcSizeBox.right) return HTTOPRIGHT;
|
|
|
- return HTTOP;
|
|
|
- }
|
|
|
- else if (pt.y > rcClient.bottom - rcSizeBox.bottom) {
|
|
|
- if (pt.x < rcClient.left + rcSizeBox.left) return HTBOTTOMLEFT;
|
|
|
- if (pt.x > rcClient.right - rcSizeBox.right) return HTBOTTOMRIGHT;
|
|
|
- return HTBOTTOM;
|
|
|
- }
|
|
|
- if (pt.x < rcClient.left + rcSizeBox.left) return HTLEFT;
|
|
|
- if (pt.x > rcClient.right - rcSizeBox.right) return HTRIGHT;
|
|
|
- }
|
|
|
+ RECT rcClient;
|
|
|
+ ::GetClientRect(*this, &rcClient);
|
|
|
|
|
|
- RECT rcCaption = m_pm.GetCaptionRect();
|
|
|
- if (pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
|
|
|
- && pt.y >= rcCaption.top && pt.y < rcCaption.bottom) {
|
|
|
- CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(pt));
|
|
|
- if (pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0 &&
|
|
|
- _tcscmp(pControl->GetClass(), DUI_CTR_OPTION) != 0 &&
|
|
|
- _tcscmp(pControl->GetClass(), DUI_CTR_TEXT) != 0)
|
|
|
- return HTCAPTION;
|
|
|
- }
|
|
|
+ if(!::IsZoomed(*this))
|
|
|
+ {
|
|
|
+ RECT rcSizeBox = m_pm.GetSizeBox();
|
|
|
+ if(pt.y < rcClient.top + rcSizeBox.top)
|
|
|
+ {
|
|
|
+ if(pt.x < rcClient.left + rcSizeBox.left)
|
|
|
+ {
|
|
|
+ return HTTOPLEFT;
|
|
|
+ }
|
|
|
+ if(pt.x > rcClient.right - rcSizeBox.right)
|
|
|
+ {
|
|
|
+ return HTTOPRIGHT;
|
|
|
+ }
|
|
|
+ return HTTOP;
|
|
|
+ }
|
|
|
+ else if(pt.y > rcClient.bottom - rcSizeBox.bottom)
|
|
|
+ {
|
|
|
+ if(pt.x < rcClient.left + rcSizeBox.left)
|
|
|
+ {
|
|
|
+ return HTBOTTOMLEFT;
|
|
|
+ }
|
|
|
+ if(pt.x > rcClient.right - rcSizeBox.right)
|
|
|
+ {
|
|
|
+ return HTBOTTOMRIGHT;
|
|
|
+ }
|
|
|
+ return HTBOTTOM;
|
|
|
+ }
|
|
|
+ if(pt.x < rcClient.left + rcSizeBox.left)
|
|
|
+ {
|
|
|
+ return HTLEFT;
|
|
|
+ }
|
|
|
+ if(pt.x > rcClient.right - rcSizeBox.right)
|
|
|
+ {
|
|
|
+ return HTRIGHT;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- return HTCLIENT;
|
|
|
- }
|
|
|
+ RECT rcCaption = m_pm.GetCaptionRect();
|
|
|
+ if(pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
|
|
|
+ && pt.y >= rcCaption.top && pt.y < rcCaption.bottom)
|
|
|
+ {
|
|
|
+ CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(pt));
|
|
|
+ if(pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0 &&
|
|
|
+ _tcscmp(pControl->GetClass(), DUI_CTR_OPTION) != 0 &&
|
|
|
+ _tcscmp(pControl->GetClass(), DUI_CTR_TEXT) != 0)
|
|
|
+ {
|
|
|
+ return HTCAPTION;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
- {
|
|
|
- SIZE szRoundCorner = m_pm.GetRoundCorner();
|
|
|
- if (!::IsIconic(*this) && (szRoundCorner.cx != 0 || szRoundCorner.cy != 0)) {
|
|
|
- CDuiRect rcWnd;
|
|
|
- ::GetWindowRect(*this, &rcWnd);
|
|
|
- rcWnd.Offset(-rcWnd.left, -rcWnd.top);
|
|
|
- rcWnd.right++; rcWnd.bottom++;
|
|
|
- HRGN hRgn = ::CreateRoundRectRgn(rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, szRoundCorner.cx, szRoundCorner.cy);
|
|
|
- ::SetWindowRgn(*this, hRgn, TRUE);
|
|
|
- ::DeleteObject(hRgn);
|
|
|
- }
|
|
|
+ return HTCLIENT;
|
|
|
+ }
|
|
|
|
|
|
- bHandled = FALSE;
|
|
|
- return 0;
|
|
|
- }
|
|
|
+ LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+ {
|
|
|
+ SIZE szRoundCorner = m_pm.GetRoundCorner();
|
|
|
+ if(!::IsIconic(*this) && (szRoundCorner.cx != 0 || szRoundCorner.cy != 0))
|
|
|
+ {
|
|
|
+ CDuiRect rcWnd;
|
|
|
+ ::GetWindowRect(*this, &rcWnd);
|
|
|
+ rcWnd.Offset(-rcWnd.left, -rcWnd.top);
|
|
|
+ rcWnd.right++;
|
|
|
+ rcWnd.bottom++;
|
|
|
+ HRGN hRgn = ::CreateRoundRectRgn(rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, szRoundCorner.cx, szRoundCorner.cy);
|
|
|
+ ::SetWindowRgn(*this, hRgn, TRUE);
|
|
|
+ ::DeleteObject(hRgn);
|
|
|
+ }
|
|
|
|
|
|
- LRESULT OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
- {
|
|
|
- int primaryMonitorWidth = ::GetSystemMetrics(SM_CXSCREEN);
|
|
|
- int primaryMonitorHeight = ::GetSystemMetrics(SM_CYSCREEN);
|
|
|
- MONITORINFO oMonitor = {};
|
|
|
- oMonitor.cbSize = sizeof(oMonitor);
|
|
|
- ::GetMonitorInfo(::MonitorFromWindow(*this, MONITOR_DEFAULTTOPRIMARY), &oMonitor);
|
|
|
- CDuiRect rcWork = oMonitor.rcWork;
|
|
|
- rcWork.Offset(-oMonitor.rcMonitor.left, -oMonitor.rcMonitor.top);
|
|
|
- if (rcWork.right > primaryMonitorWidth) rcWork.right = primaryMonitorWidth;
|
|
|
- if (rcWork.bottom > primaryMonitorHeight) rcWork.right = primaryMonitorHeight;
|
|
|
- LPMINMAXINFO lpMMI = (LPMINMAXINFO)lParam;
|
|
|
- lpMMI->ptMaxPosition.x = rcWork.left;
|
|
|
- lpMMI->ptMaxPosition.y = rcWork.top;
|
|
|
- lpMMI->ptMaxSize.x = rcWork.right;
|
|
|
- lpMMI->ptMaxSize.y = rcWork.bottom;
|
|
|
- bHandled = FALSE;
|
|
|
- return 0;
|
|
|
- }
|
|
|
+ bHandled = FALSE;
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
|
|
|
- LRESULT OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
- {
|
|
|
- // 有时会在收到WM_NCDESTROY后收到wParam为SC_CLOSE的WM_SYSCOMMAND
|
|
|
- if (wParam == SC_CLOSE) {
|
|
|
- ::PostQuitMessage(0L);
|
|
|
- bHandled = TRUE;
|
|
|
- return 0;
|
|
|
- }
|
|
|
- BOOL bZoomed = ::IsZoomed(*this);
|
|
|
- LRESULT lRes = CWindowWnd::HandleMessage(uMsg, wParam, lParam);
|
|
|
- if (::IsZoomed(*this) != bZoomed) {
|
|
|
- if (!bZoomed) {
|
|
|
- CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("maxbtn")));
|
|
|
- if (pControl) pControl->SetVisible(false);
|
|
|
- pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("restorebtn")));
|
|
|
- if (pControl) pControl->SetVisible(true);
|
|
|
- }
|
|
|
- else {
|
|
|
- CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("maxbtn")));
|
|
|
- if (pControl) pControl->SetVisible(true);
|
|
|
- pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("restorebtn")));
|
|
|
- if (pControl) pControl->SetVisible(false);
|
|
|
- }
|
|
|
- }
|
|
|
- return lRes;
|
|
|
- }
|
|
|
+ LRESULT OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+ {
|
|
|
+ int primaryMonitorWidth = ::GetSystemMetrics(SM_CXSCREEN);
|
|
|
+ int primaryMonitorHeight = ::GetSystemMetrics(SM_CYSCREEN);
|
|
|
+ MONITORINFO oMonitor = {};
|
|
|
+ oMonitor.cbSize = sizeof(oMonitor);
|
|
|
+ ::GetMonitorInfo(::MonitorFromWindow(*this, MONITOR_DEFAULTTOPRIMARY), &oMonitor);
|
|
|
+ CDuiRect rcWork = oMonitor.rcWork;
|
|
|
+ rcWork.Offset(-oMonitor.rcMonitor.left, -oMonitor.rcMonitor.top);
|
|
|
+ if(rcWork.right > primaryMonitorWidth)
|
|
|
+ {
|
|
|
+ rcWork.right = primaryMonitorWidth;
|
|
|
+ }
|
|
|
+ if(rcWork.bottom > primaryMonitorHeight)
|
|
|
+ {
|
|
|
+ rcWork.right = primaryMonitorHeight;
|
|
|
+ }
|
|
|
+ LPMINMAXINFO lpMMI = (LPMINMAXINFO)lParam;
|
|
|
+ lpMMI->ptMaxPosition.x = rcWork.left;
|
|
|
+ lpMMI->ptMaxPosition.y = rcWork.top;
|
|
|
+ lpMMI->ptMaxSize.x = rcWork.right;
|
|
|
+ lpMMI->ptMaxSize.y = rcWork.bottom;
|
|
|
+ bHandled = FALSE;
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
|
|
|
- LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
- {
|
|
|
- LRESULT lRes = 0;
|
|
|
- BOOL bHandled = TRUE;
|
|
|
- switch (uMsg) {
|
|
|
- case WM_CREATE: lRes = OnCreate(uMsg, wParam, lParam, bHandled); break;
|
|
|
- case WM_CLOSE: lRes = OnClose(uMsg, wParam, lParam, bHandled); break;
|
|
|
- case WM_DESTROY: lRes = OnDestroy(uMsg, wParam, lParam, bHandled); break;
|
|
|
- case WM_NCACTIVATE: lRes = OnNcActivate(uMsg, wParam, lParam, bHandled); break;
|
|
|
- case WM_NCCALCSIZE: lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled); break;
|
|
|
- case WM_NCPAINT: lRes = OnNcPaint(uMsg, wParam, lParam, bHandled); break;
|
|
|
- case WM_NCHITTEST: lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled); break;
|
|
|
- case WM_SIZE: lRes = OnSize(uMsg, wParam, lParam, bHandled); break;
|
|
|
- case WM_GETMINMAXINFO: lRes = OnGetMinMaxInfo(uMsg, wParam, lParam, bHandled); break;
|
|
|
- case WM_SYSCOMMAND: lRes = OnSysCommand(uMsg, wParam, lParam, bHandled); break;
|
|
|
- default:
|
|
|
- bHandled = FALSE;
|
|
|
- }
|
|
|
- if (bHandled) return lRes;
|
|
|
- if (m_pm.MessageHandler(uMsg, wParam, lParam, lRes)) return lRes;
|
|
|
- return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
|
|
|
- }
|
|
|
+ LRESULT OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+ {
|
|
|
+ // 有时会在收到WM_NCDESTROY后收到wParam为SC_CLOSE的WM_SYSCOMMAND
|
|
|
+ if(wParam == SC_CLOSE)
|
|
|
+ {
|
|
|
+ ::PostQuitMessage(0L);
|
|
|
+ bHandled = TRUE;
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ BOOL bZoomed = ::IsZoomed(*this);
|
|
|
+ LRESULT lRes = CWindowWnd::HandleMessage(uMsg, wParam, lParam);
|
|
|
+ if(::IsZoomed(*this) != bZoomed)
|
|
|
+ {
|
|
|
+ if(!bZoomed)
|
|
|
+ {
|
|
|
+ CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("maxbtn")));
|
|
|
+ if(pControl)
|
|
|
+ {
|
|
|
+ pControl->SetVisible(false);
|
|
|
+ }
|
|
|
+ pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("restorebtn")));
|
|
|
+ if(pControl)
|
|
|
+ {
|
|
|
+ pControl->SetVisible(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("maxbtn")));
|
|
|
+ if(pControl)
|
|
|
+ {
|
|
|
+ pControl->SetVisible(true);
|
|
|
+ }
|
|
|
+ pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("restorebtn")));
|
|
|
+ if(pControl)
|
|
|
+ {
|
|
|
+ pControl->SetVisible(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return lRes;
|
|
|
+ }
|
|
|
+
|
|
|
+ LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
+ {
|
|
|
+ LRESULT lRes = 0;
|
|
|
+ BOOL bHandled = TRUE;
|
|
|
+ switch(uMsg)
|
|
|
+ {
|
|
|
+ case WM_CREATE:
|
|
|
+ lRes = OnCreate(uMsg, wParam, lParam, bHandled);
|
|
|
+ break;
|
|
|
+ case WM_CLOSE:
|
|
|
+ lRes = OnClose(uMsg, wParam, lParam, bHandled);
|
|
|
+ break;
|
|
|
+ case WM_DESTROY:
|
|
|
+ lRes = OnDestroy(uMsg, wParam, lParam, bHandled);
|
|
|
+ break;
|
|
|
+ case WM_NCACTIVATE:
|
|
|
+ lRes = OnNcActivate(uMsg, wParam, lParam, bHandled);
|
|
|
+ break;
|
|
|
+ case WM_NCCALCSIZE:
|
|
|
+ lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled);
|
|
|
+ break;
|
|
|
+ case WM_NCPAINT:
|
|
|
+ lRes = OnNcPaint(uMsg, wParam, lParam, bHandled);
|
|
|
+ break;
|
|
|
+ case WM_NCHITTEST:
|
|
|
+ lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled);
|
|
|
+ break;
|
|
|
+ case WM_SIZE:
|
|
|
+ lRes = OnSize(uMsg, wParam, lParam, bHandled);
|
|
|
+ break;
|
|
|
+ case WM_GETMINMAXINFO:
|
|
|
+ lRes = OnGetMinMaxInfo(uMsg, wParam, lParam, bHandled);
|
|
|
+ break;
|
|
|
+ case WM_SYSCOMMAND:
|
|
|
+ lRes = OnSysCommand(uMsg, wParam, lParam, bHandled);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ bHandled = FALSE;
|
|
|
+ }
|
|
|
+ if(bHandled)
|
|
|
+ {
|
|
|
+ return lRes;
|
|
|
+ }
|
|
|
+ if(m_pm.MessageHandler(uMsg, wParam, lParam, lRes))
|
|
|
+ {
|
|
|
+ return lRes;
|
|
|
+ }
|
|
|
+ return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
|
|
|
+ }
|
|
|
|
|
|
public:
|
|
|
- CPaintManagerUI m_pm;
|
|
|
+ CPaintManagerUI m_pm;
|
|
|
|
|
|
private:
|
|
|
- CButtonUI* m_pCloseBtn;
|
|
|
- CButtonUI* m_pMaxBtn;
|
|
|
- CButtonUI* m_pRestoreBtn;
|
|
|
- CButtonUI* m_pMinBtn;
|
|
|
- //...
|
|
|
+ CButtonUI* m_pCloseBtn;
|
|
|
+ CButtonUI* m_pMaxBtn;
|
|
|
+ CButtonUI* m_pRestoreBtn;
|
|
|
+ CButtonUI* m_pMinBtn;
|
|
|
+ //...
|
|
|
};
|