Public Class VDMmsgbox
' Display a custom - big msgbox instead of the standard one
Private MBrslt As Integer = 0
Private BTNnum As Integer = 0 ' number of buttons to display
private BTNtxt(10) As String
Public Function BigMsgBox(ByVal Prompt As Object, Optional ByVal BigButtons As BigMsgBoxButtons = BigMsgBoxButtons.OKOnly, Optional ByVal Title As Object = Nothing, Optional ByVal Colorr As Color = Nothing) As MsgBoxResult
Select Case BigButtons
Case BigMsgBoxButtons.OKOnly
BTNnum = 1
BTNtxt(1) = "OK"
Case BigMsgBoxButtons.OKCancel
BTNnum = 2
BTNtxt(1) = "OK"
BTNtxt(2) = "CANCEL"
Case BigMsgBoxButtons.AbortRetryIgnore
BTNnum = 3
BTNtxt(1) = "ABORT"
BTNtxt(2) = "RETRY"
BTNtxt(3) = "IGNORE"
Case BigMsgBoxButtons.YesNoCancel
BTNnum = 3
BTNtxt(1) = "YES"
BTNtxt(2) = "NO"
BTNtxt(3) = "CANCEL"
Case BigMsgBoxButtons.YesNo
BTNnum = 2
BTNtxt(1) = "YES"
BTNtxt(2) = "NO"
Case BigMsgBoxButtons.RetryCancel
BTNnum = 2
BTNtxt(1) = "RETRY"
BTNtxt(2) = "CANCEL"
End Select
' Lets build the lables:
Me.Width = 417
Me.Height = 340
Dim TitleTrue As Boolean = False
If Title IsNot Nothing Then
Dim LBL_Title As New Label
LBL_Title.Name = "LBL_Title"
LBL_Title.Width = Me.Width - 2
LBL_Title.Left = 1
LBL_Title.Height = 60
LBL_Title.TextAlign = ContentAlignment.MiddleCenter
LBL_Title.Text = Title.ToString
Controls.Add(LBL_Title)
TitleTrue = True
End If
If Prompt IsNot Nothing Then
Dim lbl_msg As New Label
lbl_msg.Name = "LBL_Msg"
lbl_msg.Left = 6
lbl_msg.Width = Me.Width - 12
If TitleTrue = True Then
lbl_msg.Top = 70
Else
lbl_msg.Top = 10
End If
lbl_msg.Height = Me.Height - 250
lbl_msg.TextAlign = ContentAlignment.TopLeft
lbl_msg.Text = Prompt.ToString
Controls.Add(lbl_msg)
End If
' ------------------------------- Lets build the buttons:
Dim Location_control As New Point(0, Me.Height - 100)
Dim new_Button(BTNnum) As Button
'Dim BTNwidth = ((Me.Width - 20) - (BTNnum * 5)) / BTNnum
Dim BTNwidth = Me.Width / BTNnum - 2
For Count_control = 1 To BTNnum
'SET A NEW BUTTON
new_Button(Count_control) = New Button
new_Button(Count_control).Name = "BTN" & Count_control
new_Button(Count_control).Text = BTNtxt(Count_control) '"Button" + Count_control.ToString()
new_Button(Count_control).Location = New Point((BTNwidth * (Count_control - 1)), Location_control.Y)
new_Button(Count_control).Width = (BTNwidth)
new_Button(Count_control).Height = 90
AddHandler new_Button(Count_control).Click, AddressOf myButtonHandler_Click
Controls.Add(new_Button(Count_control))
Next
Try
Me.ShowDialog()
Catch ex As Exception
End Try
Return MBrslt
Me.Close()
End Function
Private Sub myButtonHandler_Click(ByVal sender As Object, ByVal e As EventArgs)
If TypeOf sender Is Button Then
Select Case sender.text.ToString
Case "OK"
MBrslt = 1
Case "CANCEL"
MBrslt = 2
Case "ABORT"
MBrslt = 3
Case "RETRY"
MBrslt = 4
Case "IGNORE"
MBrslt = 5
Case "YES"
MBrslt = 6
Case "NO"
MBrslt = 7
End Select
End If
Me.Visible = False
Controls.Clear()
Me.Close()
End Sub
End Class