|
 |
|
ช่วยเพิ่มเติมให้หน่อยครับ ผมลองทำแล้วแต่ยังไม่ได้ ช่วยแนะนำให้แนวทางในการใช้งานหน่อยครับ |
|
 |
|
|
 |
 |
|

ช่วยผมหน่อยครับ ทำยังไงเว็บเบราเซอร์ ในช่อง combobox ผม จะสามารถ ดึง cookkie มาใช้งาน ตอนที่เราพิมพ์ url ในช่อง comboboxครับ ช่วยหน่อยครับ
นี้คือโค้ดทั้งหมดที่ผมมีครับ
Code (C#)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Collections;
using System.IO;
using System.Xml;
using System.Text;
using System.Net;
using System.Diagnostics;
using System.Globalization;
using System.Windows.Forms;
namespace TBrowser
{
public partial class TBrowser : Form
{
/*public static String favXml = "favorits.xml", linksXml = "links.xml";
String settingsXml = "settings.xml", historyXml = "history.xml";
List<String> urls = new List<String>();
XmlDocument settings = new XmlDocument();
String homePage;
CultureInfo currentCulture;*/
public TBrowser()
{
InitializeComponent();
//currentCulture = CultureInfo.CurrentCulture;
}
/*private void setVisibility()
{
if (!File.Exists(settingsXml))
{
XmlElement r = settings.CreateElement("settings");
settings.AppendChild(r);
XmlElement el;
el = settings.CreateElement("menuBar");
el.SetAttribute("visible", "True");
r.AppendChild(el);
el = settings.CreateElement("adrBar");
el.SetAttribute("visible", "True");
r.AppendChild(el);
el = settings.CreateElement("linkBar");
el.SetAttribute("visible", "True");
r.AppendChild(el);
el = settings.CreateElement("favoritesPanel");
el.SetAttribute("visible", "True");
r.AppendChild(el);
el = settings.CreateElement("SplashScreen");
el.SetAttribute("checked", "True");
r.AppendChild(el);
el = settings.CreateElement("homepage");
el.InnerText = "about:blank";
r.AppendChild(el);
el = settings.CreateElement("dropdown");
el.InnerText = "15";
r.AppendChild(el);
}
}*/
private string[] UrlMemoryArray = new string[100];
private string[] memory = new string[100];
private int count = 0;
private string m_strURL = "";
/*private TBrowser getCurrentBrowser()
{
return (TBrowser)webbrowser.Controls[0];
}*/
private void Form1_Load(object sender, EventArgs e)
{
if (m_strURL == "")
{
webbrowser.Navigate("http://www.google.co.th");
memory[count] = urlcombobox.Text;
}
else
{
webbrowser.Navigate(m_strURL);
}
UrlMemoryArray[count] = urlcombobox.Text;
//urlcombobox.SelectedItem = urlcombobox.Items[0];
//setVisibility();
}
private void btnb_Click(object sender, EventArgs e)
{
if (count > 0)
{
count = count - 1;
urlcombobox.Text = memory[count];
webbrowser.Navigate(urlcombobox.Text);
btnf.Enabled = true;
}
}
private void btnf_Click(object sender, EventArgs e)
{
if (count < 100)
{
count = count + 1;
urlcombobox.Text = memory[count];
webbrowser.Navigate(urlcombobox.Text);
btnb.Enabled = true;
count = count + 1;
if (memory[count] == null)
{
btnf.Enabled = false;
}
count = count - 1;
}
}
private void btng_Click(object sender, EventArgs e)
{
webbrowser.Navigate(urlcombobox.Text);
}
private void btnre_Click(object sender, EventArgs e)
{
webbrowser.Refresh();
}
private void webbrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
donelabel.Visible = false;
prog.Visible = true;
prog.Value = 0;
prog.Minimum = 0;
prog.Maximum = 100;
prog.Step = 10;
prog.PerformStep();
}
private void webbrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
prog.Step = 80;
prog.PerformStep();
urlcombobox.Text = webbrowser.Url.ToString();
openinglabel.Text = "Openning: " + urlcombobox.Text;
openinglabel.Visible = true;
}
private void webbrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
prog.Step = 10;
prog.PerformStep();
prog.Visible = false;
openinglabel.Visible = false;
donelabel.Visible = true;
if (memory[count].ToString() != webbrowser.Url.ToString())
{
count = count + 1;
memory[count] = urlcombobox.Text;
}
if (count > 0)
{
btnb.Enabled = true;
}
else
{
btnb.Enabled = false;
}
}
private void urltext_Click(object sender, EventArgs e)
{
urlcombobox.SelectAll();
}
private void urltext_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
webbrowser.Navigate(urlcombobox.Text);
}
}
private void btnhome_Click(object sender, EventArgs e)
{
webbrowser.GoHome();
}
private void btnsave_Click(object sender, EventArgs e)
{
webbrowser.ShowSaveAsDialog();
}
private void btnprint_Click(object sender, EventArgs e)
{
webbrowser.ShowPrintDialog();
}
private void btnpv_Click(object sender, EventArgs e)
{
webbrowser.ShowPrintPreviewDialog();
}
private void btnppt_Click(object sender, EventArgs e)
{
webbrowser.ShowPropertiesDialog();
}
private void webbrowser_NewWindow(object sender, CancelEventArgs e)
{
TBrowser frmIE = new TBrowser();
frmIE.NavigateIE(((WebBrowser)sender).StatusText);
frmIE.Show();
e.Cancel = true;
}
private void NavigateIE(string url)
{
m_strURL = url;
}
/*private void showUrl()
{
if (File.Exists(historyXml))
{
XmlDocument myXml = new XmlDocument();
myXml.Load(historyXml);
int i = 0;
int num = int.Parse(settings.DocumentElement.ChildNodes[6].InnerText.ToString());
foreach (XmlElement el in myXml.DocumentElement.ChildNodes)
{
if (num <= i++) break;
else urlcombobox.Items.Add(el.GetAttribute("url").ToString());
}
}
}*/
/*private void urlcombobox_DropDown(object sender, EventArgs e)
{
urlcombobox.Items.Clear();
showUrl();
}*/
/*private void urlcombobox_SelectedIndexChanged(object sender, EventArgs e)
{
getCurrentBrowser().Navigate(urlcombobox.SelectedItem.ToString());
}*/
private void Navigate(string p)
{
throw new NotImplementedException();
}
private void urlcombobox_Click(object sender, EventArgs e)
{
urlcombobox.SelectAll();
}
}
}
Tag : .NET, VS 2010 (.NET 4.x)

|
|
 |
 |
 |
 |
Date :
2012-11-05 20:03:06 |
By :
touchbb |
View :
987 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช้ xml แทนขนมขบเคี้ยว
|
 |
 |
 |
 |
Date :
2012-11-06 08:25:45 |
By :
ห้ามตอบเกินวันละ 2 กระทู้ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วย หน่อยครับ โพส โค้ดให้แนวทางผมซักนิดครับ
|
 |
 |
 |
 |
Date :
2012-11-08 21:57:41 |
By :
touchbb |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|