Board index » delphi » Accelerator keys Alt-key only?
smi...@lantic.net (Johan Smit)
![]() Delphi Developer |
Fri, 04 Nov 2005 13:13:10 GMT
|
smi...@lantic.net (Johan Smit)
![]() Delphi Developer |
Fri, 04 Nov 2005 13:13:10 GMT
Accelerator keys Alt-key only?
Hi,
There are a few bitbuttons on a panel on a form for Close, Help and Print, and the captions of these are : &Close, &Help, and &Print. These accelerator keys are supposed to work from the keyboard Alt-C etc keys. So help me, if the user presses a P key while the focus is on the dbgrid, the print routine is started. Similarly, to get a name starting with C, the query does not find the names starting with C, the form is closed. Accellerator keys are supposed to work with the Alt keys. I cannot catch this keystroke anywhere. What am I doing wrong please? Thank you Johan Smit |
J Fren
![]() Delphi Developer |
Fri, 04 Nov 2005 16:55:31 GMT
Re:Accelerator keys Alt-key only?It sounds as if something is 'burning off' the Alt bit in an OnKeyPress or OnKeyDown event - is Form.KeyPreview = True ? Are you doing anything in there ? On Mon, 19 May 2003 05:13:10 GMT, smi...@lantic.net (Johan Smit) Quote>Hi, |
John Beste
![]() Delphi Developer |
Fri, 04 Nov 2005 16:43:02 GMT
Re:Accelerator keys Alt-key only?It seems to me that the focus is on your grid, but you are not in edit mode. The accellerator keys will function as they do. Example: Copy files in a folder to a new folder. Then select the files again and copy again - a dialog will pop up aksing you if you want to overwrite the files. You do not have to press Alt - only the key. The focused control will have the first choice of what to do with a key. If it cannot use it, then the parent (form or panel) will typically handle it. Did you write OnKeyDown and OnKeyPress event handlers for the grid? If so, was the function called? If the OnKeyPress event handler is called, then set the Key parameter to #0 if the grid can use the key. procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char); -- John Bester Quote"Johan Smit" <smi...@lantic.net> wrote in message Quote> Hi, |
Johan Sm
![]() Delphi Developer |
Sat, 05 Nov 2005 13:46:58 GMT
Re:Accelerator keys Alt-key only?On Mon, 19 May 2003 10:43:02 +0200, "John Bester" <no...@nowhere.com> wrote: Quote>It seems to me that the focus is on your grid, but you are not in edit mode. Although I do not quite understand it, it does solve the mystery of the accelerator working without the alt key.. The DBgrid onkeypress do not catch the key event if there is an accelerator that will catch it.(if the dbgrid is not in edit mode) In DBGrid.OnKeyUp: qM.Locate('Name',char(Key),[loPartialkey]); That scrolls the grid to the first name that starts with the pressed letter. The form key preview is set to false. Now I changed the DBGrid option dgEditing to true, and that prevents the accelerator from handling the key event, but leaves that ugly edit focus in the dbgrid. Then I changed DBGrid.OnKeyUp to: qM.Locate('Name',char(Key),[loPartialkey]); keybd_event(VK_Return,0,0,0); keybd_event(VK_Return,0,KEYEVENTF_KEYUP, 0); Now it works the way I would like it to. I am not sure if that is the best way to do it. Thank you for your help, any further comments will be welcome. Regards Johan Smit |
Rob Kenned
![]() Delphi Developer |
Sat, 05 Nov 2005 14:44:07 GMT
Re:Accelerator keys Alt-key only?QuoteJohan Smit wrote: troubles is. Windows sends the grid a wm_GetDlgCode message, which asks the control which keyboard events it wants to handle. Unless it include dlgc_WantChars, Windows won't event send the grid key-down or key-press messages about the alphabetic keys, which is why you haven't had success handling the OnKeyress event. TCustomGrid only return dlgc_WantChars if the goEditing flag is in the You can declare your own grid descendant that handles wm_GetDlgCode how procedure TTypeAheadDBGrid.WMGetDlgCode(var Message: TWMGetDlgCode); This alone shouldn't cause any problems. However, if you go ahead and -- |
Johan Sm
![]() Delphi Developer |
Mon, 07 Nov 2005 12:52:50 GMT
Re:Accelerator keys Alt-key only?On Tue, 20 May 2003 01:44:07 -0500, Rob Kennedy <rkenn...@cs.wisc.edu> wrote: Quote>DBGrid descends from TCustomGrid, and that's where the root of your Thank you, that clears up the mystery. I will try that descendant. Regards Johan Smit - Hide quoted text - - Show quoted text - Quote |
1. Single key vs Alt+key hot keys under Delphi 5
2. Accelerator keys - when ALT, when not??
3. Button's Accelerator key without Alt??
4. Restrict key combinations Alt-Ctrl-Entf, Alt-Tab, Alt-F4
5. Pressing key works like Alt-key (HELP!!!)
7. Minimize on Startup / Unresponsive Accelerator Key
8. Delphi Accelerator Key Problem