Board index » delphi » How to check the ESC key in a StringGrid?

How to check the ESC key in a StringGrid?

Hi;

there's a way to check if a user press the ESC in a StringGrid?; i tried
with OnKeyDown and OnKeypress but i can't check the ESC key, the prog just
leave the StringGrid a pass the control to the next edit.

TIA

 

Re:How to check the ESC key in a StringGrid?


procedure TForm1.StringGrid1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key=VK_ESCAPE THEN SHOWMESSAGE('ESC')
end;

Arturo Portillo escribi:

Quote
> Hi;

> there's a way to check if a user press the ESC in a StringGrid?; i tried
> with OnKeyDown and OnKeypress but i can't check the ESC key, the prog just
> leave the StringGrid a pass the control to the next edit.

> TIA

Re:How to check the ESC key in a StringGrid?


Does not work that way!, the focus leaves the component before the onKeydown
evaluation takes place...

Vicente Pascual Tarras <pascu...@teleline.es> escribi en el mensaje de
noticias 3A8ADB08.3CA26...@teleline.es...

Quote
> procedure TForm1.StringGrid1KeyDown(Sender: TObject; var Key: Word;
>   Shift: TShiftState);
> begin
> if key=VK_ESCAPE THEN SHOWMESSAGE('ESC')
> end;

> Arturo Portillo escribi:

> > Hi;

> > there's a way to check if a user press the ESC in a StringGrid?; i tried
> > with OnKeyDown and OnKeypress but i can't check the ESC key, the prog
just
> > leave the StringGrid a pass the control to the next edit.

> > TIA

Re:How to check the ESC key in a StringGrid?


try this
procedure TForm1.StringGrid1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);;
  col,row:integer;
begin
if key=VK_ESCAPE THEN
begin
col:= Tstringgrid(sender).col;
row:=Tstringgrid(sender).row;
Tstringgrid(sender).cells[col,row]:='press esc key in
cell['+inttostr(col)+','+inttostr(row)+']';

end;
end;

Arturo Portillo escribi:

Quote
> Does not work that way!, the focus leaves the component before the onKeydown
> evaluation takes place...

> Vicente Pascual Tarras <pascu...@teleline.es> escribi en el mensaje de
> noticias 3A8ADB08.3CA26...@teleline.es...
> > procedure TForm1.StringGrid1KeyDown(Sender: TObject; var Key: Word;
> >   Shift: TShiftState);
> > begin
> > if key=VK_ESCAPE THEN SHOWMESSAGE('ESC')
> > end;

> > Arturo Portillo escribi:

> > > Hi;

> > > there's a way to check if a user press the ESC in a StringGrid?; i tried
> > > with OnKeyDown and OnKeypress but i can't check the ESC key, the prog
> just
> > > leave the StringGrid a pass the control to the next edit.

> > > TIA

Re:How to check the ESC key in a StringGrid?


Just to clarify:

My problem was due a corrupted keyboard driver, after i reinstall windows,
the problem disappear.

thanks Vicente!!!

Vicente Pascual Tarras <pascu...@teleline.es> escribi en el mensaje de
noticias 3A8C2F78.3657B...@teleline.es...

Quote
> try this
> procedure TForm1.StringGrid1KeyDown(Sender: TObject; var Key: Word;
>   Shift: TShiftState);;
>   col,row:integer;
> begin
> if key=VK_ESCAPE THEN
> begin
> col:= Tstringgrid(sender).col;
> row:=Tstringgrid(sender).row;
> Tstringgrid(sender).cells[col,row]:='press esc key in
> cell['+inttostr(col)+','+inttostr(row)+']';

> end;
> end;

> Arturo Portillo escribi:

> > Does not work that way!, the focus leaves the component before the
onKeydown
> > evaluation takes place...

> > Vicente Pascual Tarras <pascu...@teleline.es> escribi en el mensaje de
> > noticias 3A8ADB08.3CA26...@teleline.es...
> > > procedure TForm1.StringGrid1KeyDown(Sender: TObject; var Key: Word;
> > >   Shift: TShiftState);
> > > begin
> > > if key=VK_ESCAPE THEN SHOWMESSAGE('ESC')
> > > end;

> > > Arturo Portillo escribi:

> > > > Hi;

> > > > there's a way to check if a user press the ESC in a StringGrid?; i
tried
> > > > with OnKeyDown and OnKeypress but i can't check the ESC key, the
prog
> > just
> > > > leave the StringGrid a pass the control to the next edit.

> > > > TIA

Other Threads