PKEY_EdgeGesture_DisableTouchWhenFullscreen未声明的标识符

PKEY_EdgeGesture_DisableTouchWhenFullscreen undeclared identifier

本文关键字:标识符 未声明 DisableTouchWhenFullscreen EdgeGesture PKEY      更新时间:2023-10-16

这是一个vs2010 MFC对话框应用程序。除了下面的代码,我还尝试包括以下库,ehstorguids。自由Uuid.Lib。我的最终目标是消灭windows 8的魅力条。我错过了什么导致这个未声明的标识符。

#include "stdafx.h"
#include <windows.h>
#include <iostream>
#include <propsys.h>
#include <propkey.h>
using namespace std;
HRESULT SetTouchDisableProperty(HWND hwnd, BOOL fDisableTouch)
{
    IPropertyStore* pPropStore;
    HRESULT hrReturnValue = SHGetPropertyStoreForWindow(hwnd, IID_PPV_ARGS(&pPropStore));
    if (SUCCEEDED(hrReturnValue))
    {
        PROPVARIANT var;
        var.vt = VT_BOOL;
        var.boolVal = fDisableTouch ? VARIANT_TRUE : VARIANT_FALSE;
        hrReturnValue = pPropStore->SetValue(PKEY_EdgeGesture_DisableTouchWhenFullscreen, var);
        pPropStore->Release();
    }
    return hrReturnValue;
}
BOOL CALLBACK MyEnumProc(HWND hWnd, LPARAM lParam)
{
    TCHAR title[500];
    ZeroMemory(title, sizeof(title));    
    GetWindowText(hWnd, title, sizeof(title)/sizeof(title[0]));
    if (!_tcscmp(title, _T("helloworld")))
    {
        SetTouchDisableProperty(hWnd,true);
    }
    return TRUE;
}
void mymfcdialog::ObBnClickedOk()
{   
    EnumWindows(MyEnumProc, 0);
}

声明需要Windows 8 SDK,即使VS没有抱怨每个MSDN都需要包含的库。

这种隐藏/禁用charm的方法仅适用于桌面应用程序,当它们全屏并有标题栏时。所以在我的例子中,这行不通。当没有需要的魅力条/手势时,终止"资源管理器"进程,然后重新启动资源管理器进程是唯一的选择。如果MS读到这个,你真的应该四处看看,这应该不需要隐藏/禁用Charms/手势。但话说回来,看看windows,看看windows 8……我是说8.1....

你的原始代码在我看来没有错。事实上,网上有这样的例子。

我发现最好的是https://github.com/Kuqd/DisableCharmBar,它演示了一个工作示例。

您在自己的回答中提到的关于窗口标题栏的限制可能与您的GetWindowText检查有关。Kuqd的例子没有标题栏。

我在我的代码中使用这个,我希望它能帮助你:

    static Guid DISABLE_TOUCH_SCREEN = new Guid("32CE38B2-2C9A-41B1-9BC5-B3784394AA44"), // PKEY_EdgeGesture_DisableTouchWhenFullscreen
                IID_PROPERTY_STORE = new Guid("886d8eeb-8cf2-4446-8d02-cdba1dbdcf99"); // PropertyStore
    static short VT_BOOL = 11;   
    private const int GC_ALLGESTURES = 0x00000001;
    public static void DisableEdgeGestures(IntPtr hwnd)
    {
        win32.IPropertyStore pPropStore = null;
        int hr = 0;
        hr = win32.SHGetPropertyStoreForWindow(hwnd, ref IID_PROPERTY_STORE, out pPropStore);
        if (hr == 0)
        {
            win32.PropertyKey propKey = new win32.PropertyKey();
            propKey.fmtid = DISABLE_TOUCH_SCREEN;
            propKey.pid = 2;
            win32.PropVariant var = new win32.PropVariant();
            var.vt = VT_BOOL;
            var.boolVal = true;
            pPropStore.SetValue(ref propKey, ref var);
            System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pPropStore);
        }
    }