Salut à tous,
Je programme en C# une navigateur web sous le nom de Protom Navigator ... Enfin bref comme je poste dur ce forum c'est que j'ai un problème ^^.
Voici mon code :
Ce que je veut c'est que quand le composé wb termine de charger la page elle exécute la class wb_DocumentCompleted mais quand j'exécute mon programme, il ne se passe absolument rien de ce qui il y a dans la class : wb_DocumentCompleted ...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62 //Intilialisation navigateur wb par onglet actif private WebBrowser GetSelectedWebBrowser() { foreach (Control ctl in tabControl1.SelectedTab.Controls) { WebBrowser wb = ctl as WebBrowser; if (wb != null) return wb; } return null; } //Initialisation composant wb public void wb() { WebBrowser wb = GetSelectedWebBrowser(); wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted); } //Evenement lors de la fin du chargement de la page private void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { WebBrowser wb = GetSelectedWebBrowser(); string url = Convert.ToString(wb.Url); if (url.StartsWith("https://")) { textBox2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(192))))); } if (url.StartsWith("ftp://") | ((url.EndsWith(".rar"))) && ((url.EndsWith(".zip")))) { textBox2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); } string title = "Historique"; TabPage myTabPage = new TabPage(title); try { RichTextBox myRT = new RichTextBox(); myTabPage.Controls.Add(myRT); myRT.Dock = DockStyle.Fill; myRT.ReadOnly = true; string dateetheure = Convert.ToString(DateTime.Now); myRT.LoadFile("Historique.rtf"); string text = myRT.Text; string urlh = Convert.ToString(wb.Url); myRT.Text = "\n" + dateetheure + " - " + urlh + " : " + wb.DocumentTitle + text; myRT.SaveFile("Historique.rtf"); } catch (Exception ex) { MessageBox.Show(ex.Message); Clipboard.SetData(DataFormats.Text, ex.Message); } textBox2.Text = Convert.ToString(wb.Url); RichTextBox rtf = new RichTextBox(); string rt = Convert.ToString(rtf); rtf.Text = rt + " \n " + wb.Url; }
Pouvez-vous m'aidez SVP ?
Merci d'avance
Partager