Support Forums

Full Version: [VB.NET] Advanced MessageBox Control
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
This is just an example, made by Soul Collector(Me).
It's advanced MessageBox creator, but basic code. :tongue:
[Image: 2usfwbs.png]

Code:
Code:
'    Author: Soul Collector
'    Comment: This example is coded for HF.NET & VBLeet.com
'    Date: 13/02/2010 - 20:02
'    MSN e-mail: soulcoll3ctor@live.com
'    Visit: Vbleet.com & Hackforums.net

Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If rbError.Checked And Ok.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
        ElseIf rbInformation.Checked And Ok.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
        ElseIf rbQuestion.Checked And Ok.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OK, MessageBoxIcon.Question)
        ElseIf rbWarning.Checked And Ok.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning)
        End If

        If rbError.Checked And OkCancel.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Error)
        ElseIf rbInformation.Checked And OkCancel.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Information)
        ElseIf rbQuestion.Checked And OkCancel.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question)
        ElseIf rbWarning.Checked And OkCancel.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)
        End If

        If rbError.Checked And YesNo.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Error)
        ElseIf rbInformation.Checked And YesNo.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Information)
        ElseIf rbQuestion.Checked And YesNo.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        ElseIf rbWarning.Checked And YesNo.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
        End If

        If rbError.Checked And YesNoCancel.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error)
        ElseIf rbInformation.Checked And YesNoCancel.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information)
        ElseIf rbQuestion.Checked And YesNoCancel.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
        ElseIf rbWarning.Checked And YesNoCancel.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning)
        End If

        If rbError.Checked And RetryCancel.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.RetryCancel, MessageBoxIcon.Error)
        ElseIf rbInformation.Checked And RetryCancel.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.RetryCancel, MessageBoxIcon.Information)
        ElseIf rbQuestion.Checked And RetryCancel.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.RetryCancel, MessageBoxIcon.Question)
        ElseIf rbWarning.Checked And RetryCancel.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning)
        End If

        If rbError.Checked And AbortRetryIgnore.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error)
        ElseIf rbInformation.Checked And AbortRetryIgnore.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Information)
        ElseIf rbQuestion.Checked And AbortRetryIgnore.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Question)
        ElseIf rbWarning.Checked And AbortRetryIgnore.Checked Then
            MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Warning)
        End If
    End Sub
End Class

Download Project:
http://www.multiupload.com/2P4ZVDPQ6S
Brilliant tut,i was looking for it
Soul Collector is an amazing coder, Thanks for the source!
Thanks for the source Soul Collector.
It'll come in handy Smile
Thanks bro
Kinda of a messy code. I would have done it a diffrent way
I don't really get the point of this application? When would you ever need to use this?

Also, like mmki said, the coding is pretty messy. And for such a simple task. Tongue
Yeah unless you could save the messagebox or something as an .exe (?). Then i dont think it has much use at all lol
Thank you so much for realeasing it for free. This will be a great contribution to my programs that i will be making in the future
very good tutorial mate. downloading now!
This is nice.
For the one's who want's this in C# this is it.
(i know is not much, but it will save you some time)


Code:
using System;
using System.Windows.Forms;

//    Author: Soul Collector
//    Comment: This example is coded for HF.NET & VBLeet.com
//    Date: 13/02/2010 - 20:02
//    MSN e-mail: soulcoll3ctor@live.com
//    Visit: Vbleet.com & Hackforums.net

namespace Advanced_MessageBox
{
    public partial class Form1
    {
        public Form1()
        {
            InitializeComponent();
            
            //Added to support default instance behavour in C#
            if (_defaultInstance == null)
                _defaultInstance = this;
        }
        
        #region Default Instance
        
        private static Form1 _defaultInstance;
        
        /// <summary>
        /// Added by the VB.Net to C# Converter to support default instance behavour in C#
        /// </summary>
        public static Form1 Default
        {
            get
            {
                if (_defaultInstance == null)
                {
                    _defaultInstance = new Form1();
                    _defaultInstance.FormClosed += DefaultInstanceFormClosed;
                }
                
                return _defaultInstance;
            }
        }
        
        static void DefaultInstanceFormClosed(object sender, FormClosedEventArgs e)
        {
            _defaultInstance = null;
        }
        
        #endregion
        public void Button1_Click(object sender, EventArgs e)
        {
            if (rbError.Checked && Ok.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (rbInformation.Checked && Ok.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (rbQuestion.Checked && Ok.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
            else if (rbWarning.Checked && Ok.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            
            if (rbError.Checked && OkCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }
            else if (rbInformation.Checked && OkCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
            }
            else if (rbQuestion.Checked && OkCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            }
            else if (rbWarning.Checked && OkCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
            }
            
            if (rbError.Checked && YesNo.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Error);
            }
            else if (rbInformation.Checked && YesNo.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Information);
            }
            else if (rbQuestion.Checked && YesNo.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            }
            else if (rbWarning.Checked && YesNo.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            }
            
            if (rbError.Checked && YesNoCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error);
            }
            else if (rbInformation.Checked && YesNoCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
            }
            else if (rbQuestion.Checked && YesNoCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
            }
            else if (rbWarning.Checked && YesNoCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
            }
            
            if (rbError.Checked && RetryCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
            }
            else if (rbInformation.Checked && RetryCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
            }
            else if (rbQuestion.Checked && RetryCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.RetryCancel, MessageBoxIcon.Question);
            }
            else if (rbWarning.Checked && RetryCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
            }
            
            if (rbError.Checked && AbortRetryIgnore.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
            }
            else if (rbInformation.Checked && AbortRetryIgnore.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Information);
            }
            else if (rbQuestion.Checked && AbortRetryIgnore.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Question);
            }
            else if (rbWarning.Checked && AbortRetryIgnore.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Warning);
            }
        }
    }
    
}

Download source in C#
Pages: 1 2