CDateTimeUI Xp下的bug修复

CDateTimeUI 的bug修复。修改CDateTimeWnd的HandleMessage方法

if(WM_NOTIFY==uMsg)
{
    ::SetFocus(m_hWnd);
}
if( uMsg == WM_KILLFOCUS /**/)
{
      ::OutputDebugString("WM_KILLFOCUS\n");
      if( uMsg == WM_KILLFOCUS /**/)
       {
            //这里肯可能需要优化,因为FindWindow找出来的窗口不一定是本进程的窗口
            HWND hh=::FindWindow(_T("SysMonthCal32"),NULL);
            if(::IsWindow(hh))
            {
                 MCHITTESTINFO pp;
                 memset(&pp,0,sizeof(pp));
                 //pp.uHit=MCHT_CALENDAR;
                 GetCursorPos(&pp.pt);
                 ::ScreenToClient(hh,&pp.pt);
                 pp.cbSize=sizeof(pp);
                 MonthCal_HitTest(hh,&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)
                 )
                {
                    ::OutputDebugString("CLose\n");
                    lRes= OnKillFocus(uMsg,wParam, lParam,bHandled);
                }
             }
       }
}

完整代码:

LRESULT CDateTimeWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
	{
		LRESULT lRes = 0;
		BOOL bHandled = TRUE;
		/**xpBug***/
		DWORD ProcessId;
		if(WM_SETFOCUS==uMsg)
		{
		    ::OutputDebugString("WM_SETFOCUS\n");
		}
		if(WM_NOTIFY==uMsg)
		{
			::SetFocus(m_hWnd);
		}
		if( uMsg == WM_KILLFOCUS /**/)
		{
			::OutputDebugString("WM_KILLFOCUS\n");
			if( uMsg == WM_KILLFOCUS /**/)
			{
				//这里肯可能需要优化,因为FindWindow找出来的窗口不一定是本进程的窗口
				HWND hh=::FindWindow(_T("SysMonthCal32"),NULL);
				//Isdel=true;
				if(::IsWindow(hh))
				{
					MCHITTESTINFO pp;
					memset(&pp,0,sizeof(pp));
					GetCursorPos(&pp.pt);
					::ScreenToClient(hh,&pp.pt);
					pp.cbSize=sizeof(pp);
					MonthCal_HitTest(hh,&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)
						)
					{
						::OutputDebugString("CLose\n");
						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;
	}


你可能感兴趣的:(XP,bug,duilib,CDateTimeUI)