|
|
@@ -1,338 +0,0 @@
|
|
|
-#include "../pch/pch.h"
|
|
|
-#include "CRengongYouhuiWnd.h"
|
|
|
-
|
|
|
-LRESULT CRengongYouhuiWnd::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 CRengongYouhuiWnd::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 CRengongYouhuiWnd::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 CRengongYouhuiWnd::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 CRengongYouhuiWnd::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("rengongyouhui_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 CRengongYouhuiWnd::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 CRengongYouhuiWnd::Init()
|
|
|
-{
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-std::string CRengongYouhuiWnd::getContent()
|
|
|
-{
|
|
|
- return m_content;
|
|
|
-}
|
|
|
-
|
|
|
-void CRengongYouhuiWnd::SetTitle(std::wstring title)
|
|
|
-{
|
|
|
- CLabelUI* pLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("memo_dlg_title")));
|
|
|
- pLabel->SetText(title.c_str());
|
|
|
-}
|
|
|
-
|
|
|
-void CRengongYouhuiWnd::StartYanzheng()
|
|
|
-{
|
|
|
- CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
|
- wstring wsReason = pContent->GetText();
|
|
|
-
|
|
|
- m_content = CLewaimaiString::UnicodeToUTF8(wsReason);
|
|
|
-
|
|
|
- int zhekou = atoi(m_content.c_str());
|
|
|
- if (zhekou > 100 || zhekou < 0)
|
|
|
- {
|
|
|
- CLabelUI* pErrorInfo = static_cast<CLabelUI*>(m_pm.FindControl(_T("errinfo")));
|
|
|
- pErrorInfo->SetText(L"优惠金额只能为0到100之间的整数");
|
|
|
- pErrorInfo->SetVisible(true);
|
|
|
-
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- Close(IDOK);
|
|
|
-}
|