duilib CDateTimeUI 在Xp下的bug修复
转自:http://my.oschina.net/u/343244/blog/370131
CDateTimeUI 的bug修复。修改CDateTimeWnd的HandleMessage方法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
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); } } } } |
完整代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
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; } |