資源簡介
這個例子不是webBrowser的html應用,只是借用html畫了界面(背景是動畫飄動的浮云和透明框圖)。
Winform中,在webBrowser寫入html(背景和一些菜單選擇項),點擊后,取得點擊的id值,
添加點擊事件,在winform里面判斷id值,執行相應不同的操作。
本例判斷點擊,根據取得的id值,執行打開新窗口的操作。
webBrowser的Winform操作的例子很多,比如寫入、取值、模擬輸入等等,可以百度下。
這里只是用了取值。
背景動畫網上巨多,搜索“CSS3 動畫”,直接將html代碼寫到字符串賦給webBrowser,需要判斷點擊的組件或圖片,
取個id值,在事件里判斷就可以了。
Winform中,在webBrowser寫入html(背景和一些菜單選擇項),點擊后,取得點擊的id值,
添加點擊事件,在winform里面判斷id值,執行相應不同的操作。
本例判斷點擊,根據取得的id值,執行打開新窗口的操作。
webBrowser的Winform操作的例子很多,比如寫入、取值、模擬輸入等等,可以百度下。
這里只是用了取值。
背景動畫網上巨多,搜索“CSS3 動畫”,直接將html代碼寫到字符串賦給webBrowser,需要判斷點擊的組件或圖片,
取個id值,在事件里判斷就可以了。
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { HtmlDocument htmlDoc = webBrowser1.Document; htmlDoc.Click = new HtmlElementEventHandler(htmlDoc_Click); //添加點擊事件 } //鼠標點擊事件 取得html點擊的 id 值,根據 id 值打開新窗口并傳遞參數 private void htmlDoc_Click(object sender, HtmlElementEventArgs e) { HtmlDocument doc = sender as HtmlDocument; HtmlElement ele = doc.GetElementFromPoint(e.ClientMousePosition); //取得點擊的 id 序號 int num = get_ID(ele.OuterHtml); //打開新窗口位置 int lx = this.Left 290; int ly = this.Top 80 num*80; //打開新窗口 f_info = new Form_Info(lx, ly,num); f_info.StartPosition = FormStartPosition.Manual; f_info.ShowDialog(); if (f_info.DialogResult == DialogResult.OK) { //這里寫代碼 } }
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Drawing.Imaging;
using?System.Linq;
using?System.Runtime.InteropServices;
using?System.Text;
using?System.Windows.Forms;
namespace?test1
{
????public?partial?class?Form1?:?Form
????{
????????[DllImport(“Gdi32.dll“?EntryPoint?=?“CreateRoundRectRgn“)]
????????private?static?extern?IntPtr?CreateRoundRectRgn
????????????????????????????(
????????????????????????????????int?nLeftRect
????????????????????????????????int?nTopRect
????????????????????????????????int?nRightRect
????????????????????????????????int?nBottomRect
????????????????????????????????int?nWidthEllipse
????????????????????????????????int?nHeightEllipse
???????????????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????..A..H.?????49152??2017-04-08?13:42??Winform_CSS3\.vs\test1\v14\.suo
?????文件?????195897??2016-03-08?22:46??Winform_CSS3\bin\Debug\img\cloud_one.png
?????文件?????286793??2016-03-08?22:47??Winform_CSS3\bin\Debug\img\cloud_three.png
?????文件?????212928??2016-03-08?22:47??Winform_CSS3\bin\Debug\img\cloud_two.png
?????文件??????20814??2017-03-02?19:34??Winform_CSS3\bin\Debug\img\logo.png
?????文件??????18276??2017-01-06?23:29??Winform_CSS3\bin\Debug\img\ok.png
?????文件???????7420??2016-11-12?21:47??Winform_CSS3\bin\Debug\img\tx1.jpg
?????文件???????5980??2016-11-12?21:48??Winform_CSS3\bin\Debug\img\tx2.jpg
?????文件???????9513??2016-11-12?21:48??Winform_CSS3\bin\Debug\img\tx3.jpg
?????文件???????6833??2016-11-12?21:48??Winform_CSS3\bin\Debug\img\tx4.jpg
?????文件???????7451??2016-11-12?21:48??Winform_CSS3\bin\Debug\img\tx5.jpg
?????文件???????6661??2016-11-12?21:49??Winform_CSS3\bin\Debug\img\tx6.jpg
?????文件???????5349??2016-11-12?21:49??Winform_CSS3\bin\Debug\img\tx7.jpg
?????文件????4191832??2017-03-06?23:16??Winform_CSS3\bin\Debug\img\書法字體.ttf
?????文件??????39424??2017-04-08?13:20??Winform_CSS3\bin\Debug\test1.exe
?????文件??????38400??2017-04-08?13:20??Winform_CSS3\bin\Debug\test1.pdb
?????文件??????22688??2017-04-08?11:31??Winform_CSS3\bin\Debug\test1.vshost.exe
?????文件????????490??2016-07-16?19:44??Winform_CSS3\bin\Debug\test1.vshost.exe.manifest
?????文件??????16482??2017-01-22?09:09??Winform_CSS3\bin\Debug\upload.png
?????文件??????13310??2017-04-08?13:20??Winform_CSS3\Form1.cs
?????文件???????4543??2017-04-08?13:20??Winform_CSS3\Form1.Designer.cs
?????文件??????15349??2017-04-08?13:20??Winform_CSS3\Form1.resx
?????文件???????6637??2017-04-08?13:15??Winform_CSS3\Form_Info.cs
?????文件???????4454??2017-04-08?12:49??Winform_CSS3\Form_Info.Designer.cs
?????文件???????7088??2017-04-08?12:49??Winform_CSS3\Form_Info.resx
?????文件????????486??2017-04-07?19:19??Winform_CSS3\Program.cs
?????文件???????1318??2017-04-07?19:19??Winform_CSS3\Properties\AssemblyInfo.cs
?????文件???????2823??2017-04-07?19:19??Winform_CSS3\Properties\Resources.Designer.cs
?????文件???????5612??2017-04-07?19:19??Winform_CSS3\Properties\Resources.resx
?????文件???????1092??2017-04-07?19:19??Winform_CSS3\Properties\Settings.Designer.cs
............此處省略19個文件信息
- 上一篇:C# 半透明窗體
- 下一篇:監視文件和資料夾系統變化情況
評論
共有 條評論