From 42cf8cbb250539f239f53dc1fb4c3475d988460d Mon Sep 17 00:00:00 2001 From: doursse Date: Thu, 10 Jul 2008 07:01:49 +0000 Subject: [PATCH] make the windows non resizable on Windows, fix error management for the glew and software_16_ddraw tests SVN revision: 35050 --- src/bin/engine_direct3d.cpp | 6 +++++ src/bin/engine_gl_glew.c | 31 ++++++++++++++++++----- src/bin/engine_software_16_ddraw.cpp | 37 +++++++++++++++++++++------- src/bin/engine_software_ddraw.cpp | 6 +++++ 4 files changed, 65 insertions(+), 15 deletions(-) diff --git a/src/bin/engine_direct3d.cpp b/src/bin/engine_direct3d.cpp index e9e1e78..6304781 100644 --- a/src/bin/engine_direct3d.cpp +++ b/src/bin/engine_direct3d.cpp @@ -221,6 +221,12 @@ engine_direct3d_args(int argc, char **argv) if (!window) goto unregister_class; + /* make the window non resizable */ + style = GetWindowLong(window, GWL_STYLE); + style &= ~WS_THICKFRAME; + if (!SetWindowLong(window, GWL_STYLE, style)) + goto unregister_class; + dc = GetDC(NULL); if (!dc) goto destroy_window; diff --git a/src/bin/engine_gl_glew.c b/src/bin/engine_gl_glew.c index 63926c1..d4c32d6 100644 --- a/src/bin/engine_gl_glew.c +++ b/src/bin/engine_gl_glew.c @@ -188,7 +188,8 @@ engine_gl_glew_args(int argc, char **argv) } if (!ok) return 0; - hinstance = GetModuleHandle(0); + hinstance = GetModuleHandle(NULL); + if (!instance) return 0; wc.style = 0; wc.lpfnWndProc = MainWndProc; @@ -201,7 +202,8 @@ engine_gl_glew_args(int argc, char **argv) wc.lpszMenuName = NULL; wc.lpszClassName = "Evas_Gl_Glew_Test"; - if(!RegisterClass(&wc)) return EXIT_FAILURE; + if(!RegisterClass(&wc)) + goto free_library; rect.left = 0; rect.top = 0; @@ -216,24 +218,41 @@ engine_gl_glew_args(int argc, char **argv) CW_USEDEFAULT, CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, hinstance, NULL); - if (!window) return 0; + if (!window) + goto unregister_class; - ShowWindow(window, SW_SHOWDEFAULT); - UpdateWindow(window); + /* make the window non resizable */ + style = GetWindowLong(window, GWL_STYLE); + style &= ~WS_THICKFRAME; + if (!SetWindowLong(window, GWL_STYLE, style)) + goto unregister_class; evas_output_method_set(evas, evas_render_method_lookup("gl_glew")); einfo = (Evas_Engine_Info_GL_Glew *)evas_engine_info_get(evas); if (!einfo) { printf("Evas does not support the GL Glew Engine\n"); - return 0; + goto destroy_window; } einfo->info.window = window; einfo->info.depth = depth; evas_engine_info_set(evas, (Evas_Engine_Info *) einfo); + /* the second parameter is ignored, as it's the first call of ShowWindow */ + ShowWindow(window, SW_SHOWDEFAULT); + UpdateWindow(window); + return 1; + + destroy_window: + DestroyWindow(window); + unregister_class: + UnregisterClass("Evas_Gl_Glew_Test", instance); + free_library: + FreeLibrary(instance); + + return 0; } void diff --git a/src/bin/engine_software_16_ddraw.cpp b/src/bin/engine_software_16_ddraw.cpp index 00359b8..6811fcc 100644 --- a/src/bin/engine_software_16_ddraw.cpp +++ b/src/bin/engine_software_16_ddraw.cpp @@ -262,7 +262,7 @@ engine_software_16_ddraw_args(int argc, char **argv) { WNDCLASS wc; RECT rect; - HINSTANCE hinstance; + HINSTANCE instance; LPDIRECTDRAW object; LPDIRECTDRAWSURFACE surface_primary; LPDIRECTDRAWSURFACE surface_back; @@ -284,20 +284,22 @@ engine_software_16_ddraw_args(int argc, char **argv) } if (!ok) return 0; - hinstance = GetModuleHandle(0); + instance = GetModuleHandle(NULL); + if (!instance) return 0; wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = MainWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; - wc.hInstance = hinstance; + wc.hInstance = instance; wc.hIcon = LoadIcon (NULL, IDI_APPLICATION); wc.hCursor = LoadCursor (NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE); wc.lpszMenuName = NULL; wc.lpszClassName = "Evas_Software_16_DDraw_Test"; - if(!RegisterClass(&wc)) return EXIT_FAILURE; + if(!RegisterClass(&wc)) + goto free_library; style = WS_OVERLAPPEDWINDOW | WS_SIZEBOX; exstyle = 0; @@ -314,8 +316,15 @@ engine_software_16_ddraw_args(int argc, char **argv) style, CW_USEDEFAULT, CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, - NULL, NULL, hinstance, NULL); - if (!window) return EXIT_FAILURE; + NULL, NULL, instance, NULL); + if (!window) + goto unregister_class; + + /* make the window non resizable */ + style = GetWindowLong(window, GWL_STYLE); + style &= ~WS_THICKFRAME; + if (!SetWindowLong(window, GWL_STYLE, style)) + goto unregister_class; if (!_directdraw_init(window, win_w, win_h, &object, @@ -323,14 +332,15 @@ engine_software_16_ddraw_args(int argc, char **argv) &surface_back, &surface_source, &depth)) - return EXIT_FAILURE; + goto destroy_window; evas_output_method_set(evas, evas_render_method_lookup("software_16_ddraw")); einfo = (Evas_Engine_Info_Software_16_DDraw *)evas_engine_info_get(evas); if (!einfo) { - fprintf(stderr, "Evas does not support the 16 bits Software DirectDraw Engine\n"); - return EXIT_FAILURE; + fprintf(stderr, "Evas does not support the 16 bits Software DirectDraw Engine\n"); + /* should shutdown ddraw */ + goto destroy_window; } einfo->info.window = window; @@ -347,6 +357,15 @@ engine_software_16_ddraw_args(int argc, char **argv) UpdateWindow(window); return 1; + + destroy_window: + DestroyWindow(window); + unregister_class: + UnregisterClass("Evas_Software_16_DDraw_Test", instance); + free_library: + FreeLibrary(instance); + + return 0; } void diff --git a/src/bin/engine_software_ddraw.cpp b/src/bin/engine_software_ddraw.cpp index 65a6dda..e39e409 100644 --- a/src/bin/engine_software_ddraw.cpp +++ b/src/bin/engine_software_ddraw.cpp @@ -225,6 +225,12 @@ engine_software_ddraw_args(int argc, char **argv) if (!window) goto unregister_class; + /* make the window non resizable */ + style = GetWindowLong(window, GWL_STYLE); + style &= ~WS_THICKFRAME; + if (!SetWindowLong(window, GWL_STYLE, style)) + goto unregister_class; + dc = GetDC(NULL); if (!dc) goto destroy_window;