-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyMessageBox.cs
55 lines (53 loc) · 2.37 KB
/
MyMessageBox.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CustomMessageBox
{
public static class MyMessageBox
{
public static System.Windows.Forms.DialogResult ShowMessage(string message, string caption, System.Windows.Forms.MessageBoxButtons button, System.Windows.Forms.MessageBoxIcon icon)
{
System.Windows.Forms.DialogResult dlgResult = System.Windows.Forms.DialogResult.None;
switch (button)
{
case System.Windows.Forms.MessageBoxButtons.OK:
using(frmMessageOK msgOK = new frmMessageOK())
{
msgOK.Text = caption;
msgOK.Message = message;
switch (icon)
{
case System.Windows.Forms.MessageBoxIcon.Information:
msgOK.MessageIcon = CustomMessageBox.Properties.Resources.information;
break;
case System.Windows.Forms.MessageBoxIcon.Question:
msgOK.MessageIcon = CustomMessageBox.Properties.Resources.question;
break;
}
dlgResult = msgOK.ShowDialog();
}
break;
case System.Windows.Forms.MessageBoxButtons.YesNo:
using (frmMessageYesNo msgYesNo = new frmMessageYesNo())
{
msgYesNo.Text = caption;
msgYesNo.Message = message;
switch (icon)
{
case System.Windows.Forms.MessageBoxIcon.Information:
msgYesNo.MessageIcon = CustomMessageBox.Properties.Resources.information;
break;
case System.Windows.Forms.MessageBoxIcon.Question:
msgYesNo.MessageIcon = CustomMessageBox.Properties.Resources.question;
break;
}
dlgResult = msgYesNo.ShowDialog();
}
break;
}
return dlgResult;
}
}
}