5 #define WIN32_LEAN_AND_MEAN
7 #undef WIN32_LEAN_AND_MEAN
12 #include "Ecore_WinCE.h"
13 #include "ecore_wince_private.h"
16 /***** Private declarations *****/
18 typedef BOOL (__stdcall *UnregisterFunc1Proc)(UINT, UINT);
20 static int _ecore_wince_hardware_keys_register(HWND window);
26 ecore_wince_window_new(Ecore_WinCE_Window *parent,
32 struct _Ecore_WinCE_Window *w;
36 INF("creating window");
38 w = (struct _Ecore_WinCE_Window *)calloc(1, sizeof(struct _Ecore_WinCE_Window));
41 ERR("malloc() failed");
49 if (!AdjustWindowRectEx(&rect, WS_CAPTION | WS_SYSMENU | WS_VISIBLE, FALSE, WS_EX_TOPMOST))
51 ERR("AdjustWindowRectEx() failed");
56 window = CreateWindowEx(WS_EX_TOPMOST,
57 ECORE_WINCE_WINDOW_CLASS,
59 WS_CAPTION | WS_SYSMENU | WS_VISIBLE,
61 rect.right - rect.left, rect.bottom - rect.top,
62 parent ? ((struct _Ecore_WinCE_Window *)parent)->window : NULL,
63 NULL, _ecore_wince_instance, NULL);
66 ERR("CreateWindowEx() failed");
71 if (!_ecore_wince_hardware_keys_register(window))
73 ERR("_ecore_wince_hardware_keys_register() failed");
74 DestroyWindow(window);
82 if (!SetWindowLong(window, GWL_USERDATA, (LONG)w) && (GetLastError() != 0))
84 ERR("SetWindowLong() failed");
85 DestroyWindow(window);
96 ecore_wince_window_free(Ecore_WinCE_Window *window)
100 INF("destroying window");
102 DestroyWindow(((struct _Ecore_WinCE_Window *)window)->window);
107 ecore_wince_window_hwnd_get(Ecore_WinCE_Window *window)
112 return ((struct _Ecore_WinCE_Window *)window)->window;
116 ecore_wince_window_move(Ecore_WinCE_Window *window,
123 if (!window || ((struct _Ecore_WinCE_Window *)window)->fullscreen)
126 INF("moving window (%dx%d)", x, y);
128 w = ((struct _Ecore_WinCE_Window *)window)->window;
129 if (!GetWindowRect(w, &rect))
131 ERR("GetWindowRect() failed");
135 if (!MoveWindow(w, x, y,
136 rect.right - rect.left,
137 rect.bottom - rect.top,
140 ERR("MoveWindow() failed");
145 ecore_wince_window_resize(Ecore_WinCE_Window *window,
150 struct _Ecore_WinCE_Window *w;
156 if (!window || ((struct _Ecore_WinCE_Window *)window)->fullscreen)
159 INF("resizing window (%dx%d)", width, height);
161 w = (struct _Ecore_WinCE_Window *)window;
162 if (!GetWindowRect(w->window, &rect))
164 ERR("GetWindowRect() failed");
173 rect.bottom = height;
174 if (!(style = GetWindowLong(w->window, GWL_STYLE)))
176 ERR("GetWindowLong() failed");
179 if (!(exstyle = GetWindowLong(w->window, GWL_EXSTYLE)))
181 ERR("GetWindowLong() failed");
184 if (!AdjustWindowRectEx(&rect, style, FALSE, exstyle))
186 ERR("AdjustWindowRectEx() failed");
190 if (!MoveWindow(w->window, x, y,
191 rect.right - rect.left,
192 rect.bottom - rect.top,
195 ERR("MoveWindow() failed");
200 ecore_wince_window_move_resize(Ecore_WinCE_Window *window,
207 struct _Ecore_WinCE_Window *w;
211 if (!window || ((struct _Ecore_WinCE_Window *)window)->fullscreen)
214 INF("moving and resizing window (%dx%d %dx%d)", x, y, width, height);
216 w = ((struct _Ecore_WinCE_Window *)window);
220 rect.bottom = height;
221 if (!(style = GetWindowLong(w->window, GWL_STYLE)))
223 ERR("GetWindowLong() failed");
226 if (!(exstyle = GetWindowLong(w->window, GWL_EXSTYLE)))
228 ERR("GetWindowLong() failed");
231 if (!AdjustWindowRectEx(&rect, style, FALSE, exstyle))
233 ERR("AdjustWindowRectEx() failed");
237 if (!MoveWindow(w->window, x, y,
238 rect.right - rect.left,
239 rect.bottom - rect.top,
242 ERR("MoveWindow() failed");
247 ecore_wince_window_show(Ecore_WinCE_Window *window)
251 INF("showing window");
253 if (!ShowWindow(((struct _Ecore_WinCE_Window *)window)->window, SW_SHOWNORMAL))
255 ERR("ShowWindow() failed");
258 if (!UpdateWindow(((struct _Ecore_WinCE_Window *)window)->window))
260 ERR("UpdateWindow() failed");
262 if (!SendMessage(((struct _Ecore_WinCE_Window *)window)->window, WM_SHOWWINDOW, 1, 0))
264 ERR("SendMessage() failed");
269 ecore_wince_window_hide(Ecore_WinCE_Window *window)
273 INF("hiding window");
275 if (!ShowWindow(((struct _Ecore_WinCE_Window *)window)->window, SW_HIDE))
277 ERR("ShowWindow() failed");
280 if (!SendMessage(((struct _Ecore_WinCE_Window *)window)->window, WM_SHOWWINDOW, 0, 0))
282 ERR("SendMessage() failed");
287 ecore_wince_window_title_set(Ecore_WinCE_Window *window,
294 if (!title || !title[0]) return;
296 INF("setting window title");
298 wtitle = evil_char_to_wchar(title);
301 if (!SetWindowText(((struct _Ecore_WinCE_Window *)window)->window, wtitle))
303 ERR("SetWindowText() failed");
309 ecore_wince_window_backend_set(Ecore_WinCE_Window *window, int backend)
311 struct _Ecore_WinCE_Window *w;
316 INF("setting backend");
318 w = (struct _Ecore_WinCE_Window *)window;
319 w->backend = backend;
323 ecore_wince_window_suspend_set(Ecore_WinCE_Window *window, int (*suspend)(int))
325 struct _Ecore_WinCE_Window *w;
330 INF("setting suspend callback");
332 w = (struct _Ecore_WinCE_Window *)window;
333 w->suspend = suspend;
337 ecore_wince_window_resume_set(Ecore_WinCE_Window *window, int (*resume)(int))
339 struct _Ecore_WinCE_Window *w;
344 INF("setting resume callback");
346 w = (struct _Ecore_WinCE_Window *)window;
351 ecore_wince_window_geometry_get(Ecore_WinCE_Window *window,
361 INF("getting window geometry");
367 if (width) *width = GetSystemMetrics(SM_CXSCREEN);
368 if (height) *height = GetSystemMetrics(SM_CYSCREEN);
373 if (!GetClientRect(((struct _Ecore_WinCE_Window *)window)->window,
376 ERR("GetClientRect() failed");
380 if (width) *width = 0;
381 if (height) *height = 0;
386 w = rect.right - rect.left;
387 h = rect.bottom - rect.top;
389 if (!GetWindowRect(((struct _Ecore_WinCE_Window *)window)->window,
392 ERR("GetWindowRect() failed");
396 if (width) *width = 0;
397 if (height) *height = 0;
402 if (x) *x = rect.left;
403 if (y) *y = rect.top;
404 if (width) *width = w;
405 if (height) *height = h;
409 ecore_wince_window_size_get(Ecore_WinCE_Window *window,
415 INF("getting window size");
419 if (width) *width = GetSystemMetrics(SM_CXSCREEN);
420 if (height) *height = GetSystemMetrics(SM_CYSCREEN);
425 if (!GetClientRect(((struct _Ecore_WinCE_Window *)window)->window,
428 ERR("GetClientRect() failed");
430 if (width) *width = 0;
431 if (height) *height = 0;
434 if (width) *width = rect.right - rect.left;
435 if (height) *height = rect.bottom - rect.top;
439 ecore_wince_window_fullscreen_set(Ecore_WinCE_Window *window,
442 struct _Ecore_WinCE_Window *ew;
448 ew = (struct _Ecore_WinCE_Window *)window;
449 if (((ew->fullscreen) && (on)) ||
450 ((!ew->fullscreen) && (!on)))
453 INF("setting fullscreen: %s", on ? "yes" : "no");
455 ew->fullscreen = !!on;
460 /* save the position and size of the window */
461 if (!GetWindowRect(w, &ew->rect))
463 ERR("GetWindowRect() failed");
468 task_bar = FindWindow(L"HHTaskBar", NULL);
471 INF("FindWindow(): can not find task bar");
473 if (!ShowWindow(task_bar, SW_HIDE))
475 INF("ShowWindow(): task bar already hidden");
477 if (!EnableWindow(task_bar, FALSE))
479 INF("EnableWindow(): input already disabled");
482 /* style: visible + popup */
483 if (!SetWindowLong(w, GWL_STYLE, WS_POPUP | WS_VISIBLE))
485 INF("SetWindowLong() failed");
488 /* resize window to fit the entire screen */
489 if (!SetWindowPos(w, HWND_TOPMOST,
491 GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
492 SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED))
494 INF("SetWindowPos() failed");
497 * It seems that SetWindowPos is not sufficient.
498 * Call MoveWindow with the correct size and force painting.
499 * Note that UpdateWindow (forcing repainting) is not sufficient
503 GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
506 INF("MoveWindow() failed");
512 task_bar = FindWindow(L"HHTaskBar", NULL);
515 INF("FindWindow(): can not find task bar");
517 if (!ShowWindow(task_bar, SW_SHOW))
519 INF("ShowWindow(): task bar already visible");
521 if (!EnableWindow(task_bar, TRUE))
523 INF("EnableWindow(): input already enabled");
526 /* style: visible + caption + sysmenu */
527 if (!SetWindowLong(w, GWL_STYLE, WS_CAPTION | WS_SYSMENU | WS_VISIBLE))
529 INF("SetWindowLong() failed");
531 /* restaure the position and size of the window */
532 if (!SetWindowPos(w, HWND_TOPMOST,
535 ew->rect.right - ew->rect.left,
536 ew->rect.bottom - ew->rect.top,
537 SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED))
539 INF("SetWindowLong() failed");
542 * It seems that SetWindowPos is not sufficient.
543 * Call MoveWindow with the correct size and force painting.
544 * Note that UpdateWindow (forcing repainting) is not sufficient
549 ew->rect.right - ew->rect.left,
550 ew->rect.bottom - ew->rect.top,
553 INF("MoveWindow() failed");
559 /***** Private functions definitions *****/
562 _ecore_wince_hardware_keys_register(HWND window)
565 UnregisterFunc1Proc unregister_fct;
568 core_dll = LoadLibrary(L"coredll.dll");
571 ERR("LoadLibrary() failed");
575 unregister_fct = (UnregisterFunc1Proc)GetProcAddress(core_dll, L"UnregisterFunc1");
578 ERR("GetProcAddress() failed");
579 FreeLibrary(core_dll);
583 for (i = 0xc1; i <= 0xcf; i++)
585 unregister_fct(MOD_WIN, i);
586 RegisterHotKey(window, i, MOD_WIN, i);
589 FreeLibrary(core_dll);