Board index » delphi » Trouble with keys beeping when I want to discard them

Trouble with keys beeping when I want to discard them

I have a KeyDown procedure for an edit field on a form. If the user
presses Ctrl+F, I want to open a new form (that's a signal that the
user wants to use the lookup form). It works fine, but when the
ProviderLookupForm opens and the focus lands on an edit field, it
beeps.

I've tried the key := 0 thing all over the place; it still beeps. This
problem is not stopping me from further work, but it is driving me
nuts.

Code follows:

procedure TProviderForm1.xProviderIDKeyDown(Sender: TObject; var Key:
Word;
  Shift: TShiftState);

var
        ProviderLookupForm: TProviderLookupForm;

begin
        {hex 46 is F}
        If (Shift = [ssCtrl]) and (Key = $46) and (dsProvider.State =
dsBrowse) then
        begin
                ProviderLookupForm :=
TProviderLookupForm.Create(Application);
                ProviderLookupForm.ShowModal;
                if ProviderLookupForm.FoundProviderID then
                begin
                        xProviderID.Text :=
IntToStr(ProviderLookupForm.FoundProviderIDValue);
                        xProviderIDExit(Self);
                end;
                ProviderLookupForm.Release;
                Screen.OnActiveControlChange := ActiveControlChange;
        end;

        {hex 4C is L}
        If (Shift = [ssCtrl]) and (Key = $4C) then
                ttProviderProviderID.Value := Globals.lProviderID;

end;

------------------------------------------------------------------------
Robert W. Weeks                                    rwwe...@southwind.net
http://www2.southwind.net/~rwweeks                  Wichita, Kansas, USA

 

Re:Trouble with keys beeping when I want to discard them


I'm not sure but I think your edit field is detecting the KeyUp.  Perhaps
it might help to create a KeyUp event on that form and discard that.  

Hopes this helps.

Chris

Robert W. Weeks <rwwe...@southwind.net> wrote in article
<33396b41.75051...@news.southwind.net>...

Quote
> I have a KeyDown procedure for an edit field on a form. If the user
> presses Ctrl+F, I want to open a new form (that's a signal that the
> user wants to use the lookup form). It works fine, but when the
> ProviderLookupForm opens and the focus lands on an edit field, it
> beeps.

> I've tried the key := 0 thing all over the place; it still beeps. This
> problem is not stopping me from further work, but it is driving me
> nuts.

Re:Trouble with keys beeping when I want to discard them


Bob, use the KeyPress event instead of the KeyDown event!

rwwe...@southwind.net (Robert W. Weeks) wrote:

Quote
>I have a KeyDown procedure for an edit field on a form. If the user
>presses Ctrl+F, I want to open a new form (that's a signal that the
>user wants to use the lookup form). It works fine, but when the
>ProviderLookupForm opens and the focus lands on an edit field, it
>beeps.

>I've tried the key := 0 thing all over the place; it still beeps. This
>problem is not stopping me from further work, but it is driving me
>nuts.

>Code follows:

>procedure TProviderForm1.xProviderIDKeyDown(Sender: TObject; var Key:
>Word;
>  Shift: TShiftState);

>var
>    ProviderLookupForm: TProviderLookupForm;

>begin
>    {hex 46 is F}
>    If (Shift = [ssCtrl]) and (Key = $46) and (dsProvider.State =
>dsBrowse) then
>    begin
>            ProviderLookupForm :=
>TProviderLookupForm.Create(Application);
>            ProviderLookupForm.ShowModal;
>            if ProviderLookupForm.FoundProviderID then
>            begin
>                    xProviderID.Text :=
>IntToStr(ProviderLookupForm.FoundProviderIDValue);
>                    xProviderIDExit(Self);
>            end;
>            ProviderLookupForm.Release;
>            Screen.OnActiveControlChange := ActiveControlChange;
>    end;

>    {hex 4C is L}
>    If (Shift = [ssCtrl]) and (Key = $4C) then
>            ttProviderProviderID.Value := Globals.lProviderID;

>end;

>------------------------------------------------------------------------
>Robert W. Weeks                                    rwwe...@southwind.net
>http://www2.southwind.net/~rwweeks                  Wichita, Kansas, USA

------------------------------------------------------------------------
Robert W. Weeks                                    rwwe...@southwind.net
http://www2.southwind.net/~rwweeks                  Wichita, Kansas, USA

Re:Trouble with keys beeping when I want to discard them


Quote
Robert W. Weeks wrote:

> I have a KeyDown procedure for an edit field on a form. If the user
> presses Ctrl+F, I want to open a new form (that's a signal that the
> user wants to use the lookup form). It works fine, but when the
> ProviderLookupForm opens and the focus lands on an edit field, it
> beeps.

> I've tried the key := 0 thing all over the place; it still beeps. This
> problem is not stopping me from further work, but it is driving me
> nuts.

Robert,

You can handle CtrlF in the KeyPress event by looking for Key=^F, set
Key:=#0, and do your form thing. No dings. You can handle other control
keys in KeyPress as well(^a=1, ^b=2, ^c=3, etc.).

Sleep well,
Dave Horacek

Other Threads