Click here to Skip to main content
15,895,656 members
Articles / Programming Languages / C#

The most complete C# Webbrowser wrapper control

Rate me:
Please Sign up or sign in to vote.
4.90/5 (141 votes)
28 May 2007CPOL21 min read 3.1M   40K   511  
A C# (.NET 2.0) control which creates, hosts, and offers advanced customization such as dragdrop, file downloads, HTTP/S header viewing, and much more.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DemoApp
{
    //if (AllForms.m_frmInput.ShowDialogInternal("Some Text\r\nMore text.", this) == DialogResult.OK)
    public partial class frmInput : Form
    {
        public frmInput()
        {
            InitializeComponent();
        }

        public string GetInputBoxText()
        {
            return txtInput.Text;
        }

        private bool m_Result = false;

        public DialogResult ShowDialogInternal(string Text, IWin32Window owner)
        {
            m_Result = false;
            txtInput.Text = Text;
            this.ShowDialog(owner);
            return (m_Result) ? DialogResult.OK : DialogResult.Cancel;
        }

        private void txtInput_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                e.Handled = true;
                m_Result = true;
                this.Hide();
            }
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            m_Result = true;
            this.Hide();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            m_Result = false;
            this.Hide();
        }

        private void frmInput_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.UserClosing)
            {
                e.Cancel = true;
                m_Result = false;
                this.Hide();
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions