adding unpinnable options to any dlg process and main app so that user cannot accidentaly pin the launcher

This commit is contained in:
amerhifi 2019-08-30 14:15:03 -07:00
parent c4c29dd093
commit a5923ac9aa
3 changed files with 20 additions and 2 deletions

View file

@ -13,7 +13,10 @@
#include "LauncherApp.h"
#include "LauncherDlg.h"
#include <propsys.h>
#include <propkey.h>
#include <d2d1.h>
#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);

View file

@ -59,6 +59,7 @@ protected:
BOOL getTextFormat(int ResID, TextFormat& formatOut);
void showWindows(std::vector<CStatic*> windows, bool show);
POINT getMouseCoords(MSG* pMsg);
void MarkWindowAsUnpinnable();
bool _isConsoleRunning { false };

View file

@ -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