@@ -193,78 +193,54 @@ void CHW::Reset (HWND hwnd)
193193
194194void CHW::updateWindowProps (HWND m_hWnd)
195195{
196- // BOOL bWindowed = strstr(Core.Params,"-dedicated") ? TRUE : !psDeviceFlags.is (rsFullscreen);
197- BOOL bWindowed = !psDeviceFlags.is (rsFullscreen);
198-
199- u32 dwWindowStyle = 0 ;
200- // Set window properties depending on what mode were in.
201- if (bWindowed) {
202- if (strstr (Core.Params , " -no_dialog_header" ))
203- SetWindowLong (m_hWnd, GWL_STYLE, dwWindowStyle = (WS_BORDER | WS_VISIBLE));
204- else
205- SetWindowLong (m_hWnd, GWL_STYLE, dwWindowStyle = (WS_BORDER | WS_DLGFRAME | WS_VISIBLE | WS_SYSMENU | WS_MINIMIZEBOX));
206-
207- // Change to default resolution
208- ChangeDisplaySettings (nullptr , CDS_FULLSCREEN);
209- }
210- else {
211- SetWindowLong (m_hWnd, GWL_STYLE, dwWindowStyle = (WS_POPUP | WS_VISIBLE));
212-
213- DEVMODE dmScreenSettings;
214- memset (&dmScreenSettings, 0 , sizeof (dmScreenSettings));
215- dmScreenSettings.dmSize = sizeof (dmScreenSettings);
216- dmScreenSettings.dmPelsWidth = psCurrentVidMode[0 ];
217- dmScreenSettings.dmPelsHeight = psCurrentVidMode[1 ];
218- dmScreenSettings.dmBitsPerPel = 32 ;
219- dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
220-
221- // Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
222- ChangeDisplaySettings (&dmScreenSettings, CDS_FULLSCREEN);
223- }
196+ bool bWindowed = true ;
197+ #ifndef _EDITOR
198+ if (!GEnv.isDedicatedServer )
199+ bWindowed = !psDeviceFlags.is (rsFullscreen);
200+ #endif
224201
225- if (m_move_window) {
226- // When moving from fullscreen to windowed mode, it is important to
227- // adjust the window size after recreating the device rather than
228- // beforehand to ensure that you get the window size you want. For
229- // example, when switching from 640x480 fullscreen to windowed with
230- // a 1000x600 window on a 1024x768 desktop, it is impossible to set
231- // the window size to 1000x600 until after the display mode has
232- // changed to 1024x768, because windows cannot be larger than the
233- // desktop.
234-
235- RECT m_rcWindowBounds;
236- BOOL bCenter = FALSE ;
237- if (strstr (Core.Params , " -center_screen" )) bCenter = TRUE ;
238-
239- if (bCenter) {
240- RECT DesktopRect;
241-
242- GetClientRect (GetDesktopWindow (), &DesktopRect);
243-
244- SetRect (&m_rcWindowBounds,
245- (DesktopRect.right - psCurrentVidMode[0 ]) / 2 ,
246- (DesktopRect.bottom - psCurrentVidMode[1 ]) / 2 ,
247- (DesktopRect.right + psCurrentVidMode[0 ]) / 2 ,
248- (DesktopRect.bottom + psCurrentVidMode[1 ]) / 2 );
249- }
250- else {
251- SetRect (&m_rcWindowBounds,
252- 0 ,
253- 0 ,
254- psCurrentVidMode[0 ],
255- psCurrentVidMode[1 ]);
256- }
257-
258- AdjustWindowRect (&m_rcWindowBounds, dwWindowStyle, FALSE );
259-
260- SetWindowPos (m_hWnd,
261- HWND_TOP,
262- m_rcWindowBounds.left ,
263- m_rcWindowBounds.top ,
264- (m_rcWindowBounds.right - m_rcWindowBounds.left ),
265- (m_rcWindowBounds.bottom - m_rcWindowBounds.top ),
266- SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_DRAWFRAME);
267- }
202+ u32 dwWindowStyle = 0 ;
203+ // Set window properties depending on what mode were in.
204+ if (bWindowed)
205+ {
206+ if (m_move_window)
207+ {
208+ dwWindowStyle = WS_BORDER | WS_VISIBLE;
209+ if (!strstr (Core.Params , " -no_dialog_header" ))
210+ dwWindowStyle |= WS_DLGFRAME | WS_SYSMENU | WS_MINIMIZEBOX;
211+ SetWindowLong (m_hWnd, GWL_STYLE, dwWindowStyle);
212+ // When moving from fullscreen to windowed mode, it is important to
213+ // adjust the window size after recreating the device rather than
214+ // beforehand to ensure that you get the window size you want. For
215+ // example, when switching from 640x480 fullscreen to windowed with
216+ // a 1000x600 window on a 1024x768 desktop, it is impossible to set
217+ // the window size to 1000x600 until after the display mode has
218+ // changed to 1024x768, because windows cannot be larger than the
219+ // desktop.
220+
221+ RECT m_rcWindowBounds;
222+ RECT DesktopRect;
223+
224+ GetClientRect (GetDesktopWindow (), &DesktopRect);
225+
226+ SetRect (&m_rcWindowBounds,
227+ (DesktopRect.right - psCurrentVidMode[0 ]) / 2 ,
228+ (DesktopRect.bottom - psCurrentVidMode[1 ]) / 2 ,
229+ (DesktopRect.right + psCurrentVidMode[0 ]) / 2 ,
230+ (DesktopRect.bottom + psCurrentVidMode[1 ]) / 2 );
231+
232+ AdjustWindowRect (&m_rcWindowBounds, dwWindowStyle, FALSE );
233+
234+ SetWindowPos (m_hWnd, HWND_NOTOPMOST, m_rcWindowBounds.left , m_rcWindowBounds.top ,
235+ (m_rcWindowBounds.right - m_rcWindowBounds.left ),
236+ (m_rcWindowBounds.bottom - m_rcWindowBounds.top ),
237+ SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_DRAWFRAME);
238+ }
239+ }
240+ else
241+ {
242+ SetWindowLong (m_hWnd, GWL_STYLE, dwWindowStyle = (WS_POPUP | WS_VISIBLE));
243+ }
268244
269245 ShowCursor (FALSE );
270246 SetForegroundWindow (m_hWnd);
0 commit comments