Recent

Author Topic: [SOLVED] Beeps  (Read 4060 times)

pcurtis

  • Sr. Member
  • ****
  • Posts: 379
[SOLVED] Beeps
« 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?
« Last Edit: October 08, 2020, 09:47:03 am by pcurtis »
Windows 10 / Linux Mint 20
Laz 2.10.0
FPC 3.2.0

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2544
    • havefunsoft.com
Re: Beeps
« Reply #1 on: October 05, 2020, 03:43:53 pm »
are you using Gtk2 widgetset?
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

pcurtis

  • Sr. Member
  • ****
  • Posts: 379
Re: Beeps
« Reply #2 on: October 06, 2020, 06:52:27 am »
Windows
Windows 10 / Linux Mint 20
Laz 2.10.0
FPC 3.2.0

Thaddy

  • Hero Member
  • *****
  • Posts: 10684
Re: Beeps
« Reply #3 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.
« Last Edit: October 06, 2020, 10:49:15 am by Thaddy »

winni

  • Hero Member
  • *****
  • Posts: 2116
Re: Beeps
« Reply #4 on: October 06, 2020, 11:00:22 am »
Hi!

Solution without cutting wires:

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

Winni

Thaddy

  • Hero Member
  • *****
  • Posts: 10684
Re: Beeps
« Reply #5 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!)
« Last Edit: October 06, 2020, 11:26:37 am by Thaddy »

korba812

  • Full Member
  • ***
  • Posts: 143
Re: Beeps
« Reply #6 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).

lucamar

  • Hero Member
  • *****
  • Posts: 3429
Re: Beeps
« Reply #7 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 ;)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.10/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Thaddy

  • Hero Member
  • *****
  • Posts: 10684
Re: Beeps
« Reply #8 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....
« Last Edit: October 06, 2020, 04:28:23 pm by Thaddy »

lucamar

  • Hero Member
  • *****
  • Posts: 3429
Re: Beeps
« Reply #9 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. ;)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.10/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Thaddy

  • Hero Member
  • *****
  • Posts: 10684
Re: Beeps
« Reply #10 on: October 06, 2020, 04:56:12 pm »
Agree.

Windsurfer

  • Sr. Member
  • ****
  • Posts: 368
    • Windsurfer
Re: Beeps
« Reply #11 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.

pcurtis

  • Sr. Member
  • ****
  • Posts: 379
Re: Beeps
« Reply #12 on: October 07, 2020, 07:13:15 am »
@korba812 - Thanks. Can anyone translate this to FPC as I don't speak C.
Windows 10 / Linux Mint 20
Laz 2.10.0
FPC 3.2.0

PascalDragon

  • Hero Member
  • *****
  • Posts: 2593
  • Compiler Developer
Re: Beeps
« Reply #13 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.

PascalDragon

  • Hero Member
  • *****
  • Posts: 2593
  • Compiler Developer
Re: Beeps
« Reply #14 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.

 

TinyPortal © 2005-2018