Allow the launcher window to be moved

This commit is contained in:
luiscuenca 2019-07-05 11:09:36 -07:00
parent 07983cd642
commit a94eb4d44b
No known key found for this signature in database
GPG key ID: 2387ECD129A6961D
2 changed files with 49 additions and 9 deletions

View file

@ -119,15 +119,22 @@ BOOL CLauncherDlg::OnInitDialog() {
return TRUE;
}
POINT CLauncherDlg::getMouseCoords(MSG* pMsg) {
POINT pos;
pos.x = (int)(short)LOWORD(pMsg->lParam);
pos.y = (int)(short)HIWORD(pMsg->lParam);
return pos;
}
BOOL CLauncherDlg::PreTranslateMessage(MSG* pMsg) {
if ((pMsg->message == WM_KEYDOWN))
{
switch (pMsg->message) {
case WM_KEYDOWN:
if (pMsg->wParam == 'A' && GetKeyState(VK_CONTROL) < 0) {
CWnd* wnd = GetFocus();
CWnd* myWnd = this->GetDlgItem(IDC_ORGNAME);
if (wnd && (wnd == this->GetDlgItem(IDC_ORGNAME) ||
wnd == this->GetDlgItem(IDC_USERNAME) ||
wnd == this->GetDlgItem(IDC_PASSWORD))) {
wnd == this->GetDlgItem(IDC_USERNAME) ||
wnd == this->GetDlgItem(IDC_PASSWORD))) {
((CEdit*)wnd)->SetSel(0, -1);
}
return TRUE;
@ -135,6 +142,33 @@ BOOL CLauncherDlg::PreTranslateMessage(MSG* pMsg) {
OnNextClicked();
return TRUE;
}
break;
case WM_LBUTTONDOWN:
if (pMsg->hwnd == GetSafeHwnd()) {
_draggingWindow = true;
_dragOffset = getMouseCoords(pMsg);
SetCapture();
}
break;
case WM_LBUTTONUP:
if (_draggingWindow) {
ReleaseCapture();
_draggingWindow = false;
}
break;
case WM_MOUSEMOVE:
if (_draggingWindow) {
POINT pos = getMouseCoords(pMsg);
RECT windowRect;
GetWindowRect(&windowRect);
int width = windowRect.right - windowRect.left;
int height = windowRect.bottom - windowRect.top;
ClientToScreen(&pos);
MoveWindow(pos.x - _dragOffset.x, pos.y - _dragOffset.y, width, height, FALSE);
}
break;
default:
break;
}
return CDialog::PreTranslateMessage(pMsg);
}

View file

@ -60,12 +60,18 @@ protected:
DrawStep _drawStep { DrawStep::DrawLogo };
BOOL getTextFormat(int ResID, TextFormat& formatOut);
void showWindows(std::vector<CStatic*> windows, bool show);
POINT getMouseCoords(MSG* pMsg);
bool _isConsoleRunning{ false };
bool _isInstalling{ false };
bool _isFirstDraw{ false };
bool _showSplash{ true };
int _splashStep{ 0 };
bool _isConsoleRunning { false };
bool _isInstalling { false };
bool _isFirstDraw { false };
bool _showSplash { true };
bool _draggingWindow { false };
POINT _dragOffset;
int _splashStep { 0 };
float _logoRotation { 0.0f };
HICON m_hIcon;