WebBrowser

Create a WebBrowser Control

Page 1 of 1

3 Replies - 5322 Views - Last Post: 14 November 2008 - 09:43 PM Rate Topic: -----

#1 gbertoli3  Icon User is offline

  • DIC at Heart + Code
  • member icon

Reputation: 40
  • View blog
  • Posts: 1,162
  • Joined: 23-June 08

WebBrowser

Post icon  Posted 14 November 2008 - 07:16 PM

I have used both of the WebBrowser Controls in the past and wanted to make my own. The only problem is I have no idea how to start on a thing like this. To keep it simple I want to duplicate the WebBrowser Control. Could you guys show me in the right path? I think I will need an Html, Css, and Javascript Parser, but down know how or where to begin.

Thanks
Is This A Good Question/Topic? 0
  • +

Replies To: WebBrowser

#2 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: WebBrowser

Posted 14 November 2008 - 08:42 PM

A couple of areas to start are with the HttpWebRequest Class and the HttpWebResponse Class. These will expose methods for initiating a get/post and retrieving the stream.

Are you planning on implementing your own methods/control to render the html/script? Or just want to use existing classes in the framework to handle rendering?
Was This Post Helpful? 0
  • +
  • -

#3 gbertoli3  Icon User is offline

  • DIC at Heart + Code
  • member icon

Reputation: 40
  • View blog
  • Posts: 1,162
  • Joined: 23-June 08

Re: WebBrowser

Posted 14 November 2008 - 08:52 PM

I think that I will start with the classes & methods included, then once I finish the WebBrowser control I will slowly create my own methods and classes.

Thanks
Was This Post Helpful? 0
  • +
  • -

#4 gbertoli3  Icon User is offline

  • DIC at Heart + Code
  • member icon

Reputation: 40
  • View blog
  • Posts: 1,162
  • Joined: 23-June 08

Re: WebBrowser

Posted 14 November 2008 - 09:43 PM

OK So here is what I have in the Paint() event. When I add the WebBrowser to the Form it makes Visual Studio Unresponsive. Can you tell me why?

NOTE: link is a String containing the url to get
        private void WebBrowser_Paint(object sender, PaintEventArgs e)
        {
            System.Net.HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(link);
            request.Method = "POST";
            String postData = "firstone=" + link;
            ASCIIEncoding encoding = new ASCIIEncoding();
            byte[] byte1 = encoding.GetBytes(postData);
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = byte1.Length;
            System.IO.Stream newStream = request.GetRequestStream();
            newStream.Write(byte1, 0, byte1.Length);
            Console.WriteLine("The value of 'ContentLength' property after sending the data is {0}", request.ContentLength);
            newStream.Close();


            HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(link);
            HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
            Stream receiveStream = myHttpWebResponse.GetResponseStream();
            Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
            StreamReader readStream = new StreamReader(receiveStream, encode);
            //Console.WriteLine("\r\nResponse stream received.");
            e.Graphics.DrawString("\r\nResponse stream received.", Font, Brushes.Black, 0, 0);
            Char[] read = new Char[256];
            int count = readStream.Read(read, 0, 256);
            //Console.WriteLine("HTML...\r\n");
            e.Graphics.DrawString("HTML...\r\n", Font, Brushes.Black, 0, 0);
            while (count > 0)
            {
                String str = new String(read, 0, count);
                Console.Write(str);
                count = readStream.Read(read, 0, 256);
            }
            //Console.WriteLine("");
            e.Graphics.DrawString("", Font, Brushes.Black, 0, 0);
            myHttpWebResponse.Close();
            readStream.Close();
        }


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1