Created
July 17, 2011 13:38
-
-
Save DosAmp/1087598 to your computer and use it in GitHub Desktop.
Windows tool for resizing Minecraft to a specific frame size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#define MC_LAUNCHER_WINDOW_TITLE L"Minecraft Launcher" | |
#define MC_GAME_WINDOW_TITLE L"Minecraft" | |
#define TARGET_WIDTH 432 | |
#define TARGET_HEIGHT 240 | |
// method by Guy Lecky-Thompson | |
// http://www.suite101.com/content/client-area-size-with-movewindow-a17846 | |
BOOL WindowClientResize(HWND hWnd, int nWidth, int nHeight) { | |
RECT rcClient, rcWindow; | |
POINT ptDiff; | |
GetClientRect(hWnd, &rcClient); | |
GetWindowRect(hWnd, &rcWindow); | |
ptDiff.x = (rcWindow.right - rcWindow.left) - rcClient.right; | |
ptDiff.y = (rcWindow.bottom - rcWindow.top) - rcClient.bottom; | |
return MoveWindow(hWnd,rcWindow.left, rcWindow.top, nWidth + ptDiff.x, | |
nHeight + ptDiff.y, TRUE); | |
} | |
int main() { | |
// first try finding the launcher window | |
HWND mcWindow = FindWindowW(NULL, MC_LAUNCHER_WINDOW_TITLE); | |
if (mcWindow == NULL) { | |
// if that doesn't succeed, look for the actual game window | |
mcWindow = FindWindowW(NULL, MC_GAME_WINDOW_TITLE); | |
} | |
if (mcWindow != NULL) { | |
// 0 when resizing was successful, 1 otherwise | |
return !WindowClientResize(mcWindow, TARGET_WIDTH, TARGET_HEIGHT); | |
} | |
else { | |
// no Minecraft window found | |
return 2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment