Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change caption of MsgBox buttons?

Status
Not open for further replies.

ErroR

Technical User
Apr 9, 2001
79
US
Is there a way to change, for instance, the "Cancel" button's caption text to something else?

In my code, if the user clicks the "x" to close the application, it will prompt them that they should leave it running. I would like the message box to present them with Yes, No, and Minimize instead of Cancel. It doesnt matter if it still returns the vbCancel.

Thanks in advance
 
Hi ErrorR,

it's totally possible.
You know, message box are very much more expansible than people use them.

You have lots of "kinds of buttons to use".
Just take a look at it's paramethers:

MsgBox(prompt[, buttons][, title][, helpfile, context])

so, for the buttons we have:

Constant Value Description
vbOKOnly 0 Display OK button only.
vbOKCancel 1 Display OK and Cancel buttons.
vbAbortRetryIgnore 2 Display Abort, Retry, and Ignore buttons.
vbYesNoCancel 3 Display Yes, No, and Cancel buttons.
vbYesNo 4 Display Yes and No buttons.
vbRetryCancel 5 Display Retry and Cancel buttons.
vbCritical 16 Display Critical Message icon.
vbQuestion 32 Display Warning Query icon.
vbExclamation 48 Display Warning Message icon.
vbInformation 64 Display Information Message icon.
vbDefaultButton1 0 First button is default.
vbDefaultButton2 256 Second button is default.
vbDefaultButton3 512 Third button is default.
vbDefaultButton4 768 Fourth button is default.
vbApplicationModal 0 Application modal; the user must respond to the message box before continuing work in the current application.
vbSystemModal 4096 System modal; all applications are suspended until the user responds to the message box.


The exact one you need is, as you said:

"I would like the message box to present them with Yes, No, and Minimize instead of Cancel."



msgbox ("watever",vbyesno+vbinformation, "title",,)


you can then use lots of buttons as refered above.
you can then add(+) other buttons.
in the case, i chose vbyesno and i wanted the icon of the msgbox to be that exclamation point (i could have prefered the warning icon, so it would be for example : vbyesno+vbcritical)

Get it?

good work, ===================
* Marta Oliveira *
===================
marta100@aeiou.pt
-------------------
CPC_TA- Braga
-------------------
Portugal
===================
 
Yes, it is possible - but it is a little convoluted, and involves creating a global window hook. Are you sure you want to go this far for a cosmetic detail, when you may just be better off writing your own version of MsgBox?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top