[Debugger] DebugDialog.h: Implement functions to manipulate window position and size

This commit is contained in:
oddMLan 2019-01-13 01:12:00 -07:00
parent 7206c28348
commit f1927648ac
1 changed files with 99 additions and 0 deletions

View File

@ -1,5 +1,6 @@
#pragma once
#include <Project64-core/Settings/SettingType/SettingsType-Application.h>
template <class T>
class CDebugDialog :
public CDialogImpl < T >
@ -39,6 +40,100 @@ public:
}
}
enum { Timer_SetWindowPos = 1 };
//Get Information about the window
int GetHeight(void) {
if (!m_hWnd) { return 0; }
RECT rect;
GetWindowRect(m_hWnd, &rect);
return rect.bottom - rect.top;
}
int GetWidth(void) {
if (!m_hWnd) { return 0; }
RECT rect;
GetWindowRect(m_hWnd, &rect);
return rect.right - rect.left;
}
int GetX(CRect WinRect) {
return (GetSystemMetrics(SM_CXSCREEN) - (WinRect.right - WinRect.left)) / 2;
}
int GetY(CRect WinRect) {
return (GetSystemMetrics(SM_CYSCREEN) - (WinRect.bottom - WinRect.top)) / 2;
}
//Manipulate the state of the window
void SetPos(int X, int Y) { //Move the window to this screen location
::SetWindowPos(m_hWnd, NULL, X, Y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
}
void SaveWindowLoc(UISettingID SettingID_Top, UISettingID SettingID_Left) {
RECT WinRect;
::GetWindowRect(m_hWnd, &WinRect);
//save the location of the window
if (m_hWnd)
{
m_SaveWnd = true;
m_SaveWndTop = WinRect.top;
m_SaveWndLeft = WinRect.left;
}
::KillTimer(m_hWnd, Timer_SetWindowPos);
::SetTimer(m_hWnd, Timer_SetWindowPos, 1000, NULL);
bool flush = false;
if (m_SaveWnd)
{
m_SaveWnd = false;
UISettingsSaveDword(SettingID_Top, m_SaveWndTop);
UISettingsSaveDword(SettingID_Left, m_SaveWndLeft);
flush = true;
}
if (flush)
{
CSettingTypeApplication::Flush();
}
}
void SetSize(int Width, int Height) { //Set window Height and Width
RECT rcClient;
rcClient.top = 0;
rcClient.bottom = Height;
rcClient.left = 0;
rcClient.right = Width;
::AdjustWindowRect(&rcClient, ::GetWindowLong(m_hWnd, GWL_STYLE), true);
int32_t WindowHeight = rcClient.bottom - rcClient.top;
int32_t WindowWidth = rcClient.right - rcClient.left;
::SetWindowPos(m_hWnd, NULL, 0, 0, WindowWidth, WindowHeight, SWP_NOMOVE | SWP_NOZORDER);
}
void SaveSize(UISettingID SettingID_X, UISettingID SettingID_Y) {
//Get the current window size
RECT rect;
GetWindowRect(m_hWnd, &rect);
int32_t WindowHeight = rect.bottom - rect.top;
int32_t WindowWidth = rect.right - rect.left;
if (UISettingsLoadDword(SettingID_X) != WindowWidth)
{
UISettingsSaveDword(SettingID_X, WindowWidth);
}
if (UISettingsLoadDword(SettingID_Y) != WindowHeight)
{
UISettingsSaveDword(SettingID_Y, WindowHeight);
}
}
void HideWindow(void)
{
if (m_hWnd && ::IsWindow(m_hWnd))
@ -78,4 +173,8 @@ public:
SetForegroundWindow((HWND)m_hWnd);
}
}
private:
bool m_SaveWnd;
LONG m_SaveWndTop;
LONG m_SaveWndLeft;
};