diff --git a/docs/integration/driver/windows.rst b/docs/integration/driver/windows.rst index 7dc5016e4..c2bd9e8d7 100644 --- a/docs/integration/driver/windows.rst +++ b/docs/integration/driver/windows.rst @@ -35,7 +35,9 @@ Application Mode Prerequisites ------------- -The minimum Windows OS version this driver supported is Windows Server 2003, or Windows XP with East Asian language support installed because the input method integration support need that. +The tested minimum Windows OS requirement for this driver is Windows XP RTM. + +According to the Windows GDI API this driver used. Maybe the minimum Windows OS requirement for this driver is Windows 2000 RTM. Configure Windows driver -------------------- diff --git a/src/dev/windows/lv_windows_context.c b/src/dev/windows/lv_windows_context.c index 9c37230a3..7bb1f4a35 100644 --- a/src/dev/windows/lv_windows_context.c +++ b/src/dev/windows/lv_windows_context.c @@ -97,12 +97,12 @@ void lv_windows_platform_init(void) window_class.cbWndExtra = 0; window_class.hInstance = NULL; window_class.hIcon = NULL; - window_class.hCursor = LoadCursorW(NULL, IDC_ARROW); + window_class.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW); window_class.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); window_class.lpszMenuName = NULL; window_class.lpszClassName = L"LVGL.Window"; window_class.hIconSm = NULL; - LV_ASSERT_NULL(RegisterClassExW(&window_class)); + LV_ASSERT(RegisterClassExW(&window_class)); } lv_windows_window_context_t * lv_windows_get_window_context( diff --git a/src/dev/windows/lv_windows_display.c b/src/dev/windows/lv_windows_display.c index b21e8642e..958338ec6 100644 --- a/src/dev/windows/lv_windows_display.c +++ b/src/dev/windows/lv_windows_display.c @@ -71,7 +71,7 @@ lv_display_t * lv_windows_create_display( &data, 0, NULL); - LV_ASSERT_NULL(thread); + LV_ASSERT(thread); WaitForSingleObjectEx(data.mutex, INFINITE, FALSE); @@ -154,7 +154,7 @@ static unsigned int __stdcall lv_windows_display_thread_entrypoint( ShowWindow(window_handle, SW_SHOW); UpdateWindow(window_handle); - LV_ASSERT_NULL(SetEvent(data->mutex)); + LV_ASSERT(SetEvent(data->mutex)); data = NULL; diff --git a/src/dev/windows/lv_windows_input.c b/src/dev/windows/lv_windows_input.c index b92a8ca6d..9830261cb 100644 --- a/src/dev/windows/lv_windows_input.c +++ b/src/dev/windows/lv_windows_input.c @@ -15,10 +15,6 @@ #include -#if _MSC_VER >= 1200 - #pragma comment(lib, "Imm32.lib") -#endif - #include "../../widgets/textarea/lv_textarea.h" #include "../../widgets/keyboard/lv_keyboard.h" @@ -475,6 +471,85 @@ static void lv_windows_push_key_to_keyboard_queue( } } +static HIMC lv_windows_imm_get_context( + HWND window_handle) +{ + HMODULE module_handle = GetModuleHandleW(L"imm32.dll"); + if(!module_handle) { + return FALSE; + } + + typedef HIMC(WINAPI * function_type)(HWND); + + function_type function = (function_type)( + GetProcAddress(module_handle, "ImmGetContext")); + if(!function) { + return FALSE; + } + + return function(window_handle); +} + +static BOOL lv_windows_imm_release_context( + HWND window_handle, + HIMC imm_context_handle) +{ + HMODULE module_handle = GetModuleHandleW(L"imm32.dll"); + if(!module_handle) { + return FALSE; + } + + typedef BOOL(WINAPI * function_type)(HWND, HIMC); + + function_type function = (function_type)( + GetProcAddress(module_handle, "ImmReleaseContext")); + if(!function) { + return FALSE; + } + + return function(window_handle, imm_context_handle); +} + +static HIMC lv_windows_imm_associate_context( + HWND window_handle, + HIMC imm_context_handle) +{ + HMODULE module_handle = GetModuleHandleW(L"imm32.dll"); + if(!module_handle) { + return FALSE; + } + + typedef HIMC(WINAPI * function_type)(HWND, HIMC); + + function_type function = (function_type)( + GetProcAddress(module_handle, "ImmAssociateContext")); + if(!function) { + return FALSE; + } + + return function(window_handle, imm_context_handle); +} + +static BOOL lv_windows_imm_set_composition_window( + HIMC imm_context_handle, + LPCOMPOSITIONFORM composition_form) +{ + HMODULE module_handle = GetModuleHandleW(L"imm32.dll"); + if(!module_handle) { + return FALSE; + } + + typedef BOOL(WINAPI * function_type)(HIMC, LPCOMPOSITIONFORM); + + function_type function = (function_type)( + GetProcAddress(module_handle, "ImmSetCompositionWindow")); + if(!function) { + return FALSE; + } + + return function(imm_context_handle, composition_form); +} + bool lv_windows_keypad_device_window_message_handler( HWND hWnd, UINT uMsg, @@ -602,10 +677,14 @@ bool lv_windows_keypad_device_window_message_handler( } case WM_IME_SETCONTEXT: { if(wParam == TRUE) { - HIMC input_method_context_handle = ImmGetContext(hWnd); - if(input_method_context_handle) { - ImmAssociateContext(hWnd, input_method_context_handle); - ImmReleaseContext(hWnd, input_method_context_handle); + HIMC imm_context_handle = lv_windows_imm_get_context(hWnd); + if(imm_context_handle) { + lv_windows_imm_associate_context( + hWnd, + imm_context_handle); + lv_windows_imm_release_context( + hWnd, + imm_context_handle); } } @@ -613,8 +692,8 @@ bool lv_windows_keypad_device_window_message_handler( break; } case WM_IME_STARTCOMPOSITION: { - HIMC input_method_context_handle = ImmGetContext(hWnd); - if(input_method_context_handle) { + HIMC imm_context_handle = lv_windows_imm_get_context(hWnd); + if(imm_context_handle) { lv_obj_t * textarea_object = NULL; lv_obj_t * focused_object = lv_group_get_focused( lv_group_get_default()); @@ -645,12 +724,12 @@ bool lv_windows_keypad_device_window_message_handler( label_object->coords.y1 + textarea->cursor.area.y1; } - ImmSetCompositionWindow( - input_method_context_handle, + lv_windows_imm_set_composition_window( + imm_context_handle, &composition_form); - ImmReleaseContext( + lv_windows_imm_release_context( hWnd, - input_method_context_handle); + imm_context_handle); } *plResult = DefWindowProcW(hWnd, uMsg, wParam, wParam); diff --git a/src/lv_init.c b/src/lv_init.c index 613547829..716bf60e8 100644 --- a/src/lv_init.c +++ b/src/lv_init.c @@ -40,7 +40,7 @@ #include "draw/vg_lite/lv_draw_vg_lite.h" #endif #if LV_USE_WINDOWS - #include "src/dev/windows/lv_windows_context.h" + #include "dev/windows/lv_windows_context.h" #endif /*********************