Lazarus

Programming => Packages and Libraries => RichMemo => Topic started by: pcurtis on October 02, 2020, 11:35:40 am

Title: [SOLVED] Beeps
Post by: pcurtis on October 02, 2020, 11:35:40 am
Hi All,

is it  possible to disable the beep when scrolling past the start off end of the rtf data?
Title: Re: Beeps
Post by: skalogryz on October 05, 2020, 03:43:53 pm
are you using Gtk2 widgetset?
Title: Re: Beeps
Post by: pcurtis on October 06, 2020, 06:52:27 am
Windows
Title: Re: Beeps
Post by: Thaddy on October 06, 2020, 10:28:48 am
You are lucky to still have a beeping little speaker (independent of soundcards).
Best solution: disconnect one of its wires (or both).
Second solution: filter out the BELL ascii code. ($07)
https://en.wikipedia.org/wiki/Bell_character

It was once meant to mimic the bell signal on old fashioned typewriters. NOT teleprinters. The wikipedia entry is partially correct, but wrong in its history as anybody that owns - or once used - a very old mechanical typewriter knows...
On the model in the picture you can either:
- Screw off the bell.
- Stuff the bell with cotton wool.(Still can leave an annoying but barely audible tick)
- a small piece of felt in between hammer and bell.
Title: Re: Beeps
Post by: winni on October 06, 2020, 11:00:22 am
Hi!

Solution without cutting wires:

Code: Pascal  [Select][+][-]
  1. Sysutils.Onbeep:= Nil;

Winni
Title: Re: Beeps
Post by: Thaddy on October 06, 2020, 11:24:03 am
Hi!

Solution without cutting wires:

Code: Pascal  [Select][+][-]
  1. Sysutils.Onbeep:= Nil;

Winni
Alas that does not work in most cases.
https://www.freepascal.org/docs-html/rtl/sysutils/onbeep.html

FreePascal does not provide that hook so it is already nil.......It just provides an entry point.

Old school bells - sick  :o - still ring through unless $07 is filtered.

Basically, this is just a hook to mimic the bell using a soundcard instead of the the old school IBM bell stuff.
Which you should implement yourself as per documentation.

(AND you should know that!)
Title: Re: Beeps
Post by: korba812 on October 06, 2020, 02:44:35 pm
This is how RichEdit control works in windows. It is possible to turn off the beep but it may not be easy, see:
https://stackoverflow.com/questions/55884687/how-to-eliminate-the-messagebeep-from-the-richedit-control

And it has nothing to do with the beep handler (Thaddy, you should know that and check the documentation before writing any nonsense).
Title: Re: Beeps
Post by: lucamar on October 06, 2020, 03:10:29 pm
Indeed, the only thing OnBeep does (or doesn't) is to produce the sound heard when one calls SysUtils.Beep(). That is, Beep() is implemented by calling OnBeep, if set.

Nothing to do with the various system generated noises ;)
Title: Re: Beeps
Post by: Thaddy on October 06, 2020, 03:57:47 pm
I beg to differ, unless the behavior has changed. The On behavior used to be for hooking in a soundcard beep instead of the old school little speaker.
That is also explained in the manual and the beep with the little speaker is Windows only at best. I can prove that with my hardware collection: it only really beeps on very old (in my case IBM) hardware. Everything else is ignored. ALL of them, but most of them are laptops and not game-towers....
Title: Re: Beeps
Post by: lucamar on October 06, 2020, 04:45:02 pm
This is the implementation of SysUtils.Beep, in sysutils.inc:
Code: Pascal  [Select][+][-]
  1. { Beep support }
  2. procedure Beep;
  3. begin
  4.   If Assigned(OnBeep) then
  5.     OnBeep;
  6. end;

In the initialization of sysutils, OnBeep is assigned to SysBeep:

Code: Pascal  [Select][+][-]
  1. unit sysutils;
  2.  
  3. {... etc ...}
  4.  
  5. Initialization
  6.   InitExceptions;       { Initialize exceptions. OS independent }
  7.   InitInternational;    { Initialize internationalization settings }
  8.   SysConfigDir:='/etc'; { Initialize system config dir }
  9.   OnBeep:=@SysBeep;
  10. {... etc ...}
  11.  
  12. end.

And, finally, SysBeep is simply:

Code: Pascal  [Select][+][-]
  1. Procedure SysBeep;
  2. begin
  3.   Write(#7);
  4.   Flush(Output);
  5. end;

Of course, one can replace that for whatever one wants (say, a visual cue for hearing impaired users) but the important thing, regarding this thread, is that OnBeep has nothing to do with the RichMemo beep or any of the various noises OSs do nowadays. It's just how Beep is implemented.

And yes, it's probably to take into account computers w/out buzzer, OSs which ignore the chr($07), etc. So you see, in the end we are saying the same thing but from a slightly different point of view. ;)
Title: Re: Beeps
Post by: Thaddy on October 06, 2020, 04:56:12 pm
Agree.
Title: Re: Beeps
Post by: Windsurfer on October 06, 2020, 06:18:57 pm
I had some problems with a failed graphics card recently. The only way to get a BIOS/UEFI beep for testing was to buy a pack of 10 "Computer Desktop PC Motherboard Speaker Connector Plug PC Mainboard Internal BIOS Beep Code Internal Speaker" from Amazon forĀ£5.00.

They still exist for non-laptops, but are no longer installed. Just in case anyone needs to know.
Title: Re: Beeps
Post by: pcurtis on October 07, 2020, 07:13:15 am
@korba812 - Thanks. Can anyone translate this to FPC as I don't speak C.
Title: Re: Beeps
Post by: PascalDragon on October 07, 2020, 09:11:05 am
I beg to differ, unless the behavior has changed. The On behavior used to be for hooking in a soundcard beep instead of the old school little speaker.
That is also explained in the manual and the beep with the little speaker is Windows only at best. I can prove that with my hardware collection: it only really beeps on very old (in my case IBM) hardware. Everything else is ignored. ALL of them, but most of them are laptops and not game-towers....

But the OnBeep handler is only called if Pascal code uses Beep. This thread's problem is about the rich edit control itself beeping, changing the OnBeep handler won't change anything there, cause the rich edit control doesn't call that handler anyway. The solution - if any - is the one listed in that Stack Overflow link.
Title: Re: Beeps
Post by: PascalDragon on October 07, 2020, 11:26:44 pm
@korba812 - Thanks. Can anyone translate this to FPC as I don't speak C.

You'll need the attached units. Then add unit RichMemoUtil to the uses clause of your form and add the following code to your OnCreate event handler of the form (or if you create your TRichMemo component dynamically add the code where you create the component):

Code: Pascal  [Select][+][-]
  1. SetRichMemoBell(MyRichMemo, False);

If you set the second parameter to True you can enable the bell again should you feel the need.
Title: Re: Beeps
Post by: Sieben on October 08, 2020, 12:30:14 am
Quote from: PascalDragon
You'll need the attached units.

There's only one...?
Title: Re: Beeps
Post by: pcurtis on October 08, 2020, 01:39:41 am
Thanks. I'll take a look and let you know.

Can't get it to work.

1. unit RichMemoUtil not found - I assume you mean RichMemoUtils

2. Error: Identifier not found "SetRichMemoBell"
Title: Re: Beeps
Post by: PascalDragon on October 08, 2020, 09:29:38 am
Quote from: PascalDragon
You'll need the attached units.

There's only one...?

Eh, yes, sorry... Apparently multi selection doesn't work when uploading files... :-[

Thanks. I'll take a look and let you know.

Can't get it to work.

1. unit RichMemoUtil not found - I assume you mean RichMemoUtils

2. Error: Identifier not found "SetRichMemoBell"

As Sieben remarked, I forgot to upload that unit. I've attached it now.
Title: Re: Beeps
Post by: pcurtis on October 08, 2020, 09:46:22 am
Your a genius. Works perfectly.
Title: Re: [SOLVED] Beeps
Post by: Sieben on October 08, 2020, 01:20:07 pm
Will this be integrated with one of the coming versions of Lazarus then? And which would be the best way of integrating it 'during the meanwhile'...?
Title: Re: [SOLVED] Beeps
Post by: PascalDragon on October 08, 2020, 01:34:30 pm
You'll have to ask the maintainer of RichMemo. ;)
Title: Re: [SOLVED] Beeps
Post by: Sieben on October 08, 2020, 02:02:32 pm
Which somehow reminds me of this one (https://forum.lazarus.freepascal.org/index.php/topic,51653.msg379677.html#msg379677)... What is the best or preferred way to adress these people then? Should the bug tracker be used for 'requests' as well? Sorry, I didn't seem to find the right doc or wiki entry so far...
Title: Re: [SOLVED] Beeps
Post by: PascalDragon on October 09, 2020, 09:12:49 am
If it's something that might lead to some discussion (like the one you pointed to) either ask here in one of the suitable subforums or ask on the appropriate mailing list as more devs are subscribed there. The bug tracker is mainly for either bug reports, feature requests or patches that should not require much discussion anymore (though it does happen).
Title: Re: [SOLVED] Beeps
Post by: Sieben on October 09, 2020, 07:12:54 pm
That's what I thought as well, but unfortunately there seems to be not much of a discussion so far... what would be a suitable place then, Packages and Libraries / LazUtils or Suggestions / LCL...? Maybe I can ask a moderator to move the whole thing there. If still no discussion evolves then I'll try a mailing list.

Or add a poll.  8-)
Title: Re: [SOLVED] Beeps
Post by: PascalDragon on October 10, 2020, 12:19:07 pm
That's what I thought as well, but unfortunately there seems to be not much of a discussion so far... what would be a suitable place then, Packages and Libraries / LazUtils or Suggestions / LCL...? Maybe I can ask a moderator to move the whole thing there. If still no discussion evolves then I'll try a mailing list.

I'd say Suggestions / LCL.

Or add a poll.  8-)

As if we core devs react to a poll more than normal posts... ::)
Title: Re: [SOLVED] Beeps
Post by: Sieben on October 10, 2020, 12:51:49 pm
Thanks, I'll give it a try then.

Quote
As if we core devs react to a poll more than normal posts...

You don't...?  ;)
TinyPortal © 2005-2018