| 1 | Imports System.Windows.Forms
|
|---|
| 2 |
|
|---|
| 3 | Public Class DialogAsShieldIcon
|
|---|
| 4 | Private shield As New ShieldIcon
|
|---|
| 5 |
|
|---|
| 6 | Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
|
|---|
| 7 | Me.DialogResult = System.Windows.Forms.DialogResult.OK
|
|---|
| 8 | Me.Hide()
|
|---|
| 9 | End Sub
|
|---|
| 10 |
|
|---|
| 11 | Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
|
|---|
| 12 | Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
|
|---|
| 13 | Me.Hide()
|
|---|
| 14 | End Sub
|
|---|
| 15 |
|
|---|
| 16 | Private Sub DialogAsShieldIcon_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
|---|
| 17 | OK_Button.Image = shield.Icon
|
|---|
| 18 | PictureBox1.Image = System.Drawing.SystemIcons.Question.ToBitmap()
|
|---|
| 19 | End Sub
|
|---|
| 20 |
|
|---|
| 21 | Public Shadows Function Show(ByVal text As String, Optional ByVal caption As String = "DialogAsShieldIcon", _
|
|---|
| 22 | Optional ByVal Buttons As Windows.Forms.MessageBoxButtons = MessageBoxButtons.OKCancel, _
|
|---|
| 23 | Optional ByVal icon As Windows.Forms.MessageBoxIcon = MessageBoxIcon.Question _
|
|---|
| 24 | ) As System.Windows.Forms.DialogResult
|
|---|
| 25 | Label1.Text = text
|
|---|
| 26 | Me.Text = caption
|
|---|
| 27 | Select Case Buttons
|
|---|
| 28 | Case MessageBoxButtons.OKCancel
|
|---|
| 29 | OK_Button.Text = "OK"
|
|---|
| 30 | Cancel_Button.Text = "キャンセル"
|
|---|
| 31 | Case MessageBoxButtons.YesNo
|
|---|
| 32 | OK_Button.Text = "はい"
|
|---|
| 33 | Cancel_Button.Text = "いいえ"
|
|---|
| 34 | Case Else
|
|---|
| 35 | OK_Button.Text = "OK"
|
|---|
| 36 | Cancel_Button.Text = "キャンセル"
|
|---|
| 37 | End Select
|
|---|
| 38 | ' とりあえずアイコンは処理しない(互換性のためパラメータだけ指定できる)
|
|---|
| 39 |
|
|---|
| 40 | MyBase.Show()
|
|---|
| 41 | Do While Me.DialogResult = Windows.Forms.DialogResult.None
|
|---|
| 42 | Application.DoEvents()
|
|---|
| 43 | Loop
|
|---|
| 44 | If Buttons = MessageBoxButtons.YesNo Then
|
|---|
| 45 | Select Case MyBase.DialogResult
|
|---|
| 46 | Case Windows.Forms.DialogResult.OK
|
|---|
| 47 | Return Windows.Forms.DialogResult.Yes
|
|---|
| 48 | Case Windows.Forms.DialogResult.Cancel
|
|---|
| 49 | Return Windows.Forms.DialogResult.No
|
|---|
| 50 | End Select
|
|---|
| 51 | Else
|
|---|
| 52 | Return MyBase.DialogResult
|
|---|
| 53 | End If
|
|---|
| 54 | End Function
|
|---|
| 55 | End Class
|
|---|