5858#include " GameClient/GameClient.h"
5959#include " GameLogic/GameLogic.h" // /< @todo for demo, remove
6060#include " GameClient/Mouse.h"
61+ #include " GameClient/Display.h"
62+ #include " GameClient/HeaderTemplate.h"
63+ #include " GameClient/Shell.h"
6164#include " GameClient/IMEManager.h"
6265#include " Win32Device/GameClient/Win32Mouse.h"
6366#include " Win32Device/Common/Win32GameEngine.h"
@@ -294,6 +297,7 @@ static const char *messageToString(unsigned int message)
294297LRESULT CALLBACK WndProc ( HWND hWnd, UINT message,
295298 WPARAM wParam, LPARAM lParam )
296299{
300+ static Bool gInSizeMove = FALSE ;
297301
298302 try
299303 {
@@ -402,7 +406,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message,
402406 // -------------------------------------------------------------------------
403407 case WM_MOVE :
404408 {
405- if (TheMouse)
409+ if (TheMouse && ! gInSizeMove )
406410 TheMouse->refreshCursorCapture ();
407411
408412 break ;
@@ -415,12 +419,60 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message,
415419 if (!gInitializing )
416420 gDoPaint = false ;
417421
418- if (TheMouse)
422+ if (TheMouse && ! gInSizeMove )
419423 TheMouse->refreshCursorCapture ();
420424
421425 break ;
422426 }
423427
428+ case WM_ENTERSIZEMOVE :
429+ {
430+ gInSizeMove = TRUE ;
431+ ::ClipCursor (nullptr );
432+ break ;
433+ }
434+
435+ case WM_EXITSIZEMOVE :
436+ {
437+ gInSizeMove = FALSE ;
438+ if (TheDisplay && TheGlobalData && TheGlobalData->m_windowed )
439+ {
440+ RECT rect;
441+ if (GetClientRect (hWnd, &rect))
442+ {
443+ Int newWidth = rect.right - rect.left ;
444+ Int newHeight = rect.bottom - rect.top ;
445+ if (newWidth > 0 && newHeight > 0 && (newWidth != TheDisplay->getWidth () || newHeight != TheDisplay->getHeight ()))
446+ {
447+ if (TheDisplay->setDisplayMode (newWidth, newHeight, TheDisplay->getBitDepth (), TRUE ))
448+ {
449+ TheWritableGlobalData->m_xResolution = newWidth;
450+ TheWritableGlobalData->m_yResolution = newHeight;
451+
452+ if (TheHeaderTemplateManager)
453+ TheHeaderTemplateManager->onResolutionChanged ();
454+ if (TheMouse)
455+ TheMouse->onResolutionChanged ();
456+
457+ if (TheShell)
458+ TheShell->recreateWindowLayouts ();
459+
460+ if (TheInGameUI)
461+ {
462+ TheInGameUI->recreateControlBar ();
463+ TheInGameUI->refreshCustomUiResources ();
464+ }
465+ }
466+ }
467+ }
468+ }
469+ if (TheMouse)
470+ {
471+ TheMouse->refreshCursorCapture ();
472+ }
473+ break ;
474+ }
475+
424476 // ------------------------------------------------------------------------
425477 case WM_SETFOCUS :
426478 {
@@ -593,12 +645,14 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message,
593645 return 0 ;
594646 }
595647
596- // -------------------------------------------------------------------------
597648 case WM_SETCURSOR :
598649 {
599- if (TheWin32Mouse && (HWND )wParam == ApplicationHWnd)
650+ if (TheWin32Mouse && (HWND )wParam == ApplicationHWnd && LOWORD (lParam) == HTCLIENT )
651+ {
600652 TheWin32Mouse->setCursor (TheWin32Mouse->getMouseCursor ());
601- return TRUE ; // tell Windows not to reset mouse cursor image to default.
653+ return TRUE ; // tell Windows not to reset mouse cursor image to default.
654+ }
655+ break ;
602656 }
603657
604658 case WM_PAINT :
@@ -706,10 +760,10 @@ static Bool initializeAppWindows( HINSTANCE hInstance, Int nCmdShow, Bool runWin
706760 TEXT (" Game Window" ) };
707761 RegisterClass ( &wndClass );
708762
709- // Create our main window
763+ // Create our main window
710764 windowStyle = WS_POPUP |WS_VISIBLE ;
711765 if (runWindowed)
712- windowStyle |= WS_MINIMIZEBOX | WS_SYSMENU | WS_DLGFRAME | WS_CAPTION ;
766+ windowStyle |= WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_SYSMENU | WS_DLGFRAME | WS_CAPTION ;
713767 else
714768 windowStyle |= WS_EX_TOPMOST | WS_SYSMENU ;
715769
0 commit comments