(svn r5874) -Feature [FS#234]: Remember the maximized state and restore on start. This also fixes a bug where a different resolution is chosen for a maximized window, but it retains the maximized flag. Only win32.
authorDarkvater
Sun, 13 Aug 2006 10:22:34 +0000
changeset 4258 3ac20963213d
parent 4257 c738085d561e
child 4259 71b8dba85ce1
(svn r5874) -Feature [FS#234]: Remember the maximized state and restore on start. This also fixes a bug where a different resolution is chosen for a maximized window, but it retains the maximized flag. Only win32.
settings.c
video/win32_v.c
--- a/settings.c	Sun Aug 13 08:51:55 2006 +0000
+++ b/settings.c	Sun Aug 13 10:22:34 2006 +0000
@@ -1157,7 +1157,7 @@
 
 /* win32_v.c only settings */
 #ifdef WIN32
-extern bool _force_full_redraw, _double_size;
+extern bool _force_full_redraw, _double_size, _window_maximize;
 extern uint _display_hz, _fullscreen_bpp;
 
 static const SettingDescGlobVarList _win32_settings[] = {
@@ -1165,6 +1165,7 @@
 	SDTG_BOOL("force_full_redraw",        S, 0, _force_full_redraw,false,     STR_NULL, NULL),
 	 SDTG_VAR("fullscreen_bpp", SLE_UINT, S, 0, _fullscreen_bpp,   8, 8,  32, STR_NULL, NULL),
 	SDTG_BOOL("double_size",              S, 0, _double_size,      false,     STR_NULL, NULL),
+	SDTG_BOOL("window_maximize",          S, 0, _window_maximize,  false,     STR_NULL, NULL),
 	 SDTG_END()
 };
 #endif /* WIN32 */
--- a/video/win32_v.c	Sun Aug 13 08:51:55 2006 +0000
+++ b/video/win32_v.c	Sun Aug 13 10:22:34 2006 +0000
@@ -29,6 +29,7 @@
 
 bool _force_full_redraw;
 bool _double_size;
+bool _window_maximize;
 uint _display_hz;
 uint _fullscreen_bpp;
 
@@ -265,6 +266,7 @@
 		} else {
 			AskExitGame();
 		}
+		_window_maximize = IsZoomed(_wnd.main_wnd);
 		return 0;
 
 	case WM_LBUTTONDOWN:
@@ -565,6 +567,7 @@
 		y = (GetSystemMetrics(SM_CYSCREEN) - h) / 2;
 
 		if (_wnd.main_wnd) {
+			ShowWindow(_wnd.main_wnd, SW_SHOWNORMAL); // remove maximize-flag
 			SetWindowPos(_wnd.main_wnd, 0, x, y, w, h, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER);
 		} else {
 			char Windowtitle[50];
@@ -572,8 +575,13 @@
 			snprintf(Windowtitle, lengthof(Windowtitle), "OpenTTD %s", _openttd_revision);
 
 			_wnd.main_wnd = CreateWindow("OTTD", Windowtitle, style, x, y, w, h, 0, 0, GetModuleHandle(NULL), 0);
-			if (_wnd.main_wnd == NULL)
-				error("CreateWindow failed");
+			if (_wnd.main_wnd == NULL) error("CreateWindow failed");
+
+			/* On startup let's see if we quit maximized the last time, restore that */
+			if (_window_maximize) {
+				ShowWindow(_wnd.main_wnd, SW_MAXIMIZE);
+				_window_maximize = false;
+			}
 		}
 	}
 	GameSizeChanged(); // invalidate all windows, force redraw