Q for hubdog & inthe

Hey, guys!
The Key := 0 does not work!!
I just tested it and I still get the beep!

:-(
LVL 1
Oli2Asked:
Who is Participating?
 
intheConnect With a Mentor Commented:
used on keypress event it does:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    procedure Edit2KeyPress(Sender: TObject; var Key: Char);
    procedure Edit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if (key = #13) then key := #0;
//keypress does work to disable it.
end;

procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if (key = ord(13)) then key := 0;
//keydown dont work to disable it.
end;

end.


try that 1 works ... one dont ;-)
Regards Barry
0
 
Oli2Author Commented:
Hi, Barry!
Thanx!
This is strange:

if you just have a
procedure KeyDown (blabla);
begin

end;

it will beep when getting to "end;"

if you have a
procedure KeyPress(blabla);
 in addition to  the KeyDown procedure,
it runs over the "end;" of the KeyDown procedure without
beeping.
(KeyDown gets handled before KeyPress it seems)


Anyway, thanx again for your help!

Regards, Oli
0
 
intheCommented:
yes thats true

keydown
keypress
keyup
is probably the  order .

mm..maybe
keydown
keyup
keypress  
          ;-)
         
0
 
Oli2Author Commented:
in case of keydown-keyup-keypress, it
should be named KeyWasPressed instead of KeyPress, huh?
;-)
0
 
intheCommented:
hehe true,
   ;-)
0
All Courses

From novice to tech pro — start learning today.