How do I disable edge gestures when my window is full screen?

Raymond Chen

A customer wanted to disable edge gestures when their program is running full screen. For example, you may want to do this if you are something like the Remote Desktop client, where you want all input (including the edge gestures) to be sent to the remote computer.

Fortunately, there’s a property specifically designed for what you request. It goes by the devious name System.Edge­Gesture.Disable­Touch­When­Fullscreen.

Let’s take it for a spin. Today’s smart pointer library will be (rolls dice) Nothing! We’re going with raw pointers today.

Start with the scratch program and make these changes:

#include <propsys.h>
#include <shellapi.h>
#include <propkey.h>
BOOL
OnCreate(HWND hwnd, LPCREATESTRUCT lpcs)
{
  SetTouchDisableProperty(hwnd, true);
  return 1;
}

This Set­Touch­Disable­Property helper function sets the property on the window’s property store which says whether we want to disable touch edge gestures when the window is full screen. We set that property when we create the window.

void OnChar(HWND hwnd, TCHAR ch, int cRepeat)
{
  if (ch == '1') {
    HMONITOR hmon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
    MONITORINFO mi = { sizeof(mi) };
    GetMonitorInfo(hmon, &mi);
    SetWindowLong(hwnd, GWL_STYLE, WS_POPUPWINDOW | WS_VISIBLE);
    SetWindowPos(hwnd, nullptr,
        mi.rcMonitor.left, mi.rcMonitor.top,
        mi.rcMonitor.right - mi.rcMonitor.left, mi.rcMonitor.bottom - mi.rcMonitor.top,
        SWP_FRAMECHANGED);
  }
}

  HANDLE_MSG(hwnd, WM_CHAR, OnChar);

When the user hits the 1 key, we go full screen by changing our style to WS_POPUP­WINDOW and changing our window size to match the monitor the window is on.

Okay, now take this program for a spin. It starts out in a normal non-fullscreen mode. Edge gestures are still active. Then press 1 to go full screen. Now edge gestures are inactive.

That’s all.

0 comments

Discussion is closed.

Feedback usabilla icon