首页 > C/C++ > Duilib CDateTimeUI 时间控件 在XP、WIN2003系统上选取日期没有反应问题bug
2015
10-09

Duilib CDateTimeUI 时间控件 在XP、WIN2003系统上选取日期没有反应问题bug

1、找到文件 DuiLib\Control\UIDateTime.cpp 修改 HandleMessage为以下

	LRESULT CDateTimeWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
	{
		LRESULT lRes = 0;
		BOOL bHandled = TRUE;

		if (WM_NOTIFY == uMsg)
		{
			::SetFocus(m_hWnd);
		}

		if( uMsg == WM_KILLFOCUS )
		{
			//lRes = OnKillFocus(uMsg, wParam, lParam, bHandled);
			HWND hSysMonthCal32 = ::FindWindow(_T("SysMonthCal32"), NULL);
			DWORD dwProcessId = 0;
			GetWindowThreadProcessId(hSysMonthCal32, &dwProcessId);
			if (::IsWindow(hSysMonthCal32) && (GetCurrentProcessId() == dwProcessId))
			{
				MCHITTESTINFO pp;
				memset(&pp, 0, sizeof(pp));
				GetCursorPos(&pp.pt);
				::ScreenToClient(hSysMonthCal32, &pp.pt);
				pp.cbSize = sizeof(pp);
				MonthCal_HitTest(hSysMonthCal32, &pp);
				//下一个月
				if (pp.uHit == MCHT_TITLEBTNNEXT)
				{
					return 1;
				}
				//上一个月
				if (pp.uHit == MCHT_TITLEBTNPREV)
				{
					return 1;
				}
			}
			else
			{
				POINT pt;
				::GetCursorPos(&pt);
				RECT rt;
				::GetWindowRect(m_hWnd, &rt);
				if (
					!(pt.x >= rt.left&&pt.x <= rt.right) ||
					!(pt.x >= rt.top&&pt.x <= rt.bottom)
					)
				{
					lRes = OnKillFocus(uMsg, wParam, lParam, bHandled);
				}

			}
		}
		else if (uMsg == WM_KEYUP && (wParam == VK_DELETE || wParam == VK_BACK))
		{
			LRESULT lRes = ::DefWindowProc(m_hWnd, uMsg, wParam, lParam);
			m_pOwner->m_nDTUpdateFlag = DT_DELETE;
			m_pOwner->UpdateText();
			PostMessage(WM_CLOSE);
			return lRes;
		}
		else if (uMsg == WM_KEYUP && wParam == VK_ESCAPE)
		{
			LRESULT lRes = ::DefWindowProc(m_hWnd, uMsg, wParam, lParam);
			m_pOwner->m_nDTUpdateFlag = DT_KEEP;
			PostMessage(WM_CLOSE);
			return lRes;
		}
		else bHandled = FALSE;
		if( !bHandled ) return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
		return lRes;
	}

 

参考链接

http://my.oschina.net/u/343244/blog/370131

最后编辑:
作者:dnybz
这个作者貌似有点懒,什么都没有留下。