C++ PKEY_EdgeGesture_在满屏未声明标识符时禁用触摸

C++ PKEY_EdgeGesture_在满屏未声明标识符时禁用触摸,c++,visual-studio-2010,windows-8,mfc,C++,Visual Studio 2010,Windows 8,Mfc,这是一个vs2010 MFC对话框应用程序。除了下面的代码之外,我还尝试包括以下lib,ehstorguids.lib Uuid.lib。最终的结果是我的目标是杀死Windows8的魅力吧。我遗漏了什么导致这个未声明的标识符 #include "stdafx.h" #include <windows.h> #include <iostream> #include <propsys.h> #include <propkey.h> using nam

这是一个vs2010 MFC对话框应用程序。除了下面的代码之外,我还尝试包括以下lib,ehstorguids.lib Uuid.lib。最终的结果是我的目标是杀死Windows8的魅力吧。我遗漏了什么导致这个未声明的标识符

#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);
}
#包括“stdafx.h”
#包括
#包括
#包括
#包括
使用名称空间std;
HRESULT SetTouchDisableProperty(HWND HWND,BOOL fDisableTouch)
{
IPropertyStore*pPropStore;
HRESULT hrReturnValue=SHGetPropertyStoreForWindow(hwnd、IID_PPV_参数(&pPropStore));
if(成功(hrReturnValue))
{
前变异体;
变量vt=vt_BOOL;
var.boolVal=fDisableTouch?VARIANT_TRUE:VARIANT_FALSE;
hrReturnValue=pPropStore->SetValue(PKEY_Edgegestrue_DisableTouchWhenFullscreen,var);
pPropStore->Release();
}
返回hrReturnValue;
}
BOOL回调MyEnumProc(HWND-HWND,LPARAM-LPARAM)
{
TCHAR名称[500];
零内存(title,sizeof(title));
GetWindowText(hWnd,title,sizeof(title)/sizeof(title[0]);
如果(!\u tcscmp(标题(“helloworld”))
{
SetTouchDisableProperty(hWnd,true);
}
返回TRUE;
}
void mymfcdialog::ObBnClickedOk()
{   
枚举窗口(MyEnumProc,0);
}

声明需要Windows 8 SDK,即使VS没有抱怨MSDN要求的LIB(包括)


这种隐藏/禁用魅力的方法仅适用于全屏且带有标题栏的桌面应用程序。所以在我的情况下,这是行不通的。在不需要任何咒语栏/手势时终止“浏览器”进程,然后重新启动浏览器进程是唯一的选择。如果MS读到这篇文章,你真的应该四处看看,隐藏/禁用咒语/手势不需要这篇文章。但再一次,看看windows 8的windows…我是说8.1…仍然没有正确使用。

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

我发现最好的是,它演示了一个工作示例


您在自己的回答中提到的关于窗口标题栏的限制可能与
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);
        }
    }