Home All Groups Group Topic Archive Search About

Shutting up a Message Box

Author
25 Mar 2006 10:02 PM
PeteR
I use a lot of Yes/No/Cancel message boxes in my application and I'd like
them to be quiet. i.e no dings, dongs or other assorted noises.
Other than developing my own message boxes is there anyway do this with
code?

Regards PeteR

Author
25 Mar 2006 11:16 PM
Bob O`Bob
PeteR wrote:
> I use a lot of Yes/No/Cancel message boxes in my application and I'd like
> them to be quiet. i.e no dings, dongs or other assorted noises.
> Other than developing my own message boxes is there anyway do this with
> code?


Probably.  It partly depends on system settings.

Play around with the Buttons argument in MsgBox.

For example, on my system,
      MsgBox "blah", vbYesNoCancel Or vbQuestion, "blah"
is silent, but I'm not certain whether there's a user setting in the
sounds control panel which could cause a sound on some other systems
even with "vbQuestion"



    Bob
--
Author
26 Mar 2006 12:06 AM
PeteR
Show quote Hide quote
"Bob O`Bob" <filter***@yahoogroups.com> wrote in message
news:e4KTlIGUGHA.1728@TK2MSFTNGP11.phx.gbl...
> PeteR wrote:
> > I use a lot of Yes/No/Cancel message boxes in my application and I'd
like
> > them to be quiet. i.e no dings, dongs or other assorted noises.
> > Other than developing my own message boxes is there anyway do this with
> > code?
>
>
> Probably.  It partly depends on system settings.
>
> Play around with the Buttons argument in MsgBox.
>
> For example, on my system,
>       MsgBox "blah", vbYesNoCancel Or vbQuestion, "blah"
> is silent, but I'm not certain whether there's a user setting in the
> sounds control panel which could cause a sound on some other systems
> even with "vbQuestion"
>
>
>
> Bob
Yes, the sounds are set in the Sounds control panel settings so on my system
MsgBox "blah", vbYesNoCancel Or vbQuestion, "blah" goes "Bonk" when I click
a button on the message box.
I don't want to change my users Sounds control panel settings but I do want
to silence some of the message boxes from within my app.

PeteR
Author
26 Mar 2006 12:28 AM
Bob O`Bob
PeteR wrote:

> Yes, the sounds are set in the Sounds control panel settings so on my system
> MsgBox "blah", vbYesNoCancel Or vbQuestion, "blah" goes "Bonk" when I click
> a button on the message box.
> I don't want to change my users Sounds control panel settings but I do want
> to silence some of the message boxes from within my app.

One simple (to suggest) answer is don't use MsgBox.  Write your own.



    Bob
--
Author
26 Mar 2006 3:04 AM
PeteR
Show quote Hide quote
"Bob O`Bob" <filter***@yahoogroups.com> wrote in message
news:uMbr7wGUGHA.5884@TK2MSFTNGP14.phx.gbl...
> PeteR wrote:
>
> > Yes, the sounds are set in the Sounds control panel settings so on my
system
> > MsgBox "blah", vbYesNoCancel Or vbQuestion, "blah" goes "Bonk" when I
click
> > a button on the message box.
> > I don't want to change my users Sounds control panel settings but I do
want
> > to silence some of the message boxes from within my app.
>
> One simple (to suggest) answer is don't use MsgBox.  Write your own.
>
>
>
> Bob
> --
I've played around with that then realised that there are few hundred
existing message boxes in the app that would need changing. I was looking
for a quick and dirty solution to silence them all except the ones that
actually need sound.
PeteR
Author
26 Mar 2006 3:56 AM
Larry Serflaten
"PeteR" <pcrREM***@THISgensol.com.au> wrote

> > One simple (to suggest) answer is don't use MsgBox.  Write your own.

> I've played around with that then realised that there are few hundred
> existing message boxes in the app that would need changing. I was looking
> for a quick and dirty solution to silence them all except the ones that
> actually need sound.

If you can determine which need sound by the style (Question, Information, Exclaimation
options etc.) then you could still create your own form and give it all the parameters
of the original MsgBox function.  In a public method that accepts those parameters
you could there decide to show your form, or the original Msgbox.  Something like:

Public Function ShowMsg(Prompt As String, Optional Buttons As VBA.VbMsgBoxStyle = vbOKOnly, Optional Title As String, Optional
HelpFile As String, Optional Context As Long) As VBA.VbMsgBoxResult
  If Buttons And VbMsgBoxStyle.vbExclamation Then
    ' Show original MsgBox
    ShowMsg = VBA.MsgBox(Prompt, Buttons, Title, HelpFile, Context)
  Else
    ' ... Show this form using the above parameters (simplified)
    Me.Show vbModal
    ShowMsg = Result
  End If
End Function


Then to force all your other code to use the above function, add a BAS
module (or somewhere in any available BAS module) override VBA's
msgbox function with your own public function:

Public Function MsgBox(Prompt As String, Optional Buttons As VBA.VbMsgBoxStyle = vbOKOnly, Optional Title As String, Optional
HelpFile As String, Optional Context As Long) As VBA.VbMsgBoxResult
  MsgBox = MyMsgBox.ShowMsg(Prompt, Buttons, Title, HelpFile, Context)
End Function

With all that in place, all the msgbox calls in your app will flow through the
overridden function instead of calling the original MsgBox function.  If you
use that method do document it in a prominent location to keep everybody
informed. (You may opt to avoid using Context, or HelpFile if you do not
use it anywhere, and _that_ should be documented to avoid later debugging)

LFS
Author
27 Mar 2006 5:24 AM
Randy Birch
If you're using VB5 or VB6, all you have to do is write your own message box
procedure that accepts exactly the same parameters as MsgBox does, in
exactly the same order, then place that in a bas module and define the
procedure as a public function giving it the same name - MsgBox. VB is smart
enough to then use your MsgBox procedure instead of the build-in method. By
keeping the function's parameters identical you don't have to re-code each
call.  If you really wanted to retain the ability to call the standard
MsgBox as well as your custom one depending on circumstances, you could add
an optional parameter to the end of the parameter list, say Optional
bUseRealMsgBox as Boolean = False, then code that last parameter True in the
few places you wanted the real message box.

--

Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/

Please reply to the newsgroups so all can participate.




Show quoteHide quote
"PeteR" <pcrREM***@THISgensol.com.au> wrote in message
news:%23xhpjIIUGHA.4976@TK2MSFTNGP11.phx.gbl...
:
: "Bob O`Bob" <filter***@yahoogroups.com> wrote in message
: news:uMbr7wGUGHA.5884@TK2MSFTNGP14.phx.gbl...
: > PeteR wrote:
: >
: > > Yes, the sounds are set in the Sounds control panel settings so on my
: system
: > > MsgBox "blah", vbYesNoCancel Or vbQuestion, "blah" goes "Bonk" when I
: click
: > > a button on the message box.
: > > I don't want to change my users Sounds control panel settings but I do
: want
: > > to silence some of the message boxes from within my app.
: >
: > One simple (to suggest) answer is don't use MsgBox.  Write your own.
: >
: >
: >
: > Bob
: > --
: I've played around with that then realised that there are few hundred
: existing message boxes in the app that would need changing. I was looking
: for a quick and dirty solution to silence them all except the ones that
: actually need sound.
: PeteR
:
:
Author
27 Mar 2006 11:47 AM
David Youngblood
"Randy Birch" <rgb_removet***@mvps.org> wrote> call.
> you could add an optional parameter to the end of the parameter
> list, say Optional bUseRealMsgBox as Boolean = False, then code
> that last parameter True in the few places you wanted the real
> message box.

You could also specify the VBA object when calling VB's message box function

    VBA.MsgBox "Hi"

David
Author
26 Mar 2006 3:27 AM
Michael C
"PeteR" <pcrREM***@THISgensol.com.au> wrote in message
> Yes, the sounds are set in the Sounds control panel settings so on my
> system
> MsgBox "blah", vbYesNoCancel Or vbQuestion, "blah" goes "Bonk" when I
> click
> a button on the message box.
> I don't want to change my users Sounds control panel settings but I do
> want
> to silence some of the message boxes from within my app.

If vbQuestion causes sound on your machine then you must have changed the
default settings. If the user has done that then it's their own fault if
they get lots of beeps, they set it that way.

> I've played around with that then realised that there are few hundred
> existing message boxes in the app that would need changing. I was looking
> for a quick and dirty solution to silence them all except the ones that
> actually need sound.

If you really want to deviate from the standard behaviour of your app just
write your own MsgBox function with all the same params as the vb6 MsgBox
function and do a search/replace appending you class or module name to the
front.

Michael
Author
26 Mar 2006 4:01 AM
Larry Serflaten
"Michael C" <nospam@nospam.com> wrote

> If you really want to deviate from the standard behaviour of your app just
> write your own MsgBox function with all the same params as the vb6 MsgBox
> function and do a search/replace appending you class or module name to the
> front.

As I suggested, overriding the original MsgBox function would obtain the same
results, but it 'feels' like you get more control.  >:-)

LFS
Author
26 Mar 2006 9:35 AM
RB Smissaert
If you want a custom msgbox I can send you one.
It has a lot of extra features, besides giving no sound.

RBS

Show quoteHide quote
"PeteR" <pcrREM***@THISgensol.com.au> wrote in message
news:uGYMygFUGHA.424@TK2MSFTNGP12.phx.gbl...
>I use a lot of Yes/No/Cancel message boxes in my application and I'd like
> them to be quiet. i.e no dings, dongs or other assorted noises.
> Other than developing my own message boxes is there anyway do this with
> code?
>
> Regards PeteR
>
>
Author
27 Mar 2006 6:49 PM
Ken Halter
"PeteR" <pcrREM***@THISgensol.com.au> wrote in message
news:uGYMygFUGHA.424@TK2MSFTNGP12.phx.gbl...
>I use a lot of Yes/No/Cancel message boxes in my application and I'd like
> them to be quiet. i.e no dings, dongs or other assorted noises.
> Other than developing my own message boxes is there anyway do this with
> code?
>
> Regards PeteR


Adding to the pile here.... if you're using a standard messagebox, it should
behave in a standard way. What if your uses expect to hear the sounds
they've setup for specific events? Some people require these sounds to help
them in one way or another (accessibility settings for the handicapped)

--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Author
28 Mar 2006 2:36 AM
PeteR
Thanks to all for the comments and suggestions. I wasn't aware the standard
MsgBox was default silent with a vbQuestion icon. My Win 2K computer is set
to go "ding" with a vbQuestion icon.  No icon default though goes "ding" as
well which is a bit of a worry as that can't be changed (as far as I can
see).
I'm trying Bobs excellent CustomMsgBox.Dll and I may go with that.

PeteR

Show quoteHide quote
"PeteR" <pcrREM***@THISgensol.com.au> wrote in message
news:uGYMygFUGHA.424@TK2MSFTNGP12.phx.gbl...
> I use a lot of Yes/No/Cancel message boxes in my application and I'd like
> them to be quiet. i.e no dings, dongs or other assorted noises.
> Other than developing my own message boxes is there anyway do this with
> code?
>
> Regards PeteR
>
>
Author
28 Mar 2006 6:58 AM
RB Smissaert
Let me know if you want the source code.

RBS

Show quoteHide quote
"PeteR" <pcrREM***@THISgensol.com.au> wrote in message
news:ehOwyBhUGHA.4608@tk2msftngp13.phx.gbl...
> Thanks to all for the comments and suggestions. I wasn't aware the
> standard
> MsgBox was default silent with a vbQuestion icon. My Win 2K computer is
> set
> to go "ding" with a vbQuestion icon.  No icon default though goes "ding"
> as
> well which is a bit of a worry as that can't be changed (as far as I can
> see).
> I'm trying Bobs excellent CustomMsgBox.Dll and I may go with that.
>
> PeteR
>
> "PeteR" <pcrREM***@THISgensol.com.au> wrote in message
> news:uGYMygFUGHA.424@TK2MSFTNGP12.phx.gbl...
>> I use a lot of Yes/No/Cancel message boxes in my application and I'd like
>> them to be quiet. i.e no dings, dongs or other assorted noises.
>> Other than developing my own message boxes is there anyway do this with
>> code?
>>
>> Regards PeteR
>>
>>
>
>
>