Skip to content

Instantly share code, notes, and snippets.

@cyriltovena
Last active August 29, 2015 13:57
Show Gist options
  • Save cyriltovena/9758305 to your computer and use it in GitHub Desktop.
Save cyriltovena/9758305 to your computer and use it in GitHub Desktop.
Blog Disable Charmbar
#include "stdafx.h"
#include "DisableCharmBar.h"
bool DisableCharmbar(HWND hWnd)
{
PROPVARIANT var;
var.vt = VT_BOOL;
var.boolVal = VARIANT_TRUE;
// Get window properties
IPropertyStore* pPropStore;
IID_PPV_ARGS(&pPropStore);
HRESULT hrReturnValue = SHGetPropertyStoreForWindow(hWnd, IID_PPV_ARGS(&pPropStore));
// set PKEY_EdgeGesture_DisableTouchWhenFullscreen property
if (SUCCEEDED(hrReturnValue))
{
hrReturnValue = pPropStore->SetValue(PKEY_EdgeGesture_DisableTouchWhenFullscreen, var);
pPropStore->Release();
}
return TRUE;
}
#pragma once
#pragma comment(lib, "User32.lib")
#pragma comment(lib, "oleaut32.lib")
#pragma comment(lib, "ole32.lib")
#pragma comment(lib, "shell32.lib")
#include <shlobj.h>
#include <assert.h>
#include <windows.h>
#include <iostream>
#include <propsys.h>
#include <propkey.h>
extern "C" __declspec(dllexport) bool DisableCharmbar(HWND hWnd);
<Window x:Class="MyWPFApplication.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" WindowStyle="None" WindowState="Maximized">
<Grid>
<TextBlock Text="Hello World !" FontSize="22" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
</Grid>
</Window>
using System;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
namespace MyWPFApplication
{
public partial class MainWindow : Window
{
[DllImport("DisableCharmbar.dll", EntryPoint = "DisableCharmbar"
, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
static extern bool DisableCharmbar(IntPtr hWnd);
public MainWindow()
{
InitializeComponent();
this.Loaded += (sender, args) => DisableCharmbar(new WindowInteropHelper(this).Handle);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment