Link to home
Start Free TrialLog in
Avatar of crystyan
crystyan

asked on

Memo Question

Hi,

I have this code:

  if (Key = Ord('B')) and (ssCtrl in Shift) then
    BoldBtn.Click;

in the Keydown Event. I want to get rid of the short sound when pressing CTRL + one key in the memo.

Thanks,
Avatar of Scay7
Scay7
Flag of South Africa image

what does
boldbtn.click;
do because usually when you call another procedure its
boldbtnclick(sender);
well not sure cause not sure where that procedure points to

if i put that procedure into my downkey avent in the memo like:

procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if (Key = Ord('B')) and (ssCtrl in Shift) then
    showmessage('test');
end;

I get no beep or beeps so mabey its in the boldbtn.click; story...

Peace Scay7
Avatar of crystyan
crystyan

ASKER

HI,

I still get the beep on showmessage too ...

Thanks
Avatar of TheRealLoki
put
Key := 0 at the end

procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if (Key = Ord('B')) and (ssCtrl in Shift) then
    begin
        Key := 0;
        showmessage('test');
    end;
end;
Does the beep come from the system speaker (the box)
or from the desktop speakers ?

Scay7
from the desktop speakers ... where I hear the music lol.
Did you try what loki said... then otherwise its the windows notification beep :P

Peace Scay7
yeah lol ... it`s the windows notification beep ... that`s what I wanted to get rid of :-) it`s like when u are trying to write into an edit box more than the maximum number of chars allowed.
happens anytime i capture the KeyDown message
e.g
if Key = vk_Return then
begin
//domsomething
    key := 0;
end;
If I don't put the key = 0 at the end, i get a beep :-)
nope, still have the prob ..
change your code from
BoldBtn.Click; to BoldBtnClick(BoldBtn);
it`s not that ... it happens anytime I press CTRL + a key ... it`s something from OnKeyDown event ...
Lol go to system sounds and select (no sounds) problem solved :P

or write in a mute option :P for the master sound... volume
http://www.swissdelphicenter.ch/torry/showcode.php?id=1630
or
http://www.delphifaq.com/faq/delphi_windows_API/f522.shtml

Peace Scay7
looool

can`t do that ... :-) so the user will mute the system if they keep CTRL + B pressed !?

:-))))))
lol ok, dunno.
but 1 way around it is to do the following
put a TActionList on the form (Standard tab on component palette), and make an action in it, call it "aBold" for example
set it's "Shortcut" to CTRL+B
set the event code in there to do BoldBtnClick(BoldBtn);

remove your keydown code for ord('B') etc..
you wont have a beep, and "bold" can be done from anywhere
if you only wish it to be active in that edit box, use the OnEnter andOnExit events of the TEdit to do
aBold.Enabled := False/True

hth, Loki... stupid beeping... I should know how to stop it, but my mind's a blank
ASKER CERTIFIED SOLUTION
Avatar of TheRealLoki
TheRealLoki
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial