Advertisement
Guest User

snes9xgit: [gocha] Improved window resize accuracy, it should work better for 1x.

a guest
Jan 10th, 2011
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.19 KB | None | 0 0
  1. From 623d954df672d3c63884d8ed0cf95a43b366a5d1 Mon Sep 17 00:00:00 2001
  2. From: gocha <gochaism@gmail.com>
  3. Date: Mon, 10 Jan 2011 13:42:01 +0900
  4. Subject: [PATCH 1/3] Improved window resize accuracy, it should work better for 1x.
  5.  Thanks http://blogs.msdn.com/b/oldnewthing/archive/2003/09/11/54885.aspx
  6.  
  7. ---
  8. win32/wsnes9x.cpp |   32 +++++++++++++++++++++++---------
  9.  1 files changed, 23 insertions(+), 9 deletions(-)
  10.  
  11. diff --git a/win32/wsnes9x.cpp b/win32/wsnes9x.cpp
  12. index f353532..23f1f79 100644
  13. --- a/win32/wsnes9x.cpp
  14. +++ b/win32/wsnes9x.cpp
  15. @@ -2058,15 +2058,29 @@ LRESULT CALLBACK WinProc(
  16.         case ID_WINDOW_SIZE_2X:
  17.         case ID_WINDOW_SIZE_3X:
  18.         case ID_WINDOW_SIZE_4X:
  19. -           UINT factor,newWidth,newHeight;
  20. -           factor = (wParam & 0xffff) - ID_WINDOW_SIZE_1X + 1;
  21. -           newWidth = GUI.AspectWidth * factor;
  22. -           newHeight = (GUI.HeightExtend ? SNES_HEIGHT_EXTENDED : SNES_HEIGHT) * factor;
  23. -           newWidth += 2*(GetSystemMetrics(SM_CXBORDER) + GetSystemMetrics(SM_CXDLGFRAME));
  24. -           newHeight += 2*(GetSystemMetrics(SM_CYBORDER) + GetSystemMetrics(SM_CYDLGFRAME)) +
  25. -               GetSystemMetrics(SM_CYCAPTION) + (GUI.HideMenu ? 0 : (GetSystemMetrics(SM_CYMENU) +
  26. -                         (factor<2 ? GetSystemMetrics(SM_CYMENU) : 0)));
  27. -           SetWindowPos(GUI.hWnd,0,0,0,newWidth,newHeight,SWP_NOMOVE);
  28. +           {
  29. +               UINT factor, newWidth, newHeight;
  30. +               factor = (wParam & 0xffff) - ID_WINDOW_SIZE_1X + 1;
  31. +               newWidth = GUI.AspectWidth * factor;
  32. +               newHeight = (GUI.HeightExtend ? SNES_HEIGHT_EXTENDED : SNES_HEIGHT) * factor;
  33. +
  34. +               RECT rcWindow = { 0, 0, newWidth, newHeight };
  35. +               AdjustWindowRectEx(&rcWindow, GetWindowStyle(GUI.hWnd), !GUI.HideMenu, GetWindowExStyle(GUI.hWnd));
  36. +
  37. +               if (!GUI.HideMenu)
  38. +               {
  39. +                   RECT rcTemp = rcWindow;
  40. +                   rcTemp.bottom = 0x7FFF; // "Infinite" height
  41. +                   SendMessage(GUI.hWnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rcTemp);
  42. +
  43. +                   // Adjust our previous calculation to compensate for menu
  44. +                   // wrapping.
  45. +                   rcWindow.bottom += rcTemp.top;
  46. +               }
  47. +
  48. +               SetWindowPos(GUI.hWnd, NULL, 0, 0, rcWindow.right - rcWindow.left,
  49. +                   rcWindow.bottom - rcWindow.top, SWP_NOMOVE);
  50. +           }
  51.             break;
  52.         case ID_WINDOW_STRETCH:
  53.             GUI.Stretch = !GUI.Stretch;
  54. --
  55. 1.7.3.1.msysgit.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement