|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Shutting up a Message BoxI 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 PeteR wrote:
> I use a lot of Yes/No/Cancel message boxes in my application and I'd like Probably. It partly depends on system settings.> 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? 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 --
Show quote
Hide quote
"Bob O`Bob" <filter***@yahoogroups.com> wrote in message Yes, the sounds are set in the Sounds control panel settings so on my systemnews: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 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 PeteR wrote:
> Yes, the sounds are set in the Sounds control panel settings so on my system One simple (to suggest) answer is don't use MsgBox. Write your own.> 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. Bob --
Show quote
Hide quote
"Bob O`Bob" <filter***@yahoogroups.com> wrote in message I've played around with that then realised that there are few hundrednews: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 > -- 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 "PeteR" <pcrREM***@THISgensol.com.au> wrote If you can determine which need sound by the style (Question, Information, Exclaimation> > 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. 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 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. -- Show quoteHide quoteRandy Birch MS MVP Visual Basic http://vbnet.mvps.org/ Please reply to the newsgroups so all can participate. "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 : : "Randy Birch" <rgb_removet***@mvps.org> wrote> call. You could also specify the VBA object when calling VB's message box function> 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. VBA.MsgBox "Hi" David "PeteR" <pcrREM***@THISgensol.com.au> wrote in message If vbQuestion causes sound on your machine then you must have changed the > 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. 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 If you really want to deviate from the standard behaviour of your app just > 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. 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 "Michael C" <nospam@nospam.com> wrote As I suggested, overriding the original MsgBox function would obtain the same> 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. results, but it 'feels' like you get more control. >:-) LFS 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 > > "PeteR" <pcrREM***@THISgensol.com.au> wrote in message Adding to the pile here.... if you're using a standard messagebox, it should 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 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 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 > > 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 >> >> > > >
Moving info to a web page
FTP(not boring) Duplicate definition on Interface declaration VBEvents ContextMenu MapObjects2 list of files in directories? How to cast a ref to one type to another? Graphics VB.NET throws "Application is ambiguous" exception How to increase the number of keys available for use as HotKey? VB to Excel - Best method? |
|||||||||||||||||||||||