Zooflow: Fix messageboxes without title

This commit is contained in:
Jonathan Jenne
2022-05-23 15:07:07 +02:00
parent ce7261acca
commit 39c69704f4
56 changed files with 683 additions and 432 deletions

View File

@@ -2,38 +2,101 @@
Imports System.Windows.Forms
Public Class frmDialog
Public Sub New(pMessageText As String, pTitle As String, IsError As Boolean)
#Region "WinAPI"
Public Const WM_NCLBUTTONDOWN As Integer = &HA1
Public Const HT_CAPTION As Integer = &H2
<System.Runtime.InteropServices.DllImport("user32.dll")>
Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
End Function
<System.Runtime.InteropServices.DllImport("user32.dll")>
Public Shared Function ReleaseCapture() As Boolean
End Function
#End Region
Public Enum DialogType
Warning
[Error]
Success
Info
Question
End Enum
Public Sub New(pMessageText As String, pTitle As String, pDialogType As DialogType)
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
txtContent.Text = pMessageText
txtTitle.Text = pTitle
Me.lblMeldung.Text = pMessageText
Me.Text = pTitle
If IsError Then
Panel1.BackColor = Color.Red
Cancel_Button.Visible = False
Else
Panel1.BackColor = Color.OrangeRed
Cancel_Button.Visible = True
Select Case pDialogType
Case DialogType.Success
pnlContent.BackColor = Color.LightGreen
SvgImageBox1.SvgImage = SvgImageCollection1.Item("success")
btnNegative.Visible = False
SetOkCancelButtons()
Case DialogType.Info
pnlContent.BackColor = Color.LightBlue
SvgImageBox1.SvgImage = SvgImageCollection1.Item("info")
SetOkCancelButtons()
Case DialogType.Error
pnlContent.BackColor = Color.LightCoral
SvgImageBox1.SvgImage = SvgImageCollection1.Item("error")
btnNegative.Visible = False
SetOkCancelButtons()
Case DialogType.Warning
pnlContent.BackColor = Color.LightYellow
SvgImageBox1.SvgImage = SvgImageCollection1.Item("warning")
SetOkCancelButtons()
Case DialogType.Question
pnlContent.BackColor = Color.LightYellow
SvgImageBox1.SvgImage = SvgImageCollection1.Item("question")
SetYesNoButtons()
End Select
Dim oLineBreaks = txtContent.Text.Split(vbNewLine).Count
If oLineBreaks > 6 Then
Dim oHeightOffset = oLineBreaks * 20
Height += oHeightOffset
End If
btnPositive.Focus()
End Sub
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.OK
Me.Close()
Private Sub SetYesNoButtons()
btnNegative.Text = "Nein"
btnNegative.DialogResult = DialogResult.No
btnPositive.Text = "Ja"
btnPositive.DialogResult = DialogResult.Yes
End Sub
Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Close()
Private Sub SetOkCancelButtons()
btnNegative.Text = "Abbrechen"
btnNegative.DialogResult = DialogResult.Cancel
btnPositive.Text = "OK"
btnPositive.DialogResult = DialogResult.OK
End Sub
Public Sub CancelButtonInvisible()
Cancel_Button.Visible = False
btnNegative.Visible = False
End Sub
Public Sub CancelButtonVisible()
Cancel_Button.Visible = True
btnNegative.Visible = True
End Sub
Private Sub Header_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles pnlHeader.MouseDown, txtTitle.MouseDown
If e.Button = MouseButtons.Left Then
ReleaseCapture()
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0)
End If
End Sub
End Class