Click here to Skip to main content
15,896,512 members
Home / Discussions / C#
   

C#

 
GeneralRe: problem with inf file Pin
Heath Stewart30-Sep-03 2:02
protectorHeath Stewart30-Sep-03 2:02 
GeneralWeb Services proxy class Pin
sneaky90930-Sep-03 0:08
sneaky90930-Sep-03 0:08 
GeneralRe: Web Services proxy class Pin
Ryan_Roberts30-Sep-03 1:09
Ryan_Roberts30-Sep-03 1:09 
Questionremoting server in console app? Pin
Roger Alsing29-Sep-03 22:37
Roger Alsing29-Sep-03 22:37 
AnswerRe: remoting server in console app? Pin
Blake Coverett29-Sep-03 23:09
Blake Coverett29-Sep-03 23:09 
GeneralRe: remoting server in console app? Pin
Roger Alsing29-Sep-03 23:31
Roger Alsing29-Sep-03 23:31 
GeneralControl Key Combo Pin
deanoA29-Sep-03 20:40
deanoA29-Sep-03 20:40 
GeneralRe: Control Key Combo Pin
Heath Stewart30-Sep-03 2:16
protectorHeath Stewart30-Sep-03 2:16 
Simply handle any of the "key" events on your controls or your Form. I recommend the Form, and then set the Form.KeyPreview property to true so that the form gets a change to handle the key sequences before the controls do, giving you a single point of "key" event handling.

Now, modifiers like Shift and Ctrl don't raise events like Control.KeyDown, but you can get them easily through the Control.ModifierKeys static property, or - depending on which event you use - from the KeyEventArgs that is passed to your event handler.

So, change the KeyPreview event on your form to true. Create a new event handler for the KeyDown event (or the KeyUp or KeyPress events), and do something like the following:
private void MyForm_KeyDown(object sender,
  KeyEventArgs e)
{
  if (e.KeyCode == Keys.X && e.Control)
  {
    e.Handled = true; // Don't let child controls process this
    this.Close(); // Close your form or use Application.Exit()
  }
}
If you wanted to support user-defineable combos, just pass the KeyEventArgs or part of its data through some key map that wouldn't be hard to create (see the Keys enumeration, which might help).

 

-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
QuestionPicture & Streamer : closed or not? Pin
Stephane David29-Sep-03 20:24
Stephane David29-Sep-03 20:24 
GeneralCallling a dll in COM+ Component Pin
Member 83727229-Sep-03 20:16
Member 83727229-Sep-03 20:16 
GeneralSave a picture Pin
Birdy29-Sep-03 18:43
Birdy29-Sep-03 18:43 
GeneralRe: Save a picture Pin
J. Dunlap29-Sep-03 19:20
J. Dunlap29-Sep-03 19:20 
GeneralCopy file to server Pin
Anonymous29-Sep-03 10:17
Anonymous29-Sep-03 10:17 
GeneralRe: Copy file to server Pin
Daniel M. Edwards29-Sep-03 10:20
Daniel M. Edwards29-Sep-03 10:20 
GeneralTaskbar window button Pin
blade29-Sep-03 9:02
blade29-Sep-03 9:02 
QuestionWhich NUD called this MenuItem? Pin
james-cxx29-Sep-03 8:52
james-cxx29-Sep-03 8:52 
AnswerRe: Which NUD called this MenuItem? Pin
james-cxx29-Sep-03 13:16
james-cxx29-Sep-03 13:16 
Generalpostioning of printer dialog Pin
trythat29-Sep-03 8:06
trythat29-Sep-03 8:06 
GeneralRe: postioning of printer dialog Pin
Heath Stewart29-Sep-03 9:01
protectorHeath Stewart29-Sep-03 9:01 
Generaltoolbar rightclick Pin
trythat29-Sep-03 8:03
trythat29-Sep-03 8:03 
GeneralRe: toolbar rightclick Pin
Heath Stewart29-Sep-03 8:43
protectorHeath Stewart29-Sep-03 8:43 
GeneralGDI+ Dashed line Pin
gadgetfbi29-Sep-03 7:35
gadgetfbi29-Sep-03 7:35 
GeneralRe: GDI+ Dashed line Pin
Heath Stewart29-Sep-03 9:04
protectorHeath Stewart29-Sep-03 9:04 
GeneralRe: GDI+ Dashed line Pin
Daniel M. Edwards29-Sep-03 10:25
Daniel M. Edwards29-Sep-03 10:25 
GeneralRe: GDI+ Dashed line Pin
gadgetfbi29-Sep-03 12:16
gadgetfbi29-Sep-03 12:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.