From 8388db4ac40ecb511580955d48a0769dbe4c4ca0 Mon Sep 17 00:00:00 2001 From: Emmet Young Date: Sun, 15 Feb 2015 18:10:25 +1100 Subject: [PATCH] Fix problems with the initial positioning of windows when there is no setting in the config file --- Source/Project64/User Interface/Gui Class.cpp | 2 ++ .../Project64/User Interface/Rom Browser Class.cpp | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Source/Project64/User Interface/Gui Class.cpp b/Source/Project64/User Interface/Gui Class.cpp index 1a7ce4a84..63a25c4c4 100644 --- a/Source/Project64/User Interface/Gui Class.cpp +++ b/Source/Project64/User Interface/Gui Class.cpp @@ -519,8 +519,10 @@ DWORD CALLBACK CMainGui::MainGui_Proc (HWND hWnd, DWORD uMsg, DWORD wParam, DWOR //Move the Main window to the location last executed from or center the window int X = (GetSystemMetrics( SM_CXSCREEN ) - _this->Width()) / 2; int Y = (GetSystemMetrics( SM_CYSCREEN ) - _this->Height()) / 2; + g_Settings->LoadDword(UserInterface_MainWindowTop,(DWORD &)Y); g_Settings->LoadDword(UserInterface_MainWindowLeft,(DWORD &)X); + _this->SetPos(X,Y); _this->ChangeWinSize(640,480); diff --git a/Source/Project64/User Interface/Rom Browser Class.cpp b/Source/Project64/User Interface/Rom Browser Class.cpp index 9e00b0f9d..63db1affc 100644 --- a/Source/Project64/User Interface/Rom Browser Class.cpp +++ b/Source/Project64/User Interface/Rom Browser Class.cpp @@ -1561,10 +1561,19 @@ void CRomBrowser::FixRomListWindow (void) //Change the window Style long Style = GetWindowLong(m_MainWindow,GWL_STYLE) | WS_SIZEBOX | WS_MAXIMIZEBOX; SetWindowLong((HWND)m_MainWindow,GWL_STYLE,Style); + + //Get the current window size + RECT rect; + GetWindowRect((HWND)m_MainWindow, &rect); + + //We find the middle position of the screen, we use this if theres no setting + int X = (GetSystemMetrics(SM_CXSCREEN) - (rect.right - rect.left)) / 2; + int Y = (GetSystemMetrics(SM_CYSCREEN) - (rect.bottom - rect.top)) / 2; - DWORD X, Y; - g_Settings->LoadDword(RomBrowser_Top,(DWORD &)Y); + //Load the value from settings, if none is available, default to above + g_Settings->LoadDword(RomBrowser_Top, (DWORD &)Y); g_Settings->LoadDword(RomBrowser_Left,(DWORD &)X); + SetWindowPos(m_MainWindow,NULL,X,Y,0,0,SWP_NOZORDER|SWP_NOSIZE); //Fix height and width