Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to get "Message" namespace

$
0
0

Hi guys,

There is a code snippet, supposed to disable screen print. But it did not work for me. What did I miss?

Thanks a lot

Richard

-----------

Here is the .xaml

<Window x:Class="DisableScreenPrint.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"><Grid></Grid></Window>

Here is the .cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DisableScreenPrint
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }


		public bool PreFilterMessage(ref Message WM)
		{
		Keys kCode = (Keys)(int)WM.WParam & Keys.KeyCode;

			//block printscreen on KeyPress
			if (kCode == Keys.Snapshot)
			{
			//remove the captured image from clipboard
			Clipboard.Clear();

			MessageBox.Show("Printscreen not allowed.");

			return true;

			}

		return false;

		}

    }
}
Here is the error message:




Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>