Alistair

Thanks for your reply.

I have tried the following, based on your suggestion but I still have problems.

procedure TMainForm.DocEntryTrMesEditKeyPress(Sender: TObject;  var Key: Char);
begin
   if (keyfound = #10) and (key = #13) then  ShowMessage('Control Enter')
else
    ShowMessage('No Go');
 keyfound:=key;
end;

First problem : My keyboard seems to be generating an ascii 10 (not 17) for the
control key.  Which should it be?
Second problem: When I press a Ctrl/Enter combination I get No Go  but when I
press them in sequence I get Control Enter.

What am I missing please?

Thanks
Mark

Alistair George wrote:

>   VK_CONTROL = 17;
>   VK_RETURN = 13; {same as ENTER}
>
> OR you could do a combo key like follows (define keyfound as a global
> variable)
> procedure TCamForm.FormKeyPress(Sender: TObject; var Key: Char);
> begin
> {NB a case expression would be better if u were only gonna use ascii values}
> if keyfound=#9 {tab}
> and key=#101 then
> ShowMessage('Haha, Tab was first')
> else
> if keyfound=#9
> and key='e'{instead of writing ascii}
> then
> ShowMessage('Haha, Tab was LAST');
> end;
> keyfound:=key;
> exit;
>
> Typically, for menu Ctrl-X for exit, once you have set up mainform for
> key-preview then you just double click your menu component, select the menu
> item eg Exit, Ctrl-X in the object inspector shortcut for that particular
> menu item.
> Easypeasy.
> Alistair+
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> > Behalf Of Mark Howard
> > Sent: Sunday, 28 March 1999 15:45
> > To: Multiple recipients of list delphi
> > Subject: [DUG]: Trapping and using a CTRL-ENTER
> >
> >
> > Hi guys
> > A simple question.
> >
> > In variety of controls (StringGrid, ComboBox, EditBox) I want to be able
> > to detect if the user has pressed a CTRL-ENTER combination.
> > If he has, I want to invoke the Save procedure. If  CTRL-ENTER is NOT
> > pressed, the control should just handle the key-press as it usually
> > does.
> > This is to save the user having to hunt for the mouse and the SAVE
> > button, if they prefer.
> >
> > Can someone please give me a short example of how you would detect and
> > use this, I can't find any examples of the use of OnKeyDown in the
> > documentation.
> > eg (in pseudo code) an OnKeyDown event:
> > if (Key = Chr(13) and ShiftState  = ssCtrl) then SaveStuff
> >
> > In a similar vein - is it possible to detect the pressing of TAB before
> > it does what it does, ie moves focus to the next control?
> >
> >
> > ------------------------------------------------------------------
> > ---------
> >     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> >                   Website: http://www.delphi.org.nz
> >
>
> ---------------------------------------------------------------------------
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz



---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to