From a5923ac9aa3bd77ba2717d10fc8c552d584fb81f Mon Sep 17 00:00:00 2001 From: amerhifi Date: Fri, 30 Aug 2019 14:15:03 -0700 Subject: [PATCH 1/4] adding unpinnable options to any dlg process and main app so that user cannot accidentaly pin the launcher --- launchers/win32/LauncherDlg.cpp | 18 +++++++++++++++++- launchers/win32/LauncherDlg.h | 1 + launchers/win32/LauncherUtils.cpp | 3 ++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/launchers/win32/LauncherDlg.cpp b/launchers/win32/LauncherDlg.cpp index 9cf21e9c8c..5d8db860e5 100644 --- a/launchers/win32/LauncherDlg.cpp +++ b/launchers/win32/LauncherDlg.cpp @@ -13,7 +13,10 @@ #include "LauncherApp.h" #include "LauncherDlg.h" +#include +#include #include + #pragma comment(lib, "d2d1") #ifdef _DEBUG @@ -84,7 +87,7 @@ END_MESSAGE_MAP() BOOL CLauncherDlg::OnInitDialog() { CDialog::OnInitDialog(); - + MarkWindowAsUnpinnable(); SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon @@ -129,6 +132,19 @@ BOOL CLauncherDlg::OnInitDialog() { return TRUE; } +void CLauncherDlg::MarkWindowAsUnpinnable() { + HWND hwnd = AfxGetMainWnd()->m_hWnd; + IPropertyStore* pps; + HRESULT hr = SHGetPropertyStoreForWindow(hwnd, IID_PPV_ARGS(&pps)); + if (SUCCEEDED(hr)) { + PROPVARIANT var; + var.vt = VT_BOOL; + var.boolVal = VARIANT_TRUE; + hr = pps->SetValue(PKEY_AppUserModel_PreventPinning, var); + pps->Release(); + } +} + POINT CLauncherDlg::getMouseCoords(MSG* pMsg) { POINT pos; pos.x = (int)(short)LOWORD(pMsg->lParam); diff --git a/launchers/win32/LauncherDlg.h b/launchers/win32/LauncherDlg.h index d25618c554..b0ccbfa04f 100644 --- a/launchers/win32/LauncherDlg.h +++ b/launchers/win32/LauncherDlg.h @@ -59,6 +59,7 @@ protected: BOOL getTextFormat(int ResID, TextFormat& formatOut); void showWindows(std::vector windows, bool show); POINT getMouseCoords(MSG* pMsg); + void MarkWindowAsUnpinnable(); bool _isConsoleRunning { false }; diff --git a/launchers/win32/LauncherUtils.cpp b/launchers/win32/LauncherUtils.cpp index ef23073ca5..cd0c15ccc3 100644 --- a/launchers/win32/LauncherUtils.cpp +++ b/launchers/win32/LauncherUtils.cpp @@ -150,7 +150,8 @@ BOOL LauncherUtils::launchApplication(LPCWSTR lpApplicationName, LPTSTR cmdArgs) ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); ZeroMemory(&pi, sizeof(pi)); - + + si.dwFlags = STARTF_TITLEISAPPID | STARTF_PREVENTPINNING; // start the program up BOOL success = CreateProcess( lpApplicationName, // the path From 08ca702c829babcd194d3220216cd7b6249b473c Mon Sep 17 00:00:00 2001 From: amerhifi Date: Fri, 30 Aug 2019 14:16:11 -0700 Subject: [PATCH 2/4] remove space --- launchers/win32/LauncherDlg.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/launchers/win32/LauncherDlg.cpp b/launchers/win32/LauncherDlg.cpp index 5d8db860e5..386d2747d6 100644 --- a/launchers/win32/LauncherDlg.cpp +++ b/launchers/win32/LauncherDlg.cpp @@ -16,7 +16,6 @@ #include #include #include - #pragma comment(lib, "d2d1") #ifdef _DEBUG From 2a3b99daa63ad1d42bc553f194161108187c521a Mon Sep 17 00:00:00 2001 From: amerhifi Date: Thu, 5 Sep 2019 13:40:29 -0700 Subject: [PATCH 3/4] removing flags --- launchers/win32/LauncherUtils.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/launchers/win32/LauncherUtils.cpp b/launchers/win32/LauncherUtils.cpp index cd0c15ccc3..88cb84eb6e 100644 --- a/launchers/win32/LauncherUtils.cpp +++ b/launchers/win32/LauncherUtils.cpp @@ -150,8 +150,6 @@ BOOL LauncherUtils::launchApplication(LPCWSTR lpApplicationName, LPTSTR cmdArgs) ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); ZeroMemory(&pi, sizeof(pi)); - - si.dwFlags = STARTF_TITLEISAPPID | STARTF_PREVENTPINNING; // start the program up BOOL success = CreateProcess( lpApplicationName, // the path From 9e69b79e2add9acc599178d9231107dab2b60908 Mon Sep 17 00:00:00 2001 From: amerhifi Date: Thu, 5 Sep 2019 13:41:51 -0700 Subject: [PATCH 4/4] adding the space back --- launchers/win32/LauncherUtils.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/launchers/win32/LauncherUtils.cpp b/launchers/win32/LauncherUtils.cpp index 88cb84eb6e..4f8e7f9a74 100644 --- a/launchers/win32/LauncherUtils.cpp +++ b/launchers/win32/LauncherUtils.cpp @@ -150,6 +150,7 @@ BOOL LauncherUtils::launchApplication(LPCWSTR lpApplicationName, LPTSTR cmdArgs) ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); ZeroMemory(&pi, sizeof(pi)); + // start the program up BOOL success = CreateProcess( lpApplicationName, // the path