(svn r7562) -Fix (r7060, 5874): It seems windows doesn't have the same functionality for CreateWindow when starting a program from the console or from the GUI. Because of this starting OpenTTD from the desktop wouldn't maximize the window, even if the config file said so. So work around this...
authorDarkvater
Tue, 26 Dec 2006 13:30:48 +0000
changeset 5565 4eae079a5609
parent 5564 6e1b3ea1ba7f
child 5566 02b1ecccc540
(svn r7562) -Fix (r7060, 5874): It seems windows doesn't have the same functionality for CreateWindow when starting a program from the console or from the GUI. Because of this starting OpenTTD from the desktop wouldn't maximize the window, even if the config file said so. So work around this...
video/win32_v.c
--- a/video/win32_v.c	Tue Dec 26 12:56:48 2006 +0000
+++ b/video/win32_v.c	Tue Dec 26 13:30:48 2006 +0000
@@ -564,17 +564,18 @@
 
 	{
 		RECT r;
-		uint style;
+		DWORD style, showstyle;
 		int x, y, w, h;
 
+		showstyle = SW_SHOWNORMAL;
 		_wnd.fullscreen = full_screen;
 		if (_wnd.fullscreen) {
-			style = WS_POPUP | WS_VISIBLE;
+			style = WS_POPUP;
 			SetRect(&r, 0, 0, _wnd.width_org, _wnd.height_org);
 		} else {
-			style = WS_OVERLAPPEDWINDOW | WS_VISIBLE;
+			style = WS_OVERLAPPEDWINDOW;
 			/* On window creation, check if we were in maximize mode before */
-			if (_window_maximize) style |= WS_MAXIMIZE;
+			if (_window_maximize) showstyle = SW_SHOWMAXIMIZED;
 			SetRect(&r, 0, 0, _wnd.width, _wnd.height);
 		}
 
@@ -595,6 +596,7 @@
 
 			_wnd.main_wnd = CreateWindow(_T("OTTD"), Windowtitle, style, x, y, w, h, 0, 0, GetModuleHandle(NULL), 0);
 			if (_wnd.main_wnd == NULL) error("CreateWindow failed");
+			ShowWindow(_wnd.main_wnd, showstyle);
 		}
 	}
 	GameSizeChanged(); // invalidate all windows, force redraw