Page 1 of 2

dingless requester

Posted: Fri Jan 27, 2006 9:22 pm
by netmaestro
Anybody know how to do this?

Re: dingless requester

Posted: Fri Jan 27, 2006 9:49 pm
by traumatic
What is a dingless requester?

Posted: Fri Jan 27, 2006 9:53 pm
by netmaestro
A messagerequester that does not play the system asterisk sound when it displays. A silent one.

Posted: Fri Jan 27, 2006 9:55 pm
by Trond
The ding is in the user's preferences. You should respect the user's preferences. Personally I've turned it off because I think it's really annoying, but that doesn't mean everyone thinks that, and that's the reason we have preferences which the application shouldn't interfere with.

Start -> Settings -> Control Panel -> Sounds and Sound Devices -> Sounds -> *turn off whatever you want to turn off*

Posted: Fri Jan 27, 2006 10:04 pm
by traumatic
Ah I see! Systemsounds are the first thing I turn off whenever I install an
OS, that's why I couldn't even remember there was a "ding".. ;) Thx.

There is a registry entry that you could try changing (and re-creating the
original entry afterwards) but I don't know if this needs a reboot nor do
I know the supported OS'...

There's "Beep" and "ExtendedSound" in "HKEY­_CURRENT_USER\Control Panel\Sound".
Set both of them to "No".

Re: dingless requester

Posted: Fri Jan 27, 2006 10:05 pm
by PB
There's code here to mute the system volume, so mute, show the requester,
and unmute again? :) No other programmatic way around it.

Re: dingless requester

Posted: Fri Jan 27, 2006 10:08 pm
by netmaestro
Perhaps, but you're waving a red flag at a bull saying it isn't possible...

Posted: Fri Jan 27, 2006 10:28 pm
by blueznl
create a small window and put some buttons on it... no ding...

Posted: Fri Jan 27, 2006 10:39 pm
by netmaestro
Yes, I may have to do that. It's just more work than a one-line requester that has a flag I can set so it doesn't ding.

Posted: Fri Jan 27, 2006 10:49 pm
by TerryHough
You might find something useful in this idea I picked up and modified from the forum, original writers in the code.

Maybe you could modifiy it for your use.

Code: Select all

; SplashMessage - by TerryHough - May 28, 2004

Procedure SplashMessage(timer)
  ; ---------------------------------------------------
  ; Display a timed Message Window
  ;
  ; The following code is based on an "ToolWindow" example by Vanleth and PB.
  ;
  ; This is used to create a pseudo MessageRequester that optionally
  ; times out and then disappears.  Since MessageRequester has no
  ; automatic removal option, this could be very useful.  If the time
  ; parameter is negative, it displays an Continue button and waits.
  ; Include text or graphics as desired.
  ;
  ; Useful for an About message display.
  ; ---------------------------------------------------
  ; Load an image
  CatchImage(1, ?EmbeddedImage)  ; catch the embedded image from memory
  ; ---------------------------------------------------
  #SM_WinID = 9888
  ; Create the window to display
  If OpenWindow(#SM_WinID,0,0,399,261,#PB_Window_WindowCentered|#PB_Window_Invisible,"Whatever title you want")
    CreateGadgetList(WindowID())              ; Create gadgets in the window.
    FontID.l = LoadFont(9889, "Arial", 18, #PB_Font_Bold) ; Load a font
    FontID.l = LoadFont(9890, "Arial", 12, #PB_Font_Bold) ; Load a font
    TextGadget (101,  1,  05, 399, 30, "Say Something", #PB_Text_Center)
    SetGadgetFont(101, UseFont(9889))            ; Set default font
    TextGadget (102,  46,  40, 300, 20, "Written by:  Billy Bob", #PB_Text_Center)
    SetGadgetFont(102, UseFont(9890))            ; Set default font
    TextGadget (104,  46,  74, 300, 20, "Powered by")
    ImageGadget(105,  46,  90,   1,  1, UseImage(1),#PB_Image_Border)
    ; (WinAPI)
    SetWindowLong_(WindowID(),#GWL_EXSTYLE,GetWindowLong_(WindowID(),#GWL_EXSTYLE)!#WS_EX_TOOLWINDOW)
    ResizeWindow(400, 262)
    ; (WinAPI)
    ShowWindow_(WindowID(),#SW_SHOW)
    If timer < 0
      #OK_Button = 110
      Result = ButtonGadget(#OK_Button, 160, 233, 80, 24, "Continue")
      Repeat
        Event = WaitWindowEvent()
        Select Event
        Case #PB_EventGadget
          Select EventGadgetID()
          Case #OK_Button
            Finished.b = 1
          EndSelect
        EndSelect
      Until Finished
    Else
      While WindowEvent():Wend  ; Give the window a chance to display
      Delay(timer)              ; Pause for a while before ending
    EndIf
    CloseWindow(#SM_WinID)
  EndIf
EndProcedure

SplashMessage(-4000)
End
; ---------------------------------------------------
EmbeddedImage: IncludeBinary "c:\purebasic\purebasic.bmp" ; Embed the image in pgm exe.

Posted: Fri Jan 27, 2006 11:07 pm
by Sparkie

Code: Select all

; ************************************************ 
; Code:   Silent Message Box 
; Author: Sparkie 
; Date:   January 27, 2006 
; Updated September 9, 2009 for PB 4.x
; OS:     Windows only 
; ************************************************ 
#MB_USERICON = $80 
Procedure SilentMessage(caption$, message$, icon) 
  mbp.MSGBOXPARAMS 
  mbp\cbSize =SizeOf(MSGBOXPARAMS) 
  mbp\hwndOwner = WindowID(0) 
  mbp\hInstance = 0 
  mbp\lpszText = @message$ 
  mbp\lpszCaption = @caption$ 
  mbp\dwStyle = #MB_OK | #MB_USERICON 
  mbp\lpszIcon = icon 
  ;#IDI_APPLICATION  Default application icon. 
  ;#IDI_ASTERISK     Same as IDI_INFORMATION. 
  ;#IDI_ERROR        Hand-shaped icon. 
  ;#IDI_EXCLAMATION  Same as IDI_WARNING. 
  ;#IDI_HAND         Same as IDI_ERROR. 
  ;#IDI_QUESTION     Question mark icon. 
  ;#IDI_WARNING      Exclamation point icon. 
  ;#IDI_WINLOGO      Windows logo icon. Windows XP: Default application icon. 
  result = MessageBoxIndirect_(mbp) 
  ProcedureReturn result 
EndProcedure 
If OpenWindow(0, 100, 100, 300, 200, "Silent Message Box", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ButtonGadget(1, 10, 40, 280, 22, "Display silent message") 
  Repeat 
    event = WaitWindowEvent() 
    If event = #PB_Event_Gadget And EventGadget() = 1 
      SilentMessage("Shhhh....", "netmaestro needs silence!", #IDI_EXCLAMATION) 
    EndIf 
  Until event = #PB_Event_CloseWindow 
EndIf 
End

Re: dingless requester

Posted: Fri Jan 27, 2006 11:12 pm
by PB
>> No other programmatic way around it.
> you are waving a red flag at a bull with that part

Hehe, I'm talking about the standard MessageBox API though. Sparkie's tip
doesn't count because it uses a different API call. ;)

Posted: Fri Jan 27, 2006 11:14 pm
by Sparkie
:evil: :P :)

Posted: Fri Jan 27, 2006 11:18 pm
by netmaestro
That's perfect, Sparkie! Just what I need.
Hehe, I'm talking about the standard MessageBox API though. Sparkie's tip
doesn't count because it uses a different API call.
Ok, I guess that'll be your little secret then. (That's from Lake Placid, an excellent movie imo)

Posted: Fri Jan 27, 2006 11:18 pm
by PB
Great tip though, Sparkie -- I've added it to my Snippets folder. :)