Solved

Need to add to the following  avoid ctrl + p:

Posted on 2006-11-24
5
190 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
Comment Utility
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
Comment Utility
u are confusing me?
0
 
LVL 18

Accepted Solution

by:
Ravi Singh earned 500 total points
Comment Utility
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
Comment Utility
It is still coming up the the dialog for print.
0
 
LVL 18

Expert Comment

by:Ravi Singh
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

12 Experts available now in Live!

Get 1:1 Help Now