Silverlight / WPF - Disable ctrl p and printscreen key option in SL5

Asked By gopal krish on 08-Jun-12 03:31 AM
hi..

i want to Disable ctrl p and printscreen key option in SL5..

how to do that..

need ur suggestions...

regards
gopal.s
Neha Garg replied to gopal krish on 08-Jun-12 09:40 AM

Hi...

See the below code to clear the clipboard, to restrict the PrintScreen:

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

if (kCode == Keys.Snapshot)
{
Clipboard.Clear();

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

return true;

}

return false;

}

 

 

or else use the below which is not allowing the user to press the  (display message on key press)

 

document.onkeydown = function(ev) {

  var a;

   ev = window.event;

   if (typeof ev == "undefined") {

   alert("PLEASE DON'T USE KEYBORD");

      }

     a = ev.keyCode;

      alert("PLEASE DON'T USE KEYBORD");

        return false;

     }

     document.onkeyup = function(ev) {

         var charCode;

      if (typeof ev == "undefined") {

     ev = window.event;

     alert("PLEASE DON'T USE KEYBORD");

       } else {

      alert("PLEASE DON'T USE KEYBORD");

       }

     return false;

     }