Solved

Need to add to the following  avoid ctrl + p:

Posted on 2006-11-24
5
199 Views
Last Modified: 2010-04-16
case "keydown":
                        {                        
                              //MessageBox.Show(win.@event.keyCode.ToString());
                              if ((win.@event.ctrlKey) && (win.@event.keyCode == (int)System.Windows.Forms.Keys.C/*67*/))
                              {
                                    DoCopy();
                              }
                              else
                              {
                                    int keyCode = win.@event.keyCode;
                                    if ((!((win.@event.ctrlKey) && ((win.@event.keyCode == (int)System.Windows.Forms.Keys.F/*70*/) || (win.@event.keyCode == (int)System.Windows.Forms.Keys.End/*35*/) || (win.@event.keyCode == (int)System.Windows.Forms.Keys.Home/*36*/)))) &&
                                          (!(win.@event.keyCode >= (int)System.Windows.Forms.Keys.PageUp/*33*/) && (win.@event.keyCode <= (int)System.Windows.Forms.Keys.Down/*40*/)) || win.@event.keyCode == (int)System.Windows.Forms.Keys.F5/*116*/)
                                    {
                                          win.@event.returnValue = false;
                                          win.@event.cancelBubble = true;                                    
                                          win.@event.keyCode = 0;
                                    }
                              }
                              break;
                        }  
0
Comment
Question by:mathieu_cupryk
  • 3
  • 2
5 Comments
 
LVL 18

Expert Comment

by:Ravi Singh
ID: 18008299
Have you tried adding a blank else if clause between the if and else like below?

...
else if ((win.@event.ctrlKey) && (win.@event.keyCode == (int) System.Windows.Forms.Keys.P))
{
}
...
0
 

Author Comment

by:mathieu_cupryk
ID: 18008312
u are confusing me?
0
 
LVL 18

Accepted Solution

by:
Ravi Singh earned 500 total points
ID: 18008331
this should ignore CTRL+P


case "keydown":
                    {                    
                         //MessageBox.Show(win.@event.keyCode.ToString());
                         if ((win.@event.ctrlKey) && (win.@event.keyCode == (int)System.Windows.Forms.Keys.C/*67*/))
                         {
                              DoCopy();
                         }
                         else if ((win.@event.ctrlKey) && (win.@event.keyCode == (int) System.Windows.Forms.Keys.P))
{ }
                         else
                         {
                              int keyCode = win.@event.keyCode;
                              if ((!((win.@event.ctrlKey) && ((win.@event.keyCode == (int)System.Windows.Forms.Keys.F/*70*/) || (win.@event.keyCode == (int)System.Windows.Forms.Keys.End/*35*/) || (win.@event.keyCode == (int)System.Windows.Forms.Keys.Home/*36*/)))) &&
                                   (!(win.@event.keyCode >= (int)System.Windows.Forms.Keys.PageUp/*33*/) && (win.@event.keyCode <= (int)System.Windows.Forms.Keys.Down/*40*/)) || win.@event.keyCode == (int)System.Windows.Forms.Keys.F5/*116*/)
                              {
                                   win.@event.returnValue = false;
                                   win.@event.cancelBubble = true;                              
                                   win.@event.keyCode = 0;
                              }
                         }
                         break;
                    }  
0
 

Author Comment

by:mathieu_cupryk
ID: 18008349
It is still coming up the the dialog for print.
0
 
LVL 18

Expert Comment

by:Ravi Singh
ID: 18014449
Hi, is this is a windows application or a web application? If the latter then I'm sorry I wouldn't know of a way to stop the print dialog from appearing. You might have more luck if you post this question in the ASP.NET topic area.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question