Hey :cool:


Im GaYan and im creating a c# web browser , the below is the source code ;)
its pretty simple :D its actually a desktop browser ;P

namespace G2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            textBox1.Text = "http://www.yahoo.com/";
        }



        private void button1_Click(object sender, EventArgs e)
        {
            box(textBox1.Text)        
       
            string url = textBox1.Text;

            if (!url.StartsWith("http://") &&
                !url.StartsWith("https://"))
            {
                url = "http://" + url;
            }

            webBrowser1.Navigate(new Uri(url));

            
        }

        
        private void webBrowser1_DocumentCompleted(object sender,  WebBrowserDocumentCompletedEventArgs e)
        {
            textBox1.Text = webBrowser1.Url.ToString();
        }
        //End update url Box

        
        //Uses the hitting of the enter key as the same as clicking the Go! button
        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                string url2 = textBox1.Text;

                if (!url2.StartsWith("http://") &&
                 !url2.StartsWith("https://"))
                {
                    url2 = "http://" + url2;
                }

                webBrowser1.Navigate(new Uri(url2));
            }
        }

well,, this works well :D but i have some questions :D

* How can i get the event when the web page is fully loaded ?

i need to show up a message box when the web page has loaded successfully :-/
how can i do this ;)

and one more thing :D how can i capture a screenshot of the loaded web page ??
[ does anyone know a good library to import ? ]

Thanks in advance !

The event you need is DocumentCompleted, it fires when the document finishes loading.

I'm not sure about your image question. Theres no straightfoward method that i know of (which doesnt mean there isnt one, just means i havent seen it yet :)).

@ Ryshad :) thanks :) ! !

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.