|
|
@@ -0,0 +1,329 @@
|
|
|
+#include "../pch/pch.h"
|
|
|
+#include "CZhengcanKaitaiWnd.h"
|
|
|
+
|
|
|
+LRESULT CZhengcanKaitaiWnd::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);
|
|
|
+
|
|
|
+ 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)
|
|
|
+ {
|
|
|
+ return HTCAPTION;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return HTCLIENT;
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CZhengcanKaitaiWnd::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);
|
|
|
+ }
|
|
|
+
|
|
|
+ bHandled = FALSE;
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CZhengcanKaitaiWnd::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_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;
|
|
|
+ default:
|
|
|
+ bHandled = FALSE;
|
|
|
+ }
|
|
|
+ if (bHandled)
|
|
|
+ {
|
|
|
+ return lRes;
|
|
|
+ }
|
|
|
+ if (m_pm.MessageHandler(uMsg, wParam, lParam, lRes))
|
|
|
+ {
|
|
|
+ return lRes;
|
|
|
+ }
|
|
|
+ return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CZhengcanKaitaiWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled)
|
|
|
+{
|
|
|
+ if (uMsg == WM_KEYDOWN)
|
|
|
+ {
|
|
|
+ if (wParam == VK_RETURN)
|
|
|
+ {
|
|
|
+ StartYanzheng();
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else if (wParam == VK_ESCAPE)
|
|
|
+ {
|
|
|
+ Close(IDCANCEL);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CZhengcanKaitaiWnd::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("zhengcan_kaitai_input_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;
|
|
|
+}
|
|
|
+
|
|
|
+void CZhengcanKaitaiWnd::Notify(TNotifyUI& msg)
|
|
|
+{
|
|
|
+ if (msg.sType == _T("click"))
|
|
|
+ {
|
|
|
+ DuiLib::CDuiString senderName = msg.pSender->GetName();
|
|
|
+
|
|
|
+ if (senderName == _T("closebtn"))
|
|
|
+ {
|
|
|
+ Close(IDCANCEL);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else if (senderName == _T("save"))
|
|
|
+ {
|
|
|
+ StartYanzheng();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_1")
|
|
|
+ {
|
|
|
+ CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
|
+ wstring wsReason = pContent->GetText();
|
|
|
+
|
|
|
+ wsReason += L"1";
|
|
|
+
|
|
|
+ pContent->SetText(wsReason.c_str());
|
|
|
+ pContent->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_2")
|
|
|
+ {
|
|
|
+ CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
|
+ wstring wsReason = pContent->GetText();
|
|
|
+
|
|
|
+ wsReason += L"2";
|
|
|
+
|
|
|
+ pContent->SetText(wsReason.c_str());
|
|
|
+ pContent->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_3")
|
|
|
+ {
|
|
|
+ CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
|
+ wstring wsReason = pContent->GetText();
|
|
|
+
|
|
|
+ wsReason += L"3";
|
|
|
+
|
|
|
+ pContent->SetText(wsReason.c_str());
|
|
|
+ pContent->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_4")
|
|
|
+ {
|
|
|
+ CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
|
+ wstring wsReason = pContent->GetText();
|
|
|
+
|
|
|
+ wsReason += L"4";
|
|
|
+
|
|
|
+ pContent->SetText(wsReason.c_str());
|
|
|
+ pContent->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_5")
|
|
|
+ {
|
|
|
+ CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
|
+ wstring wsReason = pContent->GetText();
|
|
|
+
|
|
|
+ wsReason += L"5";
|
|
|
+
|
|
|
+ pContent->SetText(wsReason.c_str());
|
|
|
+ pContent->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_6")
|
|
|
+ {
|
|
|
+ CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
|
+ wstring wsReason = pContent->GetText();
|
|
|
+
|
|
|
+ wsReason += L"6";
|
|
|
+
|
|
|
+ pContent->SetText(wsReason.c_str());
|
|
|
+ pContent->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_7")
|
|
|
+ {
|
|
|
+ CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
|
+ wstring wsReason = pContent->GetText();
|
|
|
+
|
|
|
+ wsReason += L"7";
|
|
|
+
|
|
|
+ pContent->SetText(wsReason.c_str());
|
|
|
+ pContent->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_8")
|
|
|
+ {
|
|
|
+ CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
|
+ wstring wsReason = pContent->GetText();
|
|
|
+
|
|
|
+ wsReason += L"8";
|
|
|
+
|
|
|
+ pContent->SetText(wsReason.c_str());
|
|
|
+ pContent->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_9")
|
|
|
+ {
|
|
|
+ CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
|
+ wstring wsReason = pContent->GetText();
|
|
|
+
|
|
|
+ wsReason += L"9";
|
|
|
+
|
|
|
+ pContent->SetText(wsReason.c_str());
|
|
|
+ pContent->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_0")
|
|
|
+ {
|
|
|
+ CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
|
+ wstring wsReason = pContent->GetText();
|
|
|
+
|
|
|
+ wsReason += L"0";
|
|
|
+
|
|
|
+ pContent->SetText(wsReason.c_str());
|
|
|
+ pContent->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_x")
|
|
|
+ {
|
|
|
+ CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
|
+ wstring wsReason = pContent->GetText();
|
|
|
+
|
|
|
+ wsReason = wsReason.substr(0, wsReason.length() - 1);
|
|
|
+
|
|
|
+ pContent->SetText(wsReason.c_str());
|
|
|
+ pContent->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_qingkong")
|
|
|
+ {
|
|
|
+ CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
|
+ wstring wsReason = pContent->GetText();
|
|
|
+
|
|
|
+ wsReason.clear();
|
|
|
+
|
|
|
+ pContent->SetText(wsReason.c_str());
|
|
|
+ pContent->SetFocus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (msg.sType == _T("textchanged"))
|
|
|
+ {
|
|
|
+ //只能输入数字,其他的全部删除
|
|
|
+ CEditUI* m_pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
|
+ if (!m_pEdit->GetText().IsEmpty())
|
|
|
+ {
|
|
|
+ wstring ws_Value = m_pEdit->GetText();
|
|
|
+ string strValue = CLewaimaiString::UnicodeToUTF8(ws_Value);
|
|
|
+
|
|
|
+ for (size_t nIndex = 0; nIndex < strValue.length(); nIndex++)
|
|
|
+ {
|
|
|
+ unsigned char tmp = strValue.at(nIndex);
|
|
|
+ if (tmp > 57 || tmp < 48)
|
|
|
+ {
|
|
|
+ //ASCII码不是数字的都过滤掉
|
|
|
+ strValue = strValue.substr(0, nIndex);
|
|
|
+
|
|
|
+ m_pEdit->SetText(CLewaimaiString::UTF8ToUnicode(strValue).c_str());
|
|
|
+ m_pEdit->SetSel(strValue.length(), strValue.length());//重设给光标设置位置
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (msg.sType == L"windowinit")
|
|
|
+ {
|
|
|
+ m_pm.SetNextTabControl(false);
|
|
|
+
|
|
|
+ CEditUI* pFukuanEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
|
+ pFukuanEdit->SetFocus();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void CZhengcanKaitaiWnd::Init()
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+std::string CZhengcanKaitaiWnd::getContent()
|
|
|
+{
|
|
|
+ return m_content;
|
|
|
+}
|
|
|
+
|
|
|
+void CZhengcanKaitaiWnd::SetTitle(std::wstring title)
|
|
|
+{
|
|
|
+ CLabelUI* pLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("memo_dlg_title")));
|
|
|
+ pLabel->SetText(title.c_str());
|
|
|
+}
|
|
|
+
|
|
|
+void CZhengcanKaitaiWnd::StartYanzheng()
|
|
|
+{
|
|
|
+ CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
|
+ wstring wsReason = pContent->GetText();
|
|
|
+
|
|
|
+ m_content = CLewaimaiString::UnicodeToUTF8(wsReason);
|
|
|
+
|
|
|
+ int canpai = atoi(m_content.c_str());
|
|
|
+
|
|
|
+ Close(IDOK);
|
|
|
+}
|