First thing I notice is that this key-handling code is occurring on the FORM not a specific control's key-handling event. Iirc this makes the code vunerable to the form's "KeyPreview" setting.
But I'm also somewhat suspicious of CMDialogKey - this looks it might be specific support for handling typical dialog navigation. ie return = OK, escape = Cancel, tab = control navigation. For other keys wouldn't you simply intercept those keyboard events using the "normal" windows keyboard event messages, OnKeyDown/Press etc, and handle those events on the specific tronol, rather than trying to intercept them on the form before they reach those controls. That may not be the answer you were looking for but it might set you on the right track (or elicit some further information about your specific implementation - such as why you can't handle key events on the control itself). Regards, Jolyon -----Original Message----- From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On Behalf Of John Bird Sent: Monday, 5 October 2009 17:26 To: NZ Borland Developers Group - Delphi List Subject: [DUG] Stringgrid - intercepting keys For a long time I have been intercepting keys such as Escape/Enter/Tab no problem I have been wanting to put a simple search facility in a string grid, and would like to intercept Ctrl/F and F3.....but the code as I am using does not get them (D2007) - they are just ignored. Looks like the only characters I can intercept are Tab, Enter and Escape... Any suggestions? procedure TfrmTimeSh2.CMDialogKey(var Msg: TWMKEY); { This converts ENTER key messages to TAB key messages, provided a few conditions hold } begin if (ActiveControl is TCustomEdit) or (ActiveControl is TStringGrid) then begin ATPKeyDir:=''; if Msg.CharCode = VK_RETURN then begin Msg.CharCode := VK_TAB; ATPKeyDir:='Next'; end; if Msg.Charcode = VK_ESCAPE then begin Msg.CharCode := VK_TAB; ATPKeyDir:='Prev'; end; if Msg.Charcode = VK_F2 then <=== never intercepted begin xcGridFind((ActiveControl as TStringGrid),FindStr,strFound); end; if Msg.Charcode = VK_F3 then <=== never intercepted begin xcGridFindNext((ActiveControl as TStringGrid),FindStr,strFound); end; end; inherited; end; John _______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe _______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe