Resize handling entirely remade, it should work flawlessly now, even under Vista.

Except there's still a display bug when using a rotation of 90 or 270 degrees :( but hopefully I should fix this quickly enough
This commit is contained in:
luigi__ 2009-01-10 21:02:13 +00:00
parent 2fec8603f6
commit 9690913aa0
3 changed files with 439 additions and 257 deletions

View File

@ -1,180 +1,300 @@
/* Copyright (C) 2006 yopyop /* Copyright (C) 2006 yopyop
yopyop156@ifrance.com yopyop156@ifrance.com
yopyop156.ifrance.com yopyop156.ifrance.com
This file is part of DeSmuME This file is part of DeSmuME
DeSmuME is free software; you can redistribute it and/or modify DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
DeSmuME is distributed in the hope that it will be useful, DeSmuME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "CWindow.h" #include "CWindow.h"
#include "debug.h" #include "debug.h"
WINCLASS::WINCLASS(LPSTR rclass, HINSTANCE hInst) WINCLASS::WINCLASS(LPSTR rclass, HINSTANCE hInst)
{ {
memset(regclass, 0, sizeof(regclass)); memset(regclass, 0, sizeof(regclass));
memcpy(regclass, rclass, strlen(rclass)); memcpy(regclass, rclass, strlen(rclass));
hwnd = NULL; hwnd = NULL;
hmenu = NULL; hmenu = NULL;
hInstance = hInst; hInstance = hInst;
}
minWidth = 0;
WINCLASS::~WINCLASS() minHeight = 0;
{ }
}
WINCLASS::~WINCLASS()
bool WINCLASS::create(LPSTR caption, int x, int y, int width, int height, int style, HMENU menu) {
{ }
if (hwnd != NULL) return false;
bool WINCLASS::create(LPSTR caption, int x, int y, int width, int height, int style, HMENU menu)
hwnd = CreateWindow(regclass, caption, style, x, y, width, height, NULL, menu, hInstance, NULL); {
if (hwnd != NULL) return false;
if (hwnd != NULL) return true;
return false; hwnd = CreateWindow(regclass, caption, style, x, y, width, height, NULL, menu, hInstance, NULL);
}
if (hwnd != NULL) return true;
bool WINCLASS::createEx(LPSTR caption, int x, int y, int width, int height, int style, int styleEx, HMENU menu) return false;
{ }
if (hwnd != NULL) return false;
bool WINCLASS::createEx(LPSTR caption, int x, int y, int width, int height, int style, int styleEx, HMENU menu)
hwnd = CreateWindowEx(styleEx, regclass, caption, style, x, y, width, height, NULL, menu, hInstance, NULL); {
if (hwnd != NULL) return false;
if (hwnd != NULL) return true;
return false; hwnd = CreateWindowEx(styleEx, regclass, caption, style, x, y, width, height, NULL, menu, hInstance, NULL);
}
if (hwnd != NULL) return true;
bool WINCLASS::setMenu(HMENU menu) return false;
{ }
hmenu = menu;
return SetMenu(hwnd, hmenu); bool WINCLASS::setMenu(HMENU menu)
} {
hmenu = menu;
DWORD WINCLASS::checkMenu(UINT idd, UINT check) return SetMenu(hwnd, hmenu);
{ }
return CheckMenuItem(hmenu, idd, check);
} DWORD WINCLASS::checkMenu(UINT idd, UINT check)
{
HWND WINCLASS::getHWnd() return CheckMenuItem(hmenu, idd, check);
{ }
return hwnd;
} HWND WINCLASS::getHWnd()
{
void WINCLASS::Show(int mode) return hwnd;
{ }
ShowWindow(hwnd, mode);
} void WINCLASS::Show(int mode)
{
void WINCLASS::Hide() ShowWindow(hwnd, mode);
{ }
ShowWindow(hwnd, SW_HIDE);
} void WINCLASS::Hide()
{
//========================================================= Thread class ShowWindow(hwnd, SW_HIDE);
extern DWORD WINAPI ThreadProc(LPVOID lpParameter) }
{
THREADCLASS *tmp = (THREADCLASS *)lpParameter; void WINCLASS::setMinSize(int width, int height)
return tmp->ThreadFunc(); {
} minWidth = width;
minHeight = height;
THREADCLASS::THREADCLASS() }
{
hThread = NULL; void WINCLASS::sizingMsg(WPARAM wParam, LPARAM lParam, BOOL keepRatio)
} {
RECT *rect = (RECT*)lParam;
THREADCLASS::~THREADCLASS()
{ int _minWidth, _minHeight;
closeThread();
} int xborder, yborder;
int ymenu, ymenunew;
void THREADCLASS::closeThread() int ycaption;
{
if (hThread) MENUBARINFO mbi;
{
CloseHandle(hThread); /* Get the size of the border */
hThread = NULL; xborder = GetSystemMetrics(SM_CXSIZEFRAME);
} yborder = GetSystemMetrics(SM_CYSIZEFRAME);
}
/* Get the size of the menu bar */
bool THREADCLASS::createThread() ZeroMemory(&mbi, sizeof(mbi));
{ mbi.cbSize = sizeof(mbi);
if (hThread) return false; GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi);
ymenu = (mbi.rcBar.bottom - mbi.rcBar.top + 1);
hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadProc, this, 0, &threadID);
if (!hThread) return false; /* Get the size of the caption bar */
//WaitForSingleObject(hThread, INFINITE); ycaption = GetSystemMetrics(SM_CYCAPTION);
return true;
} /* Calculate the minimum size in pixels */
_minWidth = (xborder + minWidth + xborder);
//========================================================= Tools class _minHeight = (ycaption + yborder + ymenu + minHeight + yborder);
TOOLSCLASS::TOOLSCLASS(HINSTANCE hInst, int IDD, DLGPROC dlgproc)
{ /* Clamp the size to the minimum size (256x384) */
this->dlgproc = dlgproc; rect->right = (rect->left + std::max(_minWidth, (int)(rect->right - rect->left)));
hwnd = NULL; rect->bottom = (rect->top + std::max(_minHeight, (int)(rect->bottom - rect->top)));
hInstance = hInst;
idd=IDD; /* Apply the ratio stuff */
memset(class_name, 0, sizeof(class_name)); if(keepRatio)
memset(class_name2, 0, sizeof(class_name2)); {
} switch(wParam)
{
TOOLSCLASS::~TOOLSCLASS() case WMSZ_LEFT:
{ case WMSZ_RIGHT:
close(); case WMSZ_TOPLEFT:
} case WMSZ_TOPRIGHT:
case WMSZ_BOTTOMLEFT:
bool TOOLSCLASS::open() case WMSZ_BOTTOMRIGHT:
{ {
if (!createThread()) return false; float ratio = ((rect->right - rect->left - xborder - xborder) / (float)minWidth);
return true; rect->bottom = (rect->top + ycaption + yborder + ymenu + (minHeight * ratio) + yborder);
} }
break;
bool TOOLSCLASS::close()
{ case WMSZ_TOP:
return true; case WMSZ_BOTTOM:
} {
float ratio = ((rect->bottom - rect->top - ycaption - yborder - ymenu - yborder) / (float)minHeight);
DWORD TOOLSCLASS::ThreadFunc() rect->right = (rect->left + xborder + (minWidth * ratio) + xborder);
{ }
MSG messages; break;
LOG("Start thread\n"); }
}
GetLastError();
hwnd = CreateDialog(hInstance, MAKEINTRESOURCE(idd), NULL, (DLGPROC) dlgproc); /* Check if the height of the menu has changed during the resize */
ZeroMemory(&mbi, sizeof(mbi));
if (!hwnd) mbi.cbSize = sizeof(mbi);
{ GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi);
LOG("error creating dialog\n"); ymenunew = (mbi.rcBar.bottom - mbi.rcBar.top + 1);
return (-2);
} if(ymenunew != ymenu)
rect->bottom += (ymenunew - ymenu);
ShowWindow(hwnd, SW_SHOW); }
UpdateWindow(hwnd);
void WINCLASS::setClientSize(int width, int height)
while (GetMessage (&messages, NULL, 0, 0)) {
{ int xborder, yborder;
TranslateMessage(&messages); int ymenu, ymenunew;
DispatchMessage(&messages); int ycaption;
}
MENUBARINFO mbi;
unregClass();
hwnd = NULL; RECT wndRect;
int finalx, finaly;
closeThread();
return 0; /* Get the size of the border */
} xborder = GetSystemMetrics(SM_CXSIZEFRAME);
yborder = GetSystemMetrics(SM_CYSIZEFRAME);
/* Get the size of the menu bar */
ZeroMemory(&mbi, sizeof(mbi));
mbi.cbSize = sizeof(mbi);
GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi);
ymenu = (mbi.rcBar.bottom - mbi.rcBar.top + 1);
/* Get the size of the caption bar */
ycaption = GetSystemMetrics(SM_CYCAPTION);
/* Finally, resize the window */
GetWindowRect(hwnd, &wndRect);
finalx = (xborder + width + xborder);
finaly = (ycaption + yborder + ymenu + height + yborder);
MoveWindow(hwnd, wndRect.left, wndRect.top, finalx, finaly, TRUE);
/* Oops, we also need to check if the height */
/* of the menu bar has changed after the resize */
ZeroMemory(&mbi, sizeof(mbi));
mbi.cbSize = sizeof(mbi);
GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi);
ymenunew = (mbi.rcBar.bottom - mbi.rcBar.top + 1);
if(ymenunew != ymenu)
MoveWindow(hwnd, wndRect.left, wndRect.top, finalx, (finaly + (ymenunew - ymenu)), TRUE);
}
//========================================================= Thread class
extern DWORD WINAPI ThreadProc(LPVOID lpParameter)
{
THREADCLASS *tmp = (THREADCLASS *)lpParameter;
return tmp->ThreadFunc();
}
THREADCLASS::THREADCLASS()
{
hThread = NULL;
}
THREADCLASS::~THREADCLASS()
{
closeThread();
}
void THREADCLASS::closeThread()
{
if (hThread)
{
CloseHandle(hThread);
hThread = NULL;
}
}
bool THREADCLASS::createThread()
{
if (hThread) return false;
hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadProc, this, 0, &threadID);
if (!hThread) return false;
//WaitForSingleObject(hThread, INFINITE);
return true;
}
//========================================================= Tools class
TOOLSCLASS::TOOLSCLASS(HINSTANCE hInst, int IDD, DLGPROC dlgproc)
{
this->dlgproc = dlgproc;
hwnd = NULL;
hInstance = hInst;
idd=IDD;
memset(class_name, 0, sizeof(class_name));
memset(class_name2, 0, sizeof(class_name2));
}
TOOLSCLASS::~TOOLSCLASS()
{
close();
}
bool TOOLSCLASS::open()
{
if (!createThread()) return false;
return true;
}
bool TOOLSCLASS::close()
{
return true;
}
DWORD TOOLSCLASS::ThreadFunc()
{
MSG messages;
LOG("Start thread\n");
GetLastError();
hwnd = CreateDialog(hInstance, MAKEINTRESOURCE(idd), NULL, (DLGPROC) dlgproc);
if (!hwnd)
{
LOG("error creating dialog\n");
return (-2);
}
ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd);
while (GetMessage (&messages, NULL, 0, 0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
unregClass();
hwnd = NULL;
closeThread();
return 0;
}
void TOOLSCLASS::regClass(LPSTR class_name, WNDPROC wproc, bool SecondReg) void TOOLSCLASS::regClass(LPSTR class_name, WNDPROC wproc, bool SecondReg)
{ {
WNDCLASSEX wc; WNDCLASSEX wc;
@ -198,18 +318,18 @@ void TOOLSCLASS::regClass(LPSTR class_name, WNDPROC wproc, bool SecondReg)
wc.hIconSm = 0; wc.hIconSm = 0;
RegisterClassEx(&wc); RegisterClassEx(&wc);
} }
void TOOLSCLASS::unregClass() void TOOLSCLASS::unregClass()
{ {
if (class_name[0]) if (class_name[0])
{ {
UnregisterClass(class_name, hInstance); UnregisterClass(class_name, hInstance);
} }
if (class_name2[0]) if (class_name2[0])
{ {
UnregisterClass(class_name2, hInstance); UnregisterClass(class_name2, hInstance);
} }
memset(class_name, 0, sizeof(class_name)); memset(class_name, 0, sizeof(class_name));
memset(class_name2, 0, sizeof(class_name2)); memset(class_name2, 0, sizeof(class_name2));
} }

View File

@ -31,6 +31,7 @@ private:
HMENU hmenu; HMENU hmenu;
HINSTANCE hInstance; HINSTANCE hInstance;
char regclass[256]; char regclass[256];
int minWidth, minHeight;
public: public:
WINCLASS(LPSTR rclass, HINSTANCE hInst); WINCLASS(LPSTR rclass, HINSTANCE hInst);
~WINCLASS(); ~WINCLASS();
@ -47,6 +48,11 @@ public:
void Hide(); void Hide();
HWND getHWnd(); HWND getHWnd();
void setMinSize(int width, int height);
void sizingMsg(WPARAM wParam, LPARAM lParam, BOOL keepRatio = FALSE);
void setClientSize(int width, int height);
}; };
class THREADCLASS class THREADCLASS

View File

@ -511,6 +511,18 @@ void ScaleScreen(HWND hwnd, float factor)
widthTradeOff + DefaultWidth * factor, SWP_NOMOVE | SWP_NOZORDER); widthTradeOff + DefaultWidth * factor, SWP_NOMOVE | SWP_NOZORDER);
} }
} }
void ScaleScreen(float factor)
{
if((GPU_rotation == 0) || (GPU_rotation == 180))
{
MainWindow->setClientSize((256 * factor), (384 * factor));
}
else
{
MainWindow->setClientSize((384 * factor), (256 * factor));
}
}
void translateXY(s32& x, s32& y) void translateXY(s32& x, s32& y)
{ {
@ -1242,8 +1254,7 @@ int RegClass(WNDPROC Proc, LPCTSTR szName)
wc.cbClsExtra = wc.cbWndExtra=0; wc.cbClsExtra = wc.cbWndExtra=0;
wc.lpfnWndProc=Proc; wc.lpfnWndProc=Proc;
wc.hInstance=hAppInst; wc.hInstance=hAppInst;
wc.hIcon=LoadIcon(hAppInst,MAKEINTRESOURCE(IDI_APPLICATION)); wc.hIcon=LoadIcon(hAppInst,"ICONDESMUME");
//wc.hIconSm=LoadIcon(hAppInst,MAKEINTRESOURCE(IDI_APPLICATION));
wc.hCursor=LoadCursor(NULL,IDC_ARROW); wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground=(HBRUSH)(COLOR_BACKGROUND); wc.hbrBackground=(HBRUSH)(COLOR_BACKGROUND);
wc.lpszMenuName=(LPCTSTR)NULL; wc.lpszMenuName=(LPCTSTR)NULL;
@ -1305,10 +1316,10 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
case NDS_ADDON_RUMBLEPAK: case NDS_ADDON_RUMBLEPAK:
break; break;
case NDS_ADDON_GBAGAME: case NDS_ADDON_GBAGAME:
if (!strlen(GBAgameName)) if (!strlen(GBAgameName))
{ {
addon_type = NDS_ADDON_NONE; addon_type = NDS_ADDON_NONE;
break; break;
} }
// TODO: check for file exist // TODO: check for file exist
break; break;
@ -1343,10 +1354,8 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
frameCounterDisplay = GetPrivateProfileInt("Display","FrameCounter", 0, IniName); frameCounterDisplay = GetPrivateProfileInt("Display","FrameCounter", 0, IniName);
//sprintf(text, "%s", DESMUME_NAME_AND_VERSION); //sprintf(text, "%s", DESMUME_NAME_AND_VERSION);
MainWindow = new WINCLASS(CLASSNAME, hThisInstance); MainWindow = new WINCLASS(CLASSNAME, hThisInstance);
RECT clientRect = {0,0,256,384};
DWORD dwStyle = WS_CAPTION| WS_SYSMENU | WS_SIZEBOX | WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; DWORD dwStyle = WS_CAPTION| WS_SYSMENU | WS_SIZEBOX | WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
AdjustWindowRect(&clientRect,dwStyle,TRUE); if (!MainWindow->create(DESMUME_NAME_AND_VERSION, WndX/*CW_USEDEFAULT*/, WndY/*CW_USEDEFAULT*/, 256,384,
if (!MainWindow->create(DESMUME_NAME_AND_VERSION, WndX/*CW_USEDEFAULT*/, WndY/*CW_USEDEFAULT*/, clientRect.right-clientRect.left,clientRect.bottom-clientRect.top,
WS_CAPTION| WS_SYSMENU | WS_SIZEBOX | WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_CAPTION| WS_SYSMENU | WS_SIZEBOX | WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
NULL)) NULL))
{ {
@ -1355,7 +1364,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
exit(-1); exit(-1);
} }
/* default the firmware settings, they may get changed later */ /* default the firmware settings, they may get changed later */
NDS_FillDefaultFirmwareConfigData( &win_fw_config); NDS_FillDefaultFirmwareConfigData( &win_fw_config);
GetPrivateProfileString("General", "Language", "0", text, 80, IniName); GetPrivateProfileString("General", "Language", "0", text, 80, IniName);
@ -1374,6 +1383,28 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
exit(-1); exit(-1);
} }
if((GPU_rotation == 90) || (GPU_rotation == 270))
{
MainWindow->setMinSize(384, 256);
}
else
{
MainWindow->setMinSize(256, 384);
}
{
if(windowSize == 0)
{
int w = GetPrivateProfileInt("Video", "Window width", 256, IniName);
int h = GetPrivateProfileInt("Video", "Window height", 384, IniName);
MainWindow->setClientSize(w, h);
}
else
{
ScaleScreen(windowSize);
}
}
DragAcceptFiles(MainWindow->getHWnd(), TRUE); DragAcceptFiles(MainWindow->getHWnd(), TRUE);
EnableMenuItem(mainMenu, IDM_EXEC, MF_GRAYED); EnableMenuItem(mainMenu, IDM_EXEC, MF_GRAYED);
@ -1602,8 +1633,44 @@ void GetWndRect(HWND hwnd)
//======================================================================================== //========================================================================================
void SetRotate(HWND hwnd, int rot) void SetRotate(HWND hwnd, int rot)
{ {
RECT rc;
int oldrot = GPU_rotation;
int oldheight, oldwidth;
int newheight, newwidth;
GPU_rotation = rot; GPU_rotation = rot;
GetClientRect(hwnd, &rc);
oldwidth = (rc.right - rc.left);
oldheight = (rc.bottom - rc.top);
newwidth = oldwidth;
newheight = oldheight;
switch(oldrot)
{
case 0:
case 180:
{
if((rot == 90) || (rot == 270))
{
newwidth = oldheight;
newheight = oldwidth;
}
}
break;
case 90:
case 270:
{
if((rot == 0) || (rot == 180))
{
newwidth = oldheight;
newheight = oldwidth;
}
}
break;
}
switch (rot) switch (rot)
{ {
case 0: case 0:
@ -1637,8 +1704,11 @@ void SetRotate(HWND hwnd, int rot)
rotationscanlines = 256; rotationscanlines = 256;
break; break;
} }
MainWindow->setMinSize(GPU_width, GPU_height);
MainWindow->setClientSize(newwidth, newheight);
SetWindowClientSize(hwnd, GPU_width, GPU_height); // SetWindowClientSize(hwnd, GPU_width, GPU_height);
MainWindow->checkMenu(IDC_ROTATE0, MF_BYCOMMAND | ((GPU_rotation==0)?MF_CHECKED:MF_UNCHECKED)); MainWindow->checkMenu(IDC_ROTATE0, MF_BYCOMMAND | ((GPU_rotation==0)?MF_CHECKED:MF_UNCHECKED));
MainWindow->checkMenu(IDC_ROTATE90, MF_BYCOMMAND | ((GPU_rotation==90)?MF_CHECKED:MF_UNCHECKED)); MainWindow->checkMenu(IDC_ROTATE90, MF_BYCOMMAND | ((GPU_rotation==90)?MF_CHECKED:MF_UNCHECKED));
MainWindow->checkMenu(IDC_ROTATE180, MF_BYCOMMAND | ((GPU_rotation==180)?MF_CHECKED:MF_UNCHECKED)); MainWindow->checkMenu(IDC_ROTATE180, MF_BYCOMMAND | ((GPU_rotation==180)?MF_CHECKED:MF_UNCHECKED));
@ -1747,35 +1817,6 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
case WM_CREATE: case WM_CREATE:
{ {
RECT clientSize, fullSize;
GetClientRect(hwnd, &clientSize);
GetWindowRect(hwnd, &fullSize);
DefaultWidth = clientSize.right - clientSize.left;
DefaultHeight = clientSize.bottom - clientSize.top;
widthTradeOff = (fullSize.right - fullSize.left) - (clientSize.right - clientSize.left);
heightTradeOff = (fullSize.bottom - fullSize.top) - (clientSize.bottom - clientSize.top);
if ( (windowSize < 1) || (windowSize > 4) )
{
int w=GetPrivateProfileInt("Video","Window width", 0, IniName);
int h=GetPrivateProfileInt("Video","Window height", 0, IniName);
if (w && h)
{
RECT fullSize = {0, 0, w, h};
ResizingLimit(WMSZ_RIGHT, &fullSize);
if (ForceRatio)
ScaleScreen(hwnd, WMSZ_RIGHT, &fullSize);
SetWindowPos(hwnd, NULL, WndX, WndY, fullSize.right - fullSize.left,
fullSize.bottom - fullSize.top, SWP_NOMOVE | SWP_NOZORDER);
}
else
windowSize=1;
}
if ( (windowSize > 0) && (windowSize < 5) ) ScaleScreen(hwnd, windowSize);
return 0; return 0;
} }
case WM_DESTROY: case WM_DESTROY:
@ -1787,8 +1828,12 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
WritePrivateProfileInt("Video","Window Size",windowSize,IniName); WritePrivateProfileInt("Video","Window Size",windowSize,IniName);
if (windowSize==0) if (windowSize==0)
{ {
WritePrivateProfileInt("Video","Window width",MainWindowRect.right-MainWindowRect.left+widthTradeOff,IniName); // WritePrivateProfileInt("Video","Window width",MainWindowRect.right-MainWindowRect.left+widthTradeOff,IniName);
WritePrivateProfileInt("Video","Window height",MainWindowRect.bottom-MainWindowRect.top+heightTradeOff,IniName); // WritePrivateProfileInt("Video","Window height",MainWindowRect.bottom-MainWindowRect.top+heightTradeOff,IniName);
RECT rc;
GetClientRect(hwnd, &rc);
WritePrivateProfileInt("Video", "Window width", (rc.right - rc.left), IniName);
WritePrivateProfileInt("Video", "Window height", (rc.bottom - rc.top), IniName);
} }
//Save window position //Save window position
@ -1807,19 +1852,20 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
return 0; return 0;
case WM_SIZING: case WM_SIZING:
{ {
RECT *rc=(RECT *)lParam; if(windowSize)
{
windowSize=0; windowSize = 0;
ResizingLimit(wParam, rc); MainWindow->checkMenu(IDC_WINDOW1X, MF_BYCOMMAND | MF_UNCHECKED);
if (ForceRatio) MainWindow->checkMenu(IDC_WINDOW2X, MF_BYCOMMAND | MF_UNCHECKED);
ScaleScreen(hwnd, wParam, rc); MainWindow->checkMenu(IDC_WINDOW3X, MF_BYCOMMAND | MF_UNCHECKED);
//LOG("sizing: width=%i; height=%i\n", rc->right - rc->left, rc->bottom - rc->top); MainWindow->checkMenu(IDC_WINDOW4X, MF_BYCOMMAND | MF_UNCHECKED);
}
break;
case WM_SIZE:
if (ForceRatio) {
if ( windowSize != 0 ) ScaleScreen(hwnd, windowSize);
} }
MainWindow->sizingMsg(wParam, lParam, ForceRatio);
}
return 1;
//break;
case WM_SIZE:
GetWndRect(hwnd); GetWndRect(hwnd);
return 0; return 0;
case WM_DROPFILES: case WM_DROPFILES:
@ -2565,7 +2611,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
case IDC_WINDOW1X: case IDC_WINDOW1X:
windowSize=1; windowSize=1;
ScaleScreen(hwnd, windowSize); ScaleScreen(windowSize);
WritePrivateProfileInt("Video","Window Size",windowSize,IniName); WritePrivateProfileInt("Video","Window Size",windowSize,IniName);
MainWindow->checkMenu(IDC_WINDOW1X, MF_BYCOMMAND | MF_CHECKED); MainWindow->checkMenu(IDC_WINDOW1X, MF_BYCOMMAND | MF_CHECKED);
@ -2575,7 +2621,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
break; break;
case IDC_WINDOW2X: case IDC_WINDOW2X:
windowSize=2; windowSize=2;
ScaleScreen(hwnd, windowSize); ScaleScreen(windowSize);
WritePrivateProfileInt("Video","Window Size",windowSize,IniName); WritePrivateProfileInt("Video","Window Size",windowSize,IniName);
MainWindow->checkMenu(IDC_WINDOW1X, MF_BYCOMMAND | MF_UNCHECKED); MainWindow->checkMenu(IDC_WINDOW1X, MF_BYCOMMAND | MF_UNCHECKED);
@ -2585,7 +2631,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
break; break;
case IDC_WINDOW3X: case IDC_WINDOW3X:
windowSize=3; windowSize=3;
ScaleScreen(hwnd, windowSize); ScaleScreen(windowSize);
WritePrivateProfileInt("Video","Window Size",windowSize,IniName); WritePrivateProfileInt("Video","Window Size",windowSize,IniName);
MainWindow->checkMenu(IDC_WINDOW1X, MF_BYCOMMAND | MF_UNCHECKED); MainWindow->checkMenu(IDC_WINDOW1X, MF_BYCOMMAND | MF_UNCHECKED);
@ -2595,7 +2641,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
break; break;
case IDC_WINDOW4X: case IDC_WINDOW4X:
windowSize=4; windowSize=4;
ScaleScreen(hwnd, windowSize); ScaleScreen(windowSize);
WritePrivateProfileInt("Video","Window Size",windowSize,IniName); WritePrivateProfileInt("Video","Window Size",windowSize,IniName);
MainWindow->checkMenu(IDC_WINDOW1X, MF_BYCOMMAND | MF_UNCHECKED); MainWindow->checkMenu(IDC_WINDOW1X, MF_BYCOMMAND | MF_UNCHECKED);
@ -2611,21 +2657,31 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
WritePrivateProfileInt("Video","Window Force Ratio",0,IniName); WritePrivateProfileInt("Video","Window Force Ratio",0,IniName);
} }
else { else {
RECT fullSize; RECT rc;
GetWindowRect(hwnd, &fullSize); GetClientRect(hwnd, &rc);
ScaleScreen(hwnd, WMSZ_RIGHT, &fullSize); ScaleScreen((rc.right - rc.left) / 256.0f);
SetWindowPos(hwnd, NULL, WndX, WndY, fullSize.right - fullSize.left,
fullSize.bottom - fullSize.top, SWP_NOMOVE | SWP_NOZORDER);
//ScaleScreen(hwnd, (fullSize.bottom - fullSize.top - heightTradeOff) / DefaultHeight);
MainWindow->checkMenu(IDC_FORCERATIO, MF_BYCOMMAND | MF_CHECKED); MainWindow->checkMenu(IDC_FORCERATIO, MF_BYCOMMAND | MF_CHECKED);
ForceRatio = TRUE; ForceRatio = TRUE;
WritePrivateProfileInt("Video","Window Force Ratio",1,IniName); WritePrivateProfileInt("Video","Window Force Ratio",1,IniName);
WritePrivateProfileInt("Video", "Window width", (rc.right - rc.left), IniName);
WritePrivateProfileInt("Video", "Window height", (rc.bottom - rc.top), IniName);
} }
break; break;
case IDM_DEFSIZE: case IDM_DEFSIZE:
{ {
ScaleScreen(hwnd, 1.0f); if(windowSize)
{
windowSize = 0;
MainWindow->checkMenu(IDC_WINDOW1X, MF_BYCOMMAND | MF_UNCHECKED);
MainWindow->checkMenu(IDC_WINDOW2X, MF_BYCOMMAND | MF_UNCHECKED);
MainWindow->checkMenu(IDC_WINDOW3X, MF_BYCOMMAND | MF_UNCHECKED);
MainWindow->checkMenu(IDC_WINDOW4X, MF_BYCOMMAND | MF_UNCHECKED);
}
ScaleScreen(1);
} }
break; break;