To make things clear from the beginning, by nature this class is used in a very different way than the default message box. The default message box is just a rather simple function that doesn't remember any settings.
This class however can be created and it'll remember the settings you give it. This changes the usage of the message box quite a lot and if you're just looking for Unicode MsgBox function replacement, this does not do that in a syntax compatible way.
Now that this is clear, here are the list of features:
Uses the same message box MsgBox function displays, as Unicode version.
Change button captions!
Cancel, Try Again, Continue (according to Microsoft you should always use this instead of the deprecated Abort, Retry, Ignore)
Customize the icon shown next to the message box by providing a resource icon!
Customize the icon of the window (shown next to the caption).
Change language of the buttons without explicitly changing them individually (this pretty much requires you to enumerate the languages supported by the system, you can't display say Chinese or German buttons if those languages are not supported by the system - however, the feature is still there)
Set modality of the message box: modeless, application level modality, system wide modality or task level modality. Also see Foreground property.
AlwaysOnTop supported. This means you can make the message box appear above everything (but you shouldn't do this unless it is very important or user expects it).
Change text alignment (AlignRight and RightToLeft properties).
One file only! No additional modules etc.
The class does hooking to change the texts of the buttons. This means if you're an advanced coder you can use the hWnd to customize the window further, subclass it if you like and as a result control it much more.
Usage sample:
Code:
Option Explicit
Private Sub Form_Load()
Dim MessageBox As UniMsgBox
Set MessageBox = New UniMsgBox
With MessageBox
.ButtonYes = "Oh yeah!"
.ButtonNo = "NO! NEVER!"
If .Show( _
"Bill Gates is cool?", _
"Just a simple question", _
[Yes / No], _
[Default Button 2], _
[Icon Question] _
) = [Result Yes] Then
.Show "You're hired!", "Windows will not crash anymore", , , [Icon Critical]
Else
.Show "Dear user, the following blue screen is sponsored but not endorsed by Microsoft.", "Revenge!"
End If
End With
Set MessageBox = Nothing
Unload Me
End Sub