PDA

Click to See Complete Forum and Search --> : VB6 Custom MsgBox form


longwolf
Dec 31st, 2006, 12:25 PM
I wanted an easy to use, skinnable MsgBox with custom button captions and to have or not have a 'Don't ask me again' option.
Here's what I came up with.

This comes from the header of the form:

This form makes as many buttons as you need for the options you
want to give to the user.
It can also display and return the value of a "Don't ask me again" checkbox

It has two functions that can be called
frmMsgBox.Msg: works similar to a normal MsgBox, but it's easier to use
Only the Prompt is required
frmMsgBox.MsgCstm: Allows you to select your own button captions
and add as many as you want.
A ParramArray is used for the button names
This prevents using Optional parameters :/

Both functions return the index number of the button that was clicked (1 based)
'0' always indicates that the user closed the box without hitting a button
You can also access the user selected options through the form's two
Global variables: frmMsgBox.g_lBtnClicked and frmMsgBox.g_bDontAsk

***********************************************************************************
Example uses
Converting a standard MsgBox to frmMsgBox.Msg:
lOption = MsgBox("Test", vbYesNoCancel Or vbCritical Or vbDefaultButton2)
Use:
lOption = frmMsgBox.Msg("Test", mbYesNoCancel, mbCritical, 2)

Custom MsgBox use:
frmMsgBox.MsgCstm "Want a cup of coffee?", "Coffee?", mbQuestion, 1, True, _
"Yes", "No", "Maybe", "Ask me later"
Select Case frmMsgBox.g_lBtnClicked
Case 0 ' 0 always indicates that the user closed the box without hitting a button
Case 1 'the 1st button in your list was clicked
Case 2 'the 2nd button in your list was clicked
Case 3 'ect.
Case 4
End Select
bDontAsk = frmMsgBox.g_bDontAsk

***********************************************************************************
Tips:
a. This looks great when a Manifest File is used
b. You can match the form to your skinned project by:
1. Delete the command button "btnAction"
2. Add your own custom button and name it "btnAction"
3. Set it's index to 0 and adjust it's height
c. You can copy frmMsgBox.frm and frmMsgBox.frx to the
VB Templates folder to make it accessible from the
'Project/Add Form' menu
The template folder is usually located at:
C:\Program Files\Microsoft Visual Studio\VB98\Template\Forms
***********************************************************************************

A simple sample project is in the TestForm folder.

I may add InputBox functionality to it later.

Let me know if you find any bugs :D

EntityReborn
Sep 24th, 2008, 02:22 AM
Sounds great! Ill give it a try and see what happens!

meilbeck
Aug 26th, 2009, 09:34 AM
This is just the kind of thing that I was looking for. Many thanks! :thumb: