成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

C#做瀏覽器源程序

開發(fā) 后端
這里介紹C#做瀏覽器源程序,掌握了COM組件在Visual C#使用方法,就可以利用Visual C#編寫出功能更強(qiáng)大,適應(yīng)性更強(qiáng)的軟件來,但編寫的過程又十分的簡單。

C#做瀏覽器源程序

了解C#源程序代碼,就可以比較容易編寫一個(gè)屬于自己的瀏覽器了,下面是用Visual C#做瀏覽器源程序代碼,他具備了IE瀏覽器的一些常用的功能。 

 

  1. using System ;  
  2. using System.Drawing ;  
  3. using System.Collections ;  
  4. using System.ComponentModel ;  
  5. using System.Windows.Forms ;  
  6. using System.Data ;  
  7. using AxSHDocVw ;  
  8. public class Form1 : Form  
  9. {  
  10. private ToolBar toolBar1 ;  
  11. private ToolBarButton tb1 ;  
  12. private ToolBarButton tb2 ;  
  13. private ToolBarButton tb3 ;  
  14. private ToolBarButton tb4 ;  
  15. private ToolBarButton tb5 ;  
  16. private Label label1 ;  
  17. private TextBox textBox1 ;  
  18. private Button button1 ;  
  19. private AxWebBrowser axWebBrowser1 ;  
  20. private System.ComponentModel.Container components = null ;  
  21. public Form1 ( )  
  22. {  
  23. InitializeComponent ( ) ;  
  24. }  
  25. //清除程序中使用過的資源  
  26. protected override void Dispose ( bool disposing )  
  27. {  
  28. if ( disposing )  
  29. {  
  30. if ( components != null )  
  31. {  
  32. components.Dispose ( ) ;  
  33. }  
  34. }  
  35. base.Dispose ( disposing ) ;  
  36. }  
  37. //初始化窗體中的各個(gè)組件  
  38. private void InitializeComponent ( )  
  39. {  
  40. tb1 = new ToolBarButton ( ) ;  
  41. tb2 = new ToolBarButton ( ) ;  
  42. tb3 = new ToolBarButton ( ) ;  
  43. toolBar1 = new ToolBar ( ) ;  
  44. tb4 = new ToolBarButton ( ) ;  
  45. tb5 = new ToolBarButton ( ) ;  
  46. button1 = new Button ( ) ;  
  47. textBox1 = new TextBox ( ) ;  
  48. axWebBrowser1 = new AxWebBrowser ( ) ;  
  49. label1 = new Label ( ) ;  
  50. ( ( System.ComponentModel.ISupportInitialize ) 
    ( this.axWebBrowser1 ) ).BeginInit ( ) ;  
  51. this.SuspendLayout ( ) ;  
  52.  
  53. tb1.Text = "后退" ;  
  54. tb2.Text = "前進(jìn)" ;  
  55. tb3.Text = "停止" ;  
  56. tb4.Text = "刷新" ;  
  57. tb5.Text = "主頁" ;  
  58.  
  59. toolBar1.Appearance = ToolBarAppearance.Flat ;  
  60. toolBar1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle ;  
  61. //在工具欄中加入按鈕  
  62. toolBar1.Buttons.Add ( tb1 ) ;  
  63. toolBar1.Buttons.Add ( tb2 ) ;  
  64. toolBar1.Buttons.Add ( tb3 ) ;  
  65. toolBar1.Buttons.Add ( tb4 ) ;  
  66. toolBar1.Buttons.Add ( tb5 ) ;  
  67. toolBar1.DropDownArrows = true ;  
  68. toolBar1.Name = "toolBar1" ;  
  69. toolBar1.ShowToolTips = true ;  
  70. toolBar1.Size = new System.Drawing.Size ( 612 , 39 ) ;  
  71. toolBar1.TabIndex = 0 ;  
  72. toolBar1.ButtonClick += new ToolBarButtonClickEventHandler ( toolBar1_ButtonClick ) ;  
  73. //定位“轉(zhuǎn)到”按鈕組件與窗體的上、右邊框保持一致  
  74. button1.Anchor = ( AnchorStyles.Top | AnchorStyles.Right ) ;  
  75. button1.DialogResult = DialogResult.OK ;  
  76. button1.Location = new System.Drawing.Point ( 544 , 45 ) ;  
  77. button1.Name = "button1" ;  
  78. button1.Size = new System.Drawing.Size ( 40 , 23 ) ;  
  79. button1.TabIndex = 3 ;  
  80. button1.Text = "轉(zhuǎn)到" ;  
  81. button1.Click += new System.EventHandler ( button1_Click ) ;  
  82. //定位地址文本框組件與窗體的上、左、右邊框保持一致  
  83. textBox1.Anchor = ( ( AnchorStyles.Top | AnchorStyles.Left )  
  84. | AnchorStyles.Right ) ;  
  85. textBox1.Location = new System.Drawing.Point ( 64 , 47 ) ;  
  86. textBox1.Name = "textBox1" ;  
  87. textBox1.Size = new System.Drawing.Size ( 464 , 21 ) ;  
  88. textBox1.TabIndex = 2 ;  
  89. textBox1.Text = "" ;  
  90. //定位瀏覽器組件與窗體的上、下、左、右邊框保持一致  
  91. axWebBrowser1.Anchor = ( ( ( AnchorStyles.Top | AnchorStyles.Bottom )  
  92. | AnchorStyles.Left )  
  93. | AnchorStyles.Right ) ;  
  94. axWebBrowser1.Enabled = true ;  
  95. axWebBrowser1.Location = new System.Drawing.Point ( 0 , 72 ) ;  
  96. axWebBrowser1.Size = new System.Drawing.Size ( 608 , 358 ) ;  
  97. axWebBrowser1.TabIndex = 4 ;  
  98.  
  99. label1.Location = new System.Drawing.Point ( 16 , 48 ) ;  
  100. label1.Name = "label1" ;  
  101. label1.Size = new System.Drawing.Size ( 48 , 16 ) ;  
  102. label1.TabIndex = 1 ;  
  103. label1.Text = "地址:" ;  
  104.  
  105. this.AutoScaleBaseSize = new System.Drawing.Size ( 6 , 14 ) ;  
  106. this.ClientSize = new System.Drawing.Size ( 612 , 433 ) ;  
  107.  
  108. this.Controls.Add ( axWebBrowser1 ) ;  
  109. this.Controls.Add ( button1 ) ;  
  110. this.Controls.Add ( textBox1 ) ;  
  111. this.Controls.Add ( label1 ) ;  
  112. this.Controls.Add ( toolBar1 ) ;  
  113. this.FormBorderStyle = FormBorderStyle.FixedSingle ;  
  114. this.Name = "Form1" ;  
  115. this.Text = "visual C#做瀏覽器" ;  
  116. ( ( System.ComponentModel.ISupportInitialize ) 
    ( this.axWebBrowser1 ) ).EndInit ( ) ;  
  117. this.ResumeLayout ( false ) ;  
  118.  
  119. }  
  120. static void Main ( )  
  121. {  
  122. Application.Run ( new Form1 ( ) ) ;  
  123. }  
  124. //實(shí)現(xiàn)瀏覽器主要功能  
  125. private void toolBar1_ButtonClick 
    ( object sender , ToolBarButtonClickEventArgs e )  
  126. {  
  127. //瀏覽器中的“后退”  
  128. if ( e.Button == tb1 )  
  129. {  
  130. axWebBrowser1.GoBack ( ) ;  
  131. }  
  132. //瀏覽器中的“前進(jìn)”  
  133. if ( e.Button == tb2 )  
  134. {  
  135. axWebBrowser1.GoForward ( ) ;  
  136. }  
  137. //瀏覽器中的“停止”  
  138. if ( e.Button == tb3 )  
  139. {  
  140. axWebBrowser1.Stop ( ) ;  
  141. }  
  142. //瀏覽器中的“刷新”  
  143. if ( e.Button == tb4 )  
  144. {  
  145. axWebBrowser1.Refresh ( ) ;  
  146. }  
  147. //瀏覽器中的“主頁”  
  148. if ( e.Button == tb5 )  
  149. {  
  150. axWebBrowser1.GoHome ( ) ;  
  151. }  
  152.  
  153. }  
  154. //瀏覽指定的Web地址  
  155. private void button1_Click ( object sender , System.EventArgs e )  
  156. {  
  157. System.Object nullObject = 0 ;  
  158. string str = "" ;  
  159. System.Object nullObjStr = str ;  
  160. Cursor.Current = Cursors.WaitCursor ;  
  161. axWebBrowser1.Navigate ( textBox1.Text , ref nullObject , 
    ref nullObjStr , ref nullObjStr , ref nullObjStr ) ;  
  162. Cursor.Current = Cursors.Default ;  
  163. }  
  164. }  

 

編譯源程序和編譯后的執(zhí)行程序的運(yùn)行界面在經(jīng)過如下命令編譯后,就可以得到可以自己的瀏覽器了csc /t:winexe /r:AxSHDocVw.dll /r:SHDocVw.dll /r:system.dll/r:system.windows.forms.dll /r:system.drawing.dll brower.cs

總結(jié)
至此一個(gè)功能相對完備的“瀏覽器”就算完成了,其實(shí)用Visual C#做瀏覽器源程序的過程,也就是Visual C#中使用COM組件的過程。掌握了COM組件在Visual C#使用方法,就可以利用Visual C#編寫出功能更強(qiáng)大,適應(yīng)性更強(qiáng)的軟件來,但編寫的過程又十分的簡單。

【編輯推薦】

  1. 淺談C# Connection對象
  2. C#實(shí)現(xiàn)PrintPage方法
  3. 利用Visual C#和C#語言特性
  4. C#管道技術(shù)學(xué)習(xí)經(jīng)驗(yàn)
  5. 概述C#復(fù)合控件構(gòu)建
責(zé)任編輯:佚名 來源: 博客園
相關(guān)推薦

2009-08-11 13:48:11

C# ConfigDl

2009-08-31 14:54:35

C#對象瀏覽器

2009-09-03 17:49:59

C#瀏覽器開發(fā)

2009-09-03 17:54:04

C#開發(fā)瀏覽器

2009-09-03 19:00:15

C#判斷瀏覽器

2009-09-03 18:55:08

C#判斷瀏覽器

2009-08-24 18:06:36

源程序代碼C#讀取XML文件

2009-09-04 09:27:48

C#調(diào)用瀏覽器

2009-09-04 11:03:32

C#文件瀏覽器

2009-08-18 13:59:21

C#多標(biāo)簽瀏覽器

2009-09-04 10:05:16

C#調(diào)用瀏覽器瀏覽器的原理

2011-06-10 16:44:17

Qt 瀏覽器

2009-08-20 10:48:05

C#做Screen C

2013-11-22 09:58:36

2012-09-24 14:43:51

C#網(wǎng)絡(luò)協(xié)議C

2012-03-20 11:07:08

2012-03-20 11:41:18

海豚瀏覽器

2012-03-19 17:25:22

2012-03-20 11:31:58

移動(dòng)瀏覽器

2012-03-19 17:17:00

移動(dòng)瀏覽器歐朋
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號

主站蜘蛛池模板: 久久久久国产精品一区 | 中文字幕亚洲精品 | 欧美成人第一页 | 国产在线视频一区二区董小宛性色 | 日本一区二区高清视频 | 99re国产精品 | 国产欧美精品一区二区三区 | 精品一区二区在线视频 | 91免费在线视频 | 国产片网站 | 欧美一级特黄aaa大片在线观看 | 久久久精 | 在线一区二区观看 | 免费v片在线观看 | 国产精品夜间视频香蕉 | 精品国产一区二区三区四区在线 | 久久久99精品免费观看 | 亚洲国产欧美在线 | 欧美日韩精品专区 | 久久这里只有精品首页 | 一级毛片免费看 | 国产成人综合亚洲欧美94在线 | 成人性生交a做片 | 久久综合爱 | tube国产 | 在线观看av中文字幕 | 久久精品国产亚洲一区二区 | 日韩一级精品视频在线观看 | 欧美久久久网站 | 亚洲在线一区二区 | 日韩免费一区二区 | 男女羞羞视频免费看 | 涩涩视频网站在线观看 | 亚洲欧美精品久久 | 国产激情一区二区三区 | 久久久人 | 国产精品久久网 | 国产一级片在线观看视频 | 真人一级毛片 | 国产精品美女久久久久aⅴ国产馆 | 日日夜夜精品视频 |