Prev: OLAP/Pivot cube components?
Next: Y-modem
From: Lcubed on 9 Nov 2009 16:45 Hello, hoping some one can shed some light on this. I'm trying to catch the hardware application keys. I've tried the following code with and without KeyPreview. The identical code works in another dialog. The dialog where the code works is closed and disposed of before the dialog where the code doesn't work is called. this.KeyPreview = true; this.KeyUp += new KeyEventHandler(Form_KeyUp); void Form_KeyUp(object sender, KeyEventArgs e) { LogIt("KeyUp " + e.KeyCode.ToString()); // writes line to debug file } I'm trying to catch the application keys and use a switch like this, but the function is never entered for the application keys in dialog that doesn't work. The working dialog captures all the keys. switch ((HardwareKeys)e.KeyCode) { case HardwareKeys.ApplicationKey1: // do stuff break; case HardwareKeys.ApplicationKey2: // do stuff break; } Does anyone have any ideas as to why this code would work in one dialog but not in another one in the same application? I'm working with WM 5.0, .NETCF 3.5. Thanks for any suggestions!
From: Alberto Silva, MVP on 10 Nov 2009 06:39 Are you sure that you have the KeyPreview form property of the 2nd dialog set to True? Alberto Silva "Lcubed" <loris.emailbox(a)gmail.com> escreveu na mensagem news:fd77c489-d39c-4c02-a18d-b0d02c30aed4(a)p8g2000yqb.googlegroups.com... > Hello, hoping some one can shed some light on this. I'm trying to > catch the hardware application keys. > > I've tried the following code with and without KeyPreview. The > identical code works in another dialog. The dialog where the code > works is closed and disposed of before the dialog where the code > doesn't work is called. > > this.KeyPreview = true; > this.KeyUp += new KeyEventHandler(Form_KeyUp); > > void Form_KeyUp(object sender, KeyEventArgs e) > { > LogIt("KeyUp " + e.KeyCode.ToString()); // writes line to debug > file > } > > I'm trying to catch the application keys and use a switch like this, > but the function is never entered for the application keys in dialog > that doesn't work. The working dialog captures all the keys. > > switch ((HardwareKeys)e.KeyCode) > { > case HardwareKeys.ApplicationKey1: > // do stuff > break; > case HardwareKeys.ApplicationKey2: > // do stuff > break; > } > > Does anyone have any ideas as to why this code would work in one > dialog but not in another one in the same application? I'm working > with WM 5.0, .NETCF 3.5. > > Thanks for any suggestions! > > __________ Information from ESET NOD32 Antivirus, version of virus > signature database 4591 (20091110) __________ > > The message was checked by ESET NOD32 Antivirus. > > http://www.eset.com > > > __________ Information from ESET NOD32 Antivirus, version of virus signature database 4591 (20091110) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com
|
Pages: 1 Prev: OLAP/Pivot cube components? Next: Y-modem |