August 1st, 2016

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

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.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.