Is it possible to subclass the MsgBox?
I need the msgbox just with captions of buttons changed.
I want to avoid creating a new form as it would need a lot of efforts to make it behave it like msgbox.
e.g.
VB Code:
resp = MsgBox("What do you want to Print?", vbYesNoCancel + vbQuestion, "Choose an option")
But instead of the Yes, No , Cancel buttons, I want Print Current, Print All, Cancel Printing
Pradeep
Re: Is it possible to subclass the MsgBox?
Quote:
Originally Posted by Pradeep1210
I need the msgbox just with captions of buttons changed.
I want to avoid creating a new form as it would need a lot of efforts to make it behave it like msgbox.
And you think it won't take a lot of effort to subclass a message box and add the buttons, and the functionality behind the buttons, to a standard message box????
I found one example through Google, and it does, work, but it is nasty, and the results, even though it does add a new button, is kind of nasty.
If you want it, I'll post it, but I think you should rethink your position on not using a Form of your own for this.
Re: Is it possible to subclass the MsgBox?
hi I agree with the above. it's whould take far more time and effot, tho if you really want to you can have a look at an example I made.
Now note this does not subclass a messagebox but a inputbox box, but it can be changed to a message box, just replace in the code that calls to the inputbox function with a messagebox name. and it will work
anyway this inputbox replacement has many chnages, background, text color, automatic closeing timer, and alphablending o and also finding out what button was pressed.
ps all code is commented.
http://www.pscode.com/vb/scripts/Sho...62548&lngWId=1
hope if may give you an idea
Re: Is it possible to subclass the MsgBox?
Hack:
This was just an example. I have many places in my app were I feel a MsgBox would suffice if just the captions of the buttons were different.
I could make my own form but it takes a lot of efforts to positon the buttons (1/2/3 buttons), set the default button, set the icon on the left, automatically adjust the label caption and the form and many more things the msgbox does. So my form doesn't look that professional as it would have looked with a standard Msgbox. What I need to do is just change the Captions of buttons being desplayed.
Why I asked this question is that the Msgbox has been implemented as a function in VB and I don't know how to subclass functions.
DreamVB:
Your solution seems to be the perfect thing for what I was looking (bonus - I would know how to subclass the inputbox also). I'll just have a look at your code and get back here.
Pradeep :)
Re: Is it possible to subclass the MsgBox?
If all he wants to do is change the captions then the solution is alot simpler than adding a completely new button to the messagebox.
PSCode has 2 or 3 examples of changing the captions (1 of them I've seen must have been dreamvb's), and on the forums people have asked a few times before.
chem
Re: Is it possible to subclass the MsgBox?
Re: Is it possible to subclass the MsgBox?
Here's another possibility.
Re: Is it possible to subclass the MsgBox?
Chem & Marty:
It looks great and the solution to my problems. But how do I add the icons to the MsgBoxEx like vbInformation, vbQuestion etc. ?
Thanks,
Pradeep :)