From: "Changhui Liu" Subject: comctl32: SysDateTimePick32 control add Alt+down hot key likewindows (try 3) Message-Id: Date: Mon, 2 Mar 2015 13:16:49 +0800 Superseded patch 109383 http://source.winehq.org/patches/data/109383 Change log: 1, fixed test fail on vista Windows. 2,Update DTN_DROPDOWN and DTN_CLOSEUP notification test. 3,Remove faking click point coordinates . ------------------ Regards, Changhui.
Superseded patch 109383
http://source.winehq.org/patches/data/109383

Change log:
1, fixed test fail on vista Windows.
2,Update DTN_DROPDOWN and DTN_CLOSEUP notification test. 
3,Remove faking click point coordinates .




------------------
Regards,
Changhui.
 
From ffcc6645f7d52de343c20fc3de298be4ce2cd5e1 Mon Sep 17 00:00:00 2001 From: Changhui Liu Date: Thu, 26 Feb 2015 11:25:47 +0800 Subject: comctl32: SysDateTimePick32 add Alt+down hot key like windows To: wine-patches Reply-To: wine-devel --- dlls/comctl32/datetime.c | 29 +++++++--- dlls/comctl32/tests/datetime.c | 124 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+), 8 deletions(-) diff --git a/dlls/comctl32/datetime.c b/dlls/comctl32/datetime.c index 5c73a90..3982edb 100644 --- a/dlls/comctl32/datetime.c +++ b/dlls/comctl32/datetime.c @@ -951,15 +951,8 @@ DATETIME_SetSelectedField (DATETIME_INFO *infoPtr, int select) } static LRESULT -DATETIME_LButtonDown (DATETIME_INFO *infoPtr, INT x, INT y) +DATETIME_HitResponse (DATETIME_INFO *infoPtr, int new) { - POINT pt; - int new; - - pt.x = x; - pt.y = y; - new = DATETIME_HitTest (infoPtr, pt); - SetFocus(infoPtr->hwndSelf); if (!(new & DTHT_NODATEMASK) || (new == DTHT_NONE)) @@ -1029,6 +1022,19 @@ DATETIME_LButtonDown (DATETIME_INFO *infoPtr, INT x, INT y) return 0; } +static LRESULT +DATETIME_LButtonDown (DATETIME_INFO *infoPtr, INT x, INT y) +{ + POINT pt; + int new; + + pt.x = x; + pt.y = y; + new = DATETIME_HitTest (infoPtr, pt); + + return DATETIME_HitResponse(infoPtr, new); +} + static LRESULT DATETIME_LButtonUp (DATETIME_INFO *infoPtr) @@ -1668,6 +1674,13 @@ DATETIME_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_SETTEXT: return CB_ERR; + case WM_SYSKEYDOWN: + if (wParam == VK_DOWN) + { + return DATETIME_HitResponse (infoPtr, DTHT_MCPOPUP); + } + /*else continue to DefWindowProcW*/ + default: if ((uMsg >= WM_USER) && (uMsg < WM_APP) && !COMCTL32_IsReflectedMessage(uMsg)) ERR("unknown msg %04x wp=%08lx lp=%08lx\n", diff --git a/dlls/comctl32/tests/datetime.c b/dlls/comctl32/tests/datetime.c index 195c719..ec56a6e 100644 --- a/dlls/comctl32/tests/datetime.c +++ b/dlls/comctl32/tests/datetime.c @@ -670,6 +670,8 @@ static void test_dtm_set_and_get_system_time(void) expect(4, (LRESULT)getSt.wDayOfWeek); st.wDayOfWeek = 4; expect_systime(&st, &getSt); + + DestroyWindow(hWnd); } static void test_dtm_set_and_get_systemtime_with_limits(void) @@ -782,6 +784,127 @@ static void test_dts_shownone(void) DestroyWindow(hwnd); } +static HWND g_hWndDateTime = NULL; +static HWND g_hWndMonthCal = NULL; + +static void log_notify_msg (int code) +{ + struct message msg; + msg.message = code; + msg.flags = sent; + msg.wParam = 0; + msg.lParam = 0; + msg.id = 0; + + add_message(sequences, DATETIME_SEQ_INDEX, &msg); +} + +static LRESULT WINAPI dtm_hotkey_wnd_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + if (WM_NOTIFY == message) + { + NMHDR* hdr = (NMHDR*)lParam; + + if (hdr->code == DTN_DROPDOWN) + { + log_notify_msg(DTN_DROPDOWN); + trace("open SysMonthCal32=%p\n", g_hWndMonthCal); + g_hWndMonthCal = (HWND)SendMessageA(hdr->hwndFrom, DTM_GETMONTHCAL, 0, 0); + } + else if (hdr->code == DTN_CLOSEUP) + { + log_notify_msg(DTN_CLOSEUP); + trace("closed SysMonthCal32=%p\n", g_hWndMonthCal); + } + } + + switch (message) + { + case WM_DESTROY: + PostQuitMessage(0); + break; + default: + return DefWindowProcA(hWnd, message, wParam, lParam); + } + + return 0; +} + +static DWORD WINAPI send_msg_thread(void* param) +{ + POINT pt; + RECT rect; + GetClientRect(g_hWndDateTime, &rect); + pt.x = rect.right - GetSystemMetrics(SM_CXVSCROLL)/2; + pt.y = rect.top + GetSystemMetrics(SM_CYHSCROLL)/2; + + PostMessageA(g_hWndDateTime, WM_SYSKEYDOWN, VK_DOWN, 0); + + Sleep(1000); /*Wait the SysMonthCal32 control to show*/ + + /*Close the SysMonthCal32 control*/ + PostMessageA(g_hWndDateTime, WM_LBUTTONDOWN, 1, MAKEWPARAM(pt.x, pt.y) ); + + PostMessageA((HWND)param, WM_CLOSE, 0, 0); + + return 0; +} + +static void test_dtm_hotkey(void) +{ + HANDLE thread = NULL; + HWND parent = NULL; + BOOL success; + WNDCLASSEXA wc; + MSG msg; + const char cls_name[] = "test_dtm_hotkey"; + const struct message test_dtm_hotkey_seq[] = { + { DTN_DROPDOWN, sent, 0, 0 }, + { DTN_CLOSEUP, sent, 0, 0 }, + { 0 } + }; + + memset(&wc, 0, sizeof(wc)); + wc.cbSize = sizeof(wc); + wc.style = CS_VREDRAW | CS_HREDRAW; + wc.hInstance = GetModuleHandleA(0); + wc.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_ARROW); + wc.hbrBackground = NULL; + wc.lpszClassName = cls_name; + wc.lpfnWndProc = dtm_hotkey_wnd_proc; + success = RegisterClassExA(&wc) != 0; + ok(success, "RegisterClassExA failed %u\n", GetLastError()); + + parent = CreateWindowExA(0, cls_name, NULL, WS_OVERLAPPEDWINDOW, + 50, 50, 300, 120, NULL, NULL, NULL, NULL); + ok(parent != NULL, "Expected window to be valid\n"); + + g_hWndDateTime = CreateWindowExA(0, DATETIMEPICK_CLASSA, NULL, WS_VISIBLE|WS_CHILD|DTS_SHOWNONE, + 10, 10, 100, 20, parent, NULL, NULL, NULL); + ok(g_hWndDateTime != NULL, "Expected DateTimePick32 window to be valid\n"); + + ShowWindow(parent, SW_NORMAL); + UpdateWindow(parent); + + thread = CreateThread (NULL, 0, send_msg_thread, (void*)parent, 0, 0); + + flush_sequences(sequences, NUM_MSG_SEQUENCES); + + while (GetMessageA(&msg, NULL, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessageA(&msg); + } + + WaitForSingleObject(thread, INFINITE); + + ok(g_hWndMonthCal != NULL, "Expected SysMonthCal32 window to be valid\n"); + + ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_hotkey_seq, "test_dtm_hotkey", FALSE); + + DestroyWindow(parent); +} + START_TEST(datetime) { HMODULE hComctl32; @@ -811,4 +934,5 @@ START_TEST(datetime) test_dtm_set_and_get_systemtime_with_limits(); test_wm_set_get_text(); test_dts_shownone(); + test_dtm_hotkey(); } -- 1.9.1