Hi Everyone!

I am here by to ask help on enhancing messageboxs. How is the way to Display a picture(like a JPG file) inside a messagebox along with text when a button is clicked?

Any Suggestions would be appreciated.

Thank You!

could do an easy thing and just place the picture in a picture box and then
when you want it to show just do picturebox1.visible = true
and have this picture box over the text box?or under the text,, and or grab the
position of the curser and place the picturebox there,,

if not,, best to use richtextbox and call the picture from your resource file

Something like this,,

add your picture in your resource file

Dim img2 As Integer = 0
            
            Me.PictureBox1.SizeMode = PictureBoxSizeMode.CenterImage
            PictureBox1.Image = CType(My.Resources.ResourceManager.GetObject(img2.ToString("YOURIMAGENAME")), Bitmap)

and just add that picture where you want it?

if you dont want to use the above code and get it from your resource file
you can paste it to your clipboard and then call it and add it to a
RICHTEXTBOX this way,

Private Sub AddImage()

Dim img As Image = Image.FromFile("C:\image.jpg")

Clipboard.SetImage(img)
Me.RichTextBox1.Paste()

Clipboard.SetImage(My.Resources.SomeImage)
Me.RichTextBox1.Paste()

End Sub

Thank you for all you guys support!

add these buttons to speed it up and slow er down

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer.Interval = Timer.Interval + 500
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer.Interval = Timer.Interval - 500
    End Sub

Just wanted to add the code for a custom message box in case the link I previously posted might expire.

'// ------------- Prerequisites: 1 Button required on Form1 ------------- \\
Public Class Form1

    '// ------------- DYNAMICS ------------- \\
    '// message box Form.
    Public WithEvents myMessageForm As New Form With _
        {.Size = New Size(300, 200), .MinimizeBox = False, .MaximizeBox = False, _
         .FormBorderStyle = Windows.Forms.FormBorderStyle.Fixed3D, .ControlBox = False}
    '// picturebox to display the Icon.
    Public infoImage As New PictureBox With _
        {.Location = New Point(20, 30), .Size = New Size(40, 40), .SizeMode = PictureBoxSizeMode.StretchImage}
    '// label to display Information.
    Public infoLabel As New Label With _
        {.Font = New Font("Verdana", 10), .AutoSize = True, .Location = New Point(65, 40)}
    '// background label for the Buttons.
    Public btnBgLabel As New Label With _
         {.BackColor = Color.Gainsboro, .Location = New Point(0, 120), _
          .Size = New Size(myMessageForm.width, 80)}
    '// buttons
    Public WithEvents btn1 As New Button With {.Location = New Point(18, 127), .Size = New Size(120, 35), _
         .Text = "Sure Is...", .Font = New Font("Verdana", 10)}
    Public btn2 As New Button With {.Location = New Point(150, 127), .Size = New Size(120, 35), _
         .Text = "Whatever", .Font = New Font("Verdana", 10)}

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Size = New Size(500, 350) '// resize form.
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        showMyMessagebox() '// Load the Custom Message Box.
    End Sub

    Sub showMyMessagebox()
        Dim infoIcon As Icon = SystemIcons.Information '// give this icon a box. -- referring to the box "of chocolates." :)
        myMessageForm.Text = "Cool little Title" '// Title of the message box form.
        myMessageForm.Icon = infoIcon '// take the Icon from the box and add it to the message box form.
        infoImage.Image = infoIcon.ToBitmap '// display Icon as bitmap in Picturebox.
        infoLabel.Text = "The COOLEST Message Box." '// display your Message.
        With myMessageForm.Controls '// add the Dynamic Controls to your Message Box Form.
            .Add(infoImage) : .Add(infoLabel) : .Add(btnBgLabel) : .Add(btn1) : .Add(btn2)
        End With
        btnBgLabel.SendToBack() '// send the buttons background Label to the back so the buttons display.
        myMessageForm.ShowDialog() '// Load the Custom Message Box.
    End Sub

    Private Sub myMessageForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles myMessageForm.Load
        '// get the location from Left to Right.
        Dim locationX As Integer = CInt((Me.Left + (Me.Width - myMessageForm.Width) / 2))
        '// get the location from Top to Bottom.
        Dim locationY As Integer = CInt((Me.Top + (Me.Height - myMessageForm.Height) / 2))
        '// Center the message box Form in center of Form1.
        myMessageForm.Location = New Point(locationX, locationY)
    End Sub

    Private Sub btn1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn1.Click
        myMessageForm.Close() '// close the Custom Message Box.
    End Sub

End Class

"codeorder": the code you pasted shows a mistake in VB 2005.

The word "with" is highlighted as a mistake and says that "End Of Statement [is] Expected"

"codeorder": the code you pasted shows a mistake in VB 2005.

The word "with" is highlighted as a mistake and says that "End Of Statement [is] Expected"

If it is for line39, then the End With statement is there.
If using vb2005, try adding each line in the With statement on it's own line, not with the ":" char. to combine code lines as one.

If just needing something to do and improve and you programming environment, you can download the 2008 express or the 2010 express versions from Microsoft. 2005 "is so like yesterday":D.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.