Hack Forums
[.NET] Custom MessageBox Example - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Custom MessageBox Example (/showthread.php?tid=4543610)



Custom MessageBox Example - Only3 - Nov 18, 2014

i saw thread about it and remember i have few examples i made
but then been lazy to search it and write another one

[Image: a97e9a11aeb1a5e0b09f1e32ef13042e.png]

😅


* - Cornflower Blue இڿڰۣ-ڰۣ— - Nov 18, 2014

PHP Code

<?php 
Class MessageBox
Inherits Form
Private Msg As String
WithEvents Btn 
As New Button With {.Text = "OK", .Location = New Point(Width - 100, 80)}
Sub New()
Size = New Size(300, 150)
MinimizeBox = False : MaximizeBox = False
FormBorderStyle 
= FormBorderStyle.FixedDialog
StartPosition 
= FormStartPosition.CenterParent
AddHandler Btn
.Click, Sub() DialogResult = DialogResult.0K
Controls
.Add(Btn)
End Sub
Public Overloads Shared Function Show(Title As String, Message As String)
Return New 
MessageBox() With {.Text = Title, .Msg = Message}.ShowDialog()
End Function
Protected 
Overrides Sub 0nPaint(e As PaintEventArgs)
e.Graphics.FillRectangle(Brushes.White, New Rectang1e(0, 0, ClientRectangle.Width, 70))
e.Graphics.DrawIcon(SystemIcons.Information, 10, 15)
e.Graphics.DrawString(Msg, New Font("Segoe UI", 12), Brushes.Blue, New Rectang1e(50, 0, Width - 20, 70), New
StringFormat with {.LineAlignment = StringA1ignment.Center})
MyBase.0nPaint(e)
End Sub
End 
Class 

Fuck yo' image.


* - Only3 - Nov 19, 2014

last chance to grab it b4inout 😊


* - Cornflower Blue இڿڰۣ-ڰۣ— - Nov 19, 2014

(Nov 19, 2014 01:55 PM)Only3 Wrote:  last chance to grab it b4inout 😊

You can remove the image, my post with the raw code is still there.


Also it is right here: https://i.imgur.com/2ZbKt5a.png


* - AEDEAD - Nov 19, 2014

I fixed the code
Code
Class MessageBox
    Inherits Form
    Private Msg As String
    WithEvents Btn As New Button With {.Text = "OK", .Location = New Point(Width - 100, 80)}
    Sub New()
      Size = New Size(300, 150)
      MinimizeBox = False : MaximizeBox = False
      FormBorderStyle = FormBorderStyle.FixedDialog
      StartPosition = FormStartPosition.CenterParent
      AddHandler Btn.Click, Sub() DialogResult = DialogResult.OK
      Controls.Add(Btn)
    End Sub
    Public Overloads Shared Function Show(ByVal Title As String, ByVal Message As String)
      Return New MessageBox() With {.Text = Title, .Msg = Message}.ShowDialog()
    End Function
    Protected Overrides Sub onPaint(ByVal e As PaintEventArgs)
      e.Graphics.FillRectangle(Brushes.White, New Rectangle(0, 0, ClientRectangle.Width, 70))
      e.Graphics.DrawIcon(SystemIcons.Information, 10, 15)
      e.Graphics.DrawString(Msg, New Font("Segoe UI", 12), Brushes.Blue, New Rectangle(50, 0, Width - 20, 70), New StringFormat With {.LineAlignment = StringAlignment.Center})
      MyBase.OnPaint(e)
    End Sub
End Class

So,

MessageBox.Text = "Fuck"
MessageBox.ShowDialog()

Yet

Messagebox.Msg is not acceptable because it's private blah blah.


* - Hawk HF - Nov 19, 2014

(Nov 19, 2014 02:32 PM)AEDEAD Wrote:  I fixed the code
snip

Yet

Messagebox.Msg is not acceptable because it's private blah blah.

How much did you really fix if you're unsure why private variables can't be accessed publicly?