Solved

Need to add to the following  avoid ctrl + p:

Posted on 2006-11-24
5
193 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

914 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now