别人是说了再做,我是做了再说;别人说了不一定做,我是做了不一定说。

一种开发软件的新思路,给Web页面穿个马甲,用web页面做软件UI,用C#(或者C++等其它语言)代码做功能

喜欢就点一下“推荐”,给我点写下去的动力,谢谢!

声明:

本文版权归作者碧血黄沙.NET所有,欢迎转载,但转载必须保留以下版权信息,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

作者:碧血黄沙.net
出处:博客园http://www.cnblogs.com/wjj/archive/2010/02/25/1673157.html

你可以免费使用或修改提供的源代码,但请保留源代码中的版权信息。


本人继仿QQMusic、仿360杀毒、仿QQRadio播放器之后,最近疯狂迷恋上了“金山网盾”的界面。老在思考如何用C#做出象“金山网盾”那样的界面。

想模仿它,那就先研究它。打开“金山网盾”的安装目录,发现有一个webui文件夹,哈哈,真爽,软件所有的界面资源全在这里了,我就以webui\kwebshield\main.htm文件为例子说明一下吧!

直接在浏览器打开main.htm,发现和软件主界面一模一样,嘿嘿,终于找到了。但点击上面的按钮均无反应,看看WEB页面的代码如下:

 

代码
  1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2 <html>
  3     <head>
  4         <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  5         <title>金山网盾首页</title>
  6         <link rel="stylesheet" type="text/css" href="../public/css/common.css">
  7         <link rel="stylesheet" type="text/css" href="style/index/index.css">
  8         <script type="text/javascript" src="../public/lib/jquery.js"></script>
  9         <script type="text/javascript" src="js/index/js_loader.js"></script>
 10     </head>
 11     <body ondrag="return false;" kcore="OnKWebApp" onselectstart="return false;">
 12         <div id="DivMain">
 13             <div id="DivTitle">
 14                 <div id="DivSystemBtn">
 15                     <img src="images/index/icob1_normal.gif"/>
 16                     <img src="images/index/icob2_normal.gif"/>
 17                     <img src="images/index/icob3_normal.gif"/>
 18                 </div>
 19                 <div id="DivMenuFeedBack">
 20                     <href="javascript:void(0);" hidefocus="true"><img src="images/index/fankui_normal.gif"/></a>
 21                 </div>
 22             </div>
 23             <div id="DivMenu">
 24                 <div id="DivSafeStatus"><img id="ImgSafeSta" src="images/index/anquan.jpg" /></div>
 25                 <div id="DivMenuMon"><img class="MenuBtn" id="ImgMenuMon" src="images/index/jiankong_on.jpg"/></div>
 26                 <div id="DivMenuSet"><img class="MenuBtn" id="ImgMenuSet" src="images/index/shezhi_normal.jpg"/></div>
 27                 <div id="DivMenuBkList"><img class="MenuBtn" id="ImgMenuBkList" src="images/index/mingdan_normal.jpg"/></div>
 28                 <div id="DivMenuLog"><img class="MenuBtn" id="ImgMenuLog" src="images/index/chakan_normal.jpg"/></div>
 29             </div>
 30             <div id="DivContent">
 31                 <div id="DivMon">
 32                     <div id="DivTextSta">金山网盾正在保护您的上网安全</div>
 33                     <div id="DivStaTab">
 34                         <table>
 35                             <tr>
 36                                 <td width="290" height="55" id="sta_item_1" class="sta_item">启用浏览器保护
 37                                 <style="color:#000;font-size:12px;">防止浏览网页时中毒或者上当受骗</p></td>
 38                                 <td width="50" class="sta_text" id="bStartKWS">已启用</td>
 39                                 <td width="72"><span id="BtnOpenBrowserMon" class="BtnStart">关闭</span></td>
 40                             </tr>
 41                             <tr>
 42                                 <td height="65" id="sta_item_2" class="sta_item">启用搜索引擎保护
 43                                 <style="color:#000;font-size:12px;">保护百度、Google、Bing、搜狗等搜索安全</p></td>
 44                                 <td class="sta_text" id="bStartKWS4Search">已启用</td>
 45                                 <td><span id="BtnOpenSearchMon" class="BtnStart">关闭</span></td>
 46                             </tr>
 47                             <tr>
 48                                 <td height="50" id="sta_item_2" class="sta_item">主页保护
 49                                 <style="color:#000;font-size:12px;" id="CurIeIndex">防止IE主页被恶意窜改</p></td>
 50                                 <td class="sta_text" id="bStartIEProt">已锁定</td>
 51                                 <td><span id="BtnOpenProtIE" class="BtnStart">锁定</span></td>
 52                             </tr>
 53                         </table>
 54                     </div>
 55                     <div id="DivLanJie">
 56                         <table>
 57                             <tr>
 58                                 <td>保护天数:</td>
 59                                 <td><span id="SpanProtDay">0</span> 天</td>
 60                                 <td></td>
 61                             </tr>
 62                             <tr>
 63                                 <td>拦截木马病毒总数:</td>
 64                                 <td width="50" align="center"><href="javascript:void(0);" title="查看日志" id="SpanHoldCount" hidefocus="true" >0</a></td>
 65                                 <td style="padding-top:3px;padding-left:10px;"><href="javascript:void(0);" hidefocus="true" title="清空所有拦截记录" id="BtnResetHoldCount" >清零</a>    </td>
 66                             </tr>
 67                         </table>
 68                         <table style="margin-top:50px;">
 69                             <tr>
 70                                 <td colspan="2">病毒库版本:<span id="SpanLibVer">查询中...</span></td>
 71                             </tr>
 72                             <tr>
 73                                 <td width="180">程序版本:<span id="SpanVersionVal">查询中...</span></td>
 74                                 <td align="center"><span id="BtnUpdate"><href="javascript:void(0);" hidefocus="true" id="notify_call_update">立即升级</a></span></td>
 75                             </tr>
 76                         </table>
 77                     </div>
 78                     <div id="Frame4Report">
 79                         <!--<iframe src="http://labs.duba.net/kws/kwsad/kwsad.html" frameborder="no" border="0" width="200" height="168" allowtransparency="true"></iframe>-->
 80                         <iframe src=""  id="BOBAO" frameborder="no" border="0" width="209" height="168" allowtransparency="true"></iframe>
 81                     </div>
 82                 </div>
 83                 <div id="DivSet" style="display:none;">
 84                     <div class="DivSetMenu">
 85                         <div id="BaseSetMenu" class="BaseSetMenu">
 86                             <table>
 87                                 <tr>
 88                                     <td width="5"><img src="images/index/table_button_left.jpg"/></td>
 89                                     <td width="72" class="menu_on">基本设置</td>
 90                                     <td width="3"><img src="images/index/table_button_right.jpg"/></td>
 91                                 </tr>
 92                             </table>
 93                         </div>
 94                         <div id="BaseSetMenu_1" class="BaseSetMenu" style="display:none;">基本设置</div>
 95                         <div id="CustomSetMenu" class="CustomSetMenu" style="display:none;">
 96                             <table>
 97                                 <tr>
 98                                     <td width="5"><img src="images/index/table_button_left.jpg"/></td>
 99                                     <td width="112" class="menu_on">自定义浏览器保护</td>
100                                     <td width="3"><img src="images/index/table_button_right.jpg"/></td>
101                                 </tr>
102                             </table>
103                         </div>                        
104                         <div id="CustomSetMenu_1" class="CustomSetMenu">自定义浏览器保护</div>
105                         <div id="ProtIEMenu" class="ProtIEMenu" style="display:none;">
106                             <table>
107                                 <tr>
108                                     <td width="5"><img src="images/index/table_button_left.jpg"/></td>
109                                     <td width="112" class="menu_on">IE首页锁定</td>
110                                     <td width="3"><img src="images/index/table_button_right.jpg"/></td>
111                                 </tr>
112                             </table>
113                         </div>                        
114                         <div id="ProtIEMenu_1" class="ProtIEMenu">IE首页锁定</div>
115                     </div>
116                     <div id="DivBaseSetContent" >
117                         <div id="DivStepFirst">
118                             <table>
119                                 <tr>
120                                     <td width="285">
121                                         <input type='checkbox' id="ChkStartTray"/>
122                                         <label for="ChkStartTray">启动托盘图标</label>
123                                     </td>                                
124                                     <td>
125                                         <input type='checkbox' id="ChkStartTrayFlash" disabled="true"/>
126                                         <label for="ChkStartTrayFlash">启动托盘闪动提示</label>
127                                     </td>
128                                 </tr>
129                             </table>
130                         </div>
131                         <div id="DivStepSecond">
132                             <table>
133                                 <tr>
134                                     <td width="175">
135                                         <input type='checkbox' id="ChkStartBox"/>
136                                         <label for="ChkStartBox">开启闪框提醒</label>
137                                     </td>
138                                     <td width="175">
139                                         <input type='checkbox' id="ChkRedBox" disabled="true"/>
140                                         <label for="ChkRedBox">仅危险时闪框</label>
141                                     </td>                                                                    
142                                 </tr>
143                             </table>
144                             <table style="margin-top:10px;">
145                                 <tr>
146                                     <td width="85">闪烁时间:</td>
147                                     <td width="88">
148                                         <input type='radio' id="RadTimeShort" name="BoxTimeType" value="1">
149                                         <label for="RadTimeShort">较短</label>
150                                     </td>
151                                     <td width="107">
152                                         <input type='radio' id="RadTimeNormal" name="BoxTimeType" value="3">
153                                         <label for="RadTimeNormal">正常</label>
154                                     </td>
155                                     <td>
156                                         <input type='radio' id="RadTimeLong" name="BoxTimeType" value="5">
157                                         <label for="RadTimeLong">较长</label>
158                                     </td>
159                                 </tr>
160                             </table>
161                             <table style="margin-top:10px;">
162                                 <tr>
163                                     <td width="85">颜色设置:</td>
164                                     <td>安全提醒:</td>
165                                     <td width="65"><div id="SafeColor"  class="ColorSelect" selfparam="0"></div></td>
166                                     <td>钓鱼警告:</td>
167                                     <td width="65"><div id="FraudColor" class="ColorSelect" selfparam="1"></div></td>
168                                     <td>挂马警告:</td>
169                                     <td width="65"><div id="TrojanColor" class="ColorSelect" selfparam="2"></div></td>
170                                 </tr>
171                             </table>    
172                         </div>
173                         <div id="DivStep4">
174                             <table>
175                                 <tr>
176                                     <td width="185" height="85" valign="center"><input type="checkbox" id="StartProtMouse" /> 
177                                     <label for="StartProtMouse">开启鼠镖保护</label>
178                                     <style="color:#000;">(为鼠标所指链接给出安全提示)</p>
179                                     </td>                                
180                                 </tr>
181                             </table>                            
182                         </div>
183                         <div id="DivStepThree" style="display:none;">
184                             <table style="margin-top:5px;">
185                                 <tr>
186                                     <td width="175"><input type="checkbox" id="StartProtDownLoad" /> 
187                                     <label for="StartProtDownLoad">启动下载保护</label></td>                                    
188                                 </tr>
189                             </table>
190                             <table style="margin-top:20px;margin-left:10px;">
191                                 <tr>
192                                     <td width="120"><input type="checkbox" id="ProtBrowser" /> 
193                                     <label for="ProtBrowser">浏览器</label></td>
194                                     <td width="120"><input type="checkbox" id="ProtXunLei" /> 
195                                     <label for="ProtXunLei">迅雷</label></td>
196                                     <td width="120"><input type="checkbox" id="ProtXuanFeng" /> 
197                                     <label for="ProtXuanFeng">QQ旋风</label></td>
198                                     <td width="120"><input type="checkbox" id="ProtFlashGet" /> 
199                                     <label for="ProtFlashGet">FlashGet</label></td>
200                                 </tr>
201                             </table>
202                         </div>
203                         <div id="DivTipReboot">设置需浏览器重启才生效    </div>
204                         <div id="DivSetDef" class="BtnComBig">恢复默认设置</div>
205                         <div id="DivSetApply" class="BtnComMid">应   用</div>
206                     </div>
207                     <div id="DivCustomSetContent" style="display:none;">
208                         <div id="CustomSetTip">金山网盾支持所有浏览器,但不能避免一些程序腾空而出,您可以在列表中添加需要保护的程序</div>
209                         <!--模拟表格头部-->
210                         <div id="DivCustomTabHead">
211                             <table class="TabListHead">
212                                 <tr height="24">
213                                     <td width="450" style="padding-left:30px;">程序名</td>
214                                     <td width="3"><img src="images/index/rz_table_line.gif"/></td>
215                                     <td width="67" style="padding-left:30px;">删除</td>
216                                 </tr>
217                             </table>
218                         </div>
219                         <!--带滚动条表格-->
220                         <div id="DivScroCustomTab">
221                             <table id="TabCustomList" class="TabCom">
222                             </table>
223                             <table style="display:none;">
224                                 <tr height="20" id="TrForCreateProtEXE">
225                                     <td width="450" style="padding-left:10px;"></td>
226                                     <td width="70"><href="javascript:void(0);" class="DelProtExe">删除</a></td>
227                                 </tr>                        
228                             </table>
229                         </div>
230                         <div id="DivLinkCustom"><href="javascript:void(0);" hidefocus="true" title="只保护exe类型的可执行文件" id="BtnAddCustom">添加</a></div>
231                     </div>
232                     <!--改成IE首页保护-->                    
233                     <div id="DivProtIESetContent" style="display:none;">
234                         <div id="DivClock" class="DivClock">
235                             <table style="margin-top:10px;">
236                                 <tr>
237                                     <td width="386">输入要锁定的网址:<input type="text" class="IeUrl" value="" id="IEIndexText" /></td>                                    
238                                     <td><div id="BtnLockIE" class="BtnComMid">锁  定</div></td>
239                                 </tr>
240                             </table>
241                             <table style="margin-top:10px;">
242                                 <tr>
243                                     <td width="125" align="right"><span id="URLBlank" class="LinkBtn">使用空白页</span></td>
244                                     <td width="125" align="right"><span id="URLBaidu" class="LinkBtn"><span id="svt_name_2" style="cursor:pointer;">baidu</span>设为首页</span></td>
245                                     <td width="125" align="right"><span id="URLSVT" class="LinkBtn"><span id="svt_name" style="cursor:pointer;">hao123</span>设为首页</span></td>
246                                 </tr>
247                             </table>
248                         </div>
249                         <!--专版情况下是用-->
250                         <div id="DivSVTClock" class="DivClock" style="display:none;">
251                             <table style="margin-top:10px;">
252                                 <tr>
253                                     <td width="460">您当前使用的是<span id="SVTNAME"></span>专版金山网盾,IE首页锁定能有效防止IE首页被恶意篡改</td>                                    
254                                 </tr>
255                                 <tr>
256                                     <td width="460" height="35"><span id="TipSVT">已经将您的IE浏览器首页保护为: </span><href="" target="_blank" hidefocus="true" id="SVTURL"></a></td>
257                                 </tr>
258                                 <tr>
259                                     <td align="right"><href="javascript:void(0);" id="ChangeIndex" hidefocus="true">我要锁定其他首页</a></td>                                    
260                                 </tr>
261                             </table>
262                         </div>
263                         <div id="DivClockErr">
264                             <table style="margin-top:10px;">
265                                 <tr>
266                                     <td height="25" style="color:#ff8040;font-weight:700;">如果锁定IE首页失败可以尝试以下解决方案:</td>                                    
267                                 </tr>
268                                 <tr>
269                                     <td height="25">1.添加“强制屏蔽列表”。(遇到顽固恶意首页,请将它添加到列表中,直接屏蔽。)</td>                                    
270                                 </tr>
271                                 <tr>
272                                     <td><table><tr><td>输入要屏蔽网址:<input type="text" id="InputPingBi" value="" /></td><td style="padding-left:20px;"><div id="BtnAddShield" class="BtnComMid">添  加</div></td></tr></table></td>                                    
273                                 </tr>
274                                 <tr>
275                                     <td style="padding-top:10px;padding-bottom:5px;">
276                                         <div class="DivTabIE">
277                                             <table width="100%" id="TabIeIndex" style="table-layout:fixed;"></table>
278                                             <!--为克隆提供模板-->
279                                             <table style="display:none;">
280                                                 <tr id="tr_ie_pb">
281                                                     <td width="410"><nobr></nobr></td>
282                                                     <td width="100%"><href="javascript:void(0);" class="DelTabIe" hidefocus="true">删除</a></td>
283                                                 </tr>
284                                             </table>
285                                         </div>
286                                     </td>                                    
287                                 </tr>
288                                 <tr>
289                                     <td height="25"><href="javascript:void(0);" id="UseKSfa" hidefocus="true">2.使用金山急救箱修复IE首页</a></td>                                    
290                                 </tr>
291                                 <tr>
292                                     <td height="25"><href="javascript:void(0);" hidefocus="true" id="ToFeedBack">3.向网盾研发人员反馈,请注意留下您的联系方式</a></td>                                    
293                                 </tr>
294                             </table>
295                         </div>
296                     </div>
297                 </div>
298                 <div id="DivBkList" style="display:none;" >
299                     <div class="DivSetMenu">
300                         <div id="BkListMenu" class="CLSBkListMenu">
301                             <table>
302                                 <tr>
303                                     <td width="5"><img src="images/index/table_button_left.jpg"/></td>
304                                     <td width="72" class="menu_on">网站黑名单</td>
305                                     <td width="3"><img src="images/index/table_button_right.jpg"/></td>
306                                 </tr>
307                             </table>
308                         </div>
309                         <div id="BkListMenu_1" class="CLSBkListMenu" style="display:none;">网站黑名单</div>
310                         <div id="FilterMenu" class="CLSFilterMenu" style="display:none;">
311                             <table>
312                                 <tr>
313                                     <td width="5"><img src="images/index/table_button_left.jpg"/></td>
314                                     <td width="100" class="menu_on">网页内容净化</td>
315                                     <td width="3"><img src="images/index/table_button_right.jpg"/></td>
316                                 </tr>
317                             </table>
318                         </div>                        
319                         <div id="FilterMenu_1" class="CLSFilterMenu">网页内容净化</div>
320                     </div>
321                     <div id="DivAddBkList">
322                         <table>
323                             <tr>
324                                 <td colspan="5" height="35" class="BkTit">将你认为存在威胁网址添加到黑名单,金山网盾将阻止对该网站的访问 </td>
325                             </tr>
326                             <tr>
327                                 <td height="35"><input type="text" mamaxlength="128" id="TextAddURL" value=""/></td>
328                                 <td width="88"><input type="radio" value="1" name="WebType" checked id="ChkTypeM"/><label for="ChkTypeM">带毒网站</label></td>
329                                 <td width="88"><input type="radio" value="3" name="WebType" id="ChkTypeD"/><label for="ChkTypeD">欺诈网站</label></td>
330                                 <td width="88"><input type="radio" value="4" name="WebType" id="ChkTypeV"/><label for="ChkTypeV">恶意广告</label></td>
331                                 <td><div id="BtnAddBkList" class="BtnComBig">添加到黑名单</div></td>
332                             </tr>
333                         </table>
334                     </div>
335                     <!--模拟表格头部-->
336                     <div id="DivListTabHead">
337                         <table class="TabListHead">
338                             <tr height="24">
339                                 <td width="350" style="padding-left:30px;">网址</td>
340                                 <td width="3"><img src="images/index/rz_table_line.gif"/></td>
341                                 <td width="100" style="padding-left:30px;">性质</td>
342                                 <td width="3"><img src="images/index/rz_table_line.gif"/></td>
343                                 <td width="85" style="padding-left:30px;">删除</td>
344                             </tr>
345                         </table>
346                     </div>
347                     <!--带滚动条表格-->
348                     <div id="DivListTab">
349                         <table id="TabBkList" class="TabCom">
350                         </table>
351                         <table style="display:none;">
352                             <tr height="18" id="TrForCreateBkList">
353                                 <td width="353" style="padding-left:10px;"></td>
354                                 <td width="103"></td>
355                                 <td width="68"><href="javascript:void(0);" class="DelBkList">删除</a></td>
356                             </tr>                        
357                         </table>
358                     </div>
359                     <div id="DivListLink">                        
360                         <table>
361                             <tr>
362                                 <td width="40"><href="javascript:void(0);" hidefocus="true" id="notify_import_black_url">导入</a></td>
363                                 <td width="40"><href="javascript:void(0);" hidefocus="true" id="notify_export_black_url">导出</a></td>
364                                 <td width="40"><href="javascript:void(0);" hidefocus="true" id="notify_clean_black_url">清空</a></td>
365                                 <td width="130" align="center">当前第<span id="cur_page">1</span>/<span id="total_page">1</span></td>
366                                 <td width="40"><href="javascript:void(0);" hidefocus="true" id="first_page">首页</a></td>
367                                 <td width="40"><href="javascript:void(0);" hidefocus="true" id="prev_page">上页</a></td>
368                                 <td width="40"><href="javascript:void(0);" hidefocus="true" id="next_page">下页</a></td>
369                                 <td width="40"><href="javascript:void(0);" hidefocus="true" id="last_page">末页</a></td>
370                                 <td width="75"  style="padding-top:0px;">转到 <input type="text" id="go_page" value="" style="width:30px;" size="1" maxlength="6"/></td>
371                                 <td width="30"  style="padding-top:0px;"><img id="Btn_go" style="cursor:pointer;" src="images/index/go_normal.gif" alt="转到" /></td>
372                             </tr>
373                         </table>
374                     </div>
375                     <!-- 改成 网页净化-->
376                     <div id="DivFilterSetContent" style="display:none;">
377                         <div id="FilterSetTip">
378                             <table>
379                                 <tr><td height="30"><input type="checkbox" id="StartFilter" />  <label for="StartFilter" style="color:#326D00;font-weight:700;outline:none;">启用网页内容净化</label></td><td></td></tr>
380                                 <tr><td style="padding-left:30px;height:30px;"><input type="text" id="InputFilter" value="" maxlength="256"></td><td style="padding-left:30px;"><div id="DivAddFilter" class="BtnComMid">添  加</div></tr>
381                             </table>
382                         </div>
383                         <!--模拟表格头部-->
384                         <div id="DivFilterTabHead">
385                             <table class="TabListHead">
386                                 <tr height="24">
387                                     <td width="37" style="padding-left:10px;">启用</td>
388                                     <td width="3"><img src="images/index/rz_table_line.gif"/></td>
389                                     <td width="410" style="padding-left:30px;">规则</td>
390                                     <td width="3"><img src="images/index/rz_table_line.gif"/></td>
391                                     <td width="67" style="padding-left:30px;">删除</td>
392                                 </tr>
393                             </table>
394                         </div>
395                         <!--带滚动条表格-->
396                         <div id="DivScroFilterTab">
397                             <table id="TabFilterList" class="TabCom">                                
398                             </table>
399                             <table style="display:none;">
400                                 <tr height="20" id="TrForCreateFilter">
401                                     <td width="43" align="center">
402                                         <input type="checkbox" class="StartItemFilter" checked="true"/>
403                                     </td>
404                                     <td width="390" style="padding-left:10px;"><nobr></nobr></td>
405                                     <td width="70" align="center"><href="javascript:void(0);" class="DelFilter">删除</a></td>
406                                 </tr>                        
407                             </table>
408                         </div>
409                         <div id="DivLinkCustom">
410                             <href="javascript:void(0);" hidefocus="true" id="notify_import_filter_rule">导入</a>
411                             &nbsp;&nbsp;&nbsp;&nbsp;
412                             <href="javascript:void(0);" hidefocus="true" id="notify_export_filter_rule">导出</a>
413                         </div>
414                     </div>
415                 </div>                    
416                     
417                 <div id="DivLog" style="display:none;">
418                     <div id="LogTabTit">
419                         <table>
420                             <tr>
421                                 <td width="127" style="padding-left:30px;">时间</td>
422                                 <td width="3"><img src="images/index/rz_table_line.gif"/></td>
423                                 <td width="399" style="padding-left:30px;">日志内容</td>
424                             </tr>
425                         </table>
426                     </div>
427                     <div id="LogTabContent">                        
428                         <table id="TabLog" style="table-layout:fixed;"></table>
429                         <table style="width:519px;table-layout:fixed;display:none;">
430                             <tr height="20" id="TrForCreateLog" >
431                                 <td width="145"></td>
432                                 <td width="100%"></td>
433                             </tr>    
434                         </table>
435                     </div>
436                     <div id="LogBtn">
437                         <table>
438                             <tr>
439                                 <td width="70"><href="javascript:void(0);" hidefocus="true" id="RefreshLog">刷新日志</a></td>
440                                 <td width="70"><href="javascript:void(0);" hidefocus="true" id="CleanLog">清空日志</a></td>
441                                 <td><href="javascript:void(0);" id="notify_view_log">查看全部日志</a></td>
442                             </tr>
443                         </table>
444                     </div>
445                 </div>
446             </div>
447             <div id="DivBottom">
448                 <table>
449                     <tr><td width="470" align="right"><target="_blank" hidefocus="true" href="http://blog.duba.net/wd">拦截测试</a></td>
450                         <td width="100" align="right"><target="_blank" hidefocus="true" href="http://labs.duba.net/dairy_wd.shtml">更新日志</a></td>
451                         <td width="120" align="center"><target="_blank" hidefocus="true" href="http://bbs.duba.net/forum-6394-1.html">网盾论坛</a></td>
452                     </tr>    
453                 </table>
454                 <!--Begin 事件触发C++-->
455                     <!--Begin 首页-->
456                         <input type="hidden" id="query_init_param"             title="查询默认先显示哪个页面"/>
457                         <input type="hidden" id="notify_sysmenu_close"           title="关闭界面"/>
458                         <input type="hidden" id="notify_sysmenu_minimize"     title="最小化界面"/>
459                         <input type="hidden" id="query_version_time"        title="查询版本信息"/>
460                         <!--input type="hidden" id="notify_call_update"         title="调用升级"/-->                    
461                         <input type="hidden" id="query_log_count"              title="查询日志数量,拦截网页木马病毒总数"/>
462                         <input type="hidden" id="notify_clean_log"             title="清空日志,清零"/>
463                         <input type="hidden" id="notify_setting_enable_kws" title="通知网盾开启与关闭,保护浏览器开启与关闭"/>
464                         <input type="hidden" id="query_setting_enable_kws"  title="查询网盾是否开启"/>
465                         <input type="hidden" id="notify_setting_enable_sep" title="搜索引擎保护开启与关闭"/>
466                         <input type="hidden" id="query_setting_enable_sep"  title="查询搜索引擎保护是否开启"/>
467                         <input type="hidden" id="query_prot_days"             title="查询保护了多少天"/>
468                         <input type="hidden" id="notify_call_ksfa"            title="调用急救箱"/>
469                         <input type="hidden" id="newsinfo"                     title="刷XXX"/>
470                         <input type="hidden" id="open_dlg"                     title="打开关于对话框"/>
471                     <!--End 首页-->
472                     <!--Begin 日志-->
473                         <!--<input type="hidden" id="notify_view_log"           title="用记事本打开(查看全部日志)">直接附在元素上-->
474                         <input type="hidden" id="query_log"                 title="查询日志详细信息"/>
475                     <!--End 日志-->
476                     <!--Begin 黑名单-->
477                         <input type="hidden" id="query_black_url"             title="查询黑名单"/>
478                         <input type="hidden" id="notify_del_balck_url"      title="删除黑名单"/>
479                         <input type="hidden" id="notify_add_black_url"      title="添加黑名单"/>
480                         <input type="hidden" id="notify_export_black_url"      title="导出黑名单"/>
481                         <input type="hidden" id="notify_import_black_url"      title="导入黑名单"/>
482                     <!--End 黑名单-->
483                     <!--Begin 设置-->
484                         <input type="hidden" id="query_bat_setting_basic"     title="查询基础设置"/>
485                         <input type="hidden" id="notify_bat_setting_basic"     title="更改基础设置"/>
486                         <input type="hidden" id="query_setting_color_dlg"    title="打开颜色选择对话框"/>
487                         <input type="hidden" id="notify_def_basic_setting"    title="基础设置恢复默认设置"/>
488                         <input type="hidden" id="query_fileopen_dialog"        title="打开文件选择器"/>
489                         <input type="hidden" id="notify_setting_add_exe"    title="添加保护EXE"/>
490                         <input type="hidden" id="notify_setting_del_exe"    title="删除保护EXE"/>
491                         <input type="hidden" id="query_protected_exe"        title="查询保护EXE"/>
492                     <!--End 设置-->
493                     <!--Begin 意见反馈-->
494                         <input type="hidden" id="notify_set_feedback_time"  title="设置意见反馈时间"/>
495                     <!--End 意见反馈-->
496                     <!--Begin IE 首页保护-->
497                         <input type="hidden" id="query_startpage"             title="查询保护的首页url"/>
498                         <input type="hidden" id="notify_set_startpage"         title="锁定IE首页"/>
499                         <input type="hidden" id="notify_add_ssp"             title="增加屏蔽首页"/>
500                         <input type="hidden" id="notify_del_ssp"             title="删除屏蔽首页"/>
501                         <input type="hidden" id="query_ssp"                 title="查询屏蔽首页列表"/>
502                         <input type="hidden" id="query_locksp"                 title="查询是否开启IE首页保护"/>
503                         <input type="hidden" id="notify_set_locksp"            title="通知是否开启IE首页保护"/>
504                         <input type="hidden" id="change_svt"                title="专版转换普通"/>
505                     <!--End IE 首页保护-->
506                     <!--Begin 网页净化-->
507                         <input type="hidden" id="query_set_filter"             title="查询是否开启净化"/>
508                         <input type="hidden" id="notify_set_filter"         title="设置是否开启净化"/>
509                         <input type="hidden" id="notify_add_filter_rule"     title="增加规则"/>
510                         <input type="hidden" id="notify_del_filter_rule"     title="删除规则"/>
511                         <input type="hidden" id="query_filter_rule"         title="查询规则列表"/>
512                         <input type="hidden" id="notify_export_filter_rule" title="导出"/>
513                         <input type="hidden" id="notify_import_filter_rule" title="导入"/>
514                     <!--End 网页净化-->
515                     
516                 <!--End 事件触发C++-->
517             </div>
518         </div>
519     </body>
520 </html>

 

 我们首先关注一下

代码
 1 <div id="DivTitle">
 2                 <div id="DivSystemBtn">
 3                     <img src="images/index/icob1_normal.gif"/>
 4                     <img src="images/index/icob2_normal.gif"/>
 5                     <img src="images/index/icob3_normal.gif"/>
 6                 </div>
 7                 <div id="DivMenuFeedBack">
 8                     <href="javascript:void(0);" hidefocus="true"><img src="images/index/fankui_normal.gif"/></a>
 9                 </div>
10             </div>

这里的DivTitle和DivSystemBtn的CSS定义如下:

#DivTitle
{
    position:relative;
    width:100%;
    height:68px;

#DivSystemBtn
{
    left:637px;
    height:30px;
    top:8px;
    width:53px;
    position:absolute;

 

DivTitle自然不必说了,望文生意即可明白它是相当于WINFORM软件标题部分的一个DIV。

 DivSystemBtn即是放“关于”、“最小化”、“关闭”按钮的一个DIV容器。

 以“最小化”为例阐述一下WEB与WINFORM的交互过程:

 <!--Begin 事件触发C++-->
                    <!--Begin 首页-->
                        <input type="hidden" id="query_init_param"             title="查询默认先显示哪个页面"/>
                        <input type="hidden" id="notify_sysmenu_close"           title="关闭界面"/>
                        <input type="hidden" id="notify_sysmenu_minimize"     title="最小化界面"/>
                        <input type="hidden" id="query_version_time"        title="查询版本信息"/>
                        <!--input type="hidden" id="notify_call_update"         title="调用升级"/-->                    
                        <input type="hidden" id="query_log_count"              title="查询日志数量,拦截网页木马病毒总数"/>
                        <input type="hidden" id="notify_clean_log"             title="清空日志,清零"/>
                        <input type="hidden" id="notify_setting_enable_kws" title="通知网盾开启与关闭,保护浏览器开启与关闭"/>
                        <input type="hidden" id="query_setting_enable_kws"  title="查询网盾是否开启"/>
                        <input type="hidden" id="notify_setting_enable_sep" title="搜索引擎保护开启与关闭"/>
                        <input type="hidden" id="query_setting_enable_sep"  title="查询搜索引擎保护是否开启"/>
                        <input type="hidden" id="query_prot_days"             title="查询保护了多少天"/>
                        <input type="hidden" id="notify_call_ksfa"            title="调用急救箱"/>
                        <input type="hidden" id="newsinfo"                     title="刷XXX"/>
                        <input type="hidden" id="open_dlg"                     title="打开关于对话框"/>
                    <!--End 首页-->
                    <!--Begin 日志-->
                        <!--<input type="hidden" id="notify_view_log"           title="用记事本打开(查看全部日志)">直接附在元素上-->
                        <input type="hidden" id="query_log"                 title="查询日志详细信息"/>
                    <!--End 日志-->
                    <!--Begin 黑名单-->
                        <input type="hidden" id="query_black_url"             title="查询黑名单"/>
                        <input type="hidden" id="notify_del_balck_url"      title="删除黑名单"/>
                        <input type="hidden" id="notify_add_black_url"      title="添加黑名单"/>
                        <input type="hidden" id="notify_export_black_url"      title="导出黑名单"/>
                        <input type="hidden" id="notify_import_black_url"      title="导入黑名单"/>
                    <!--End 黑名单-->
                    <!--Begin 设置-->
                        <input type="hidden" id="query_bat_setting_basic"     title="查询基础设置"/>
                        <input type="hidden" id="notify_bat_setting_basic"     title="更改基础设置"/>
                        <input type="hidden" id="query_setting_color_dlg"    title="打开颜色选择对话框"/>
                        <input type="hidden" id="notify_def_basic_setting"    title="基础设置恢复默认设置"/>
                        <input type="hidden" id="query_fileopen_dialog"        title="打开文件选择器"/>
                        <input type="hidden" id="notify_setting_add_exe"    title="添加保护EXE"/>
                        <input type="hidden" id="notify_setting_del_exe"    title="删除保护EXE"/>
                        <input type="hidden" id="query_protected_exe"        title="查询保护EXE"/>
                    <!--End 设置-->
                    <!--Begin 意见反馈-->
                        <input type="hidden" id="notify_set_feedback_time"  title="设置意见反馈时间"/>
                    <!--End 意见反馈-->
                    <!--Begin IE 首页保护-->
                        <input type="hidden" id="query_startpage"             title="查询保护的首页url"/>
                        <input type="hidden" id="notify_set_startpage"         title="锁定IE首页"/>
                        <input type="hidden" id="notify_add_ssp"             title="增加屏蔽首页"/>
                        <input type="hidden" id="notify_del_ssp"             title="删除屏蔽首页"/>
                        <input type="hidden" id="query_ssp"                 title="查询屏蔽首页列表"/>
                        <input type="hidden" id="query_locksp"                 title="查询是否开启IE首页保护"/>
                        <input type="hidden" id="notify_set_locksp"            title="通知是否开启IE首页保护"/>
                        <input type="hidden" id="change_svt"                title="专版转换普通"/>
                    <!--End IE 首页保护-->
                    <!--Begin 网页净化-->
                        <input type="hidden" id="query_set_filter"             title="查询是否开启净化"/>
                        <input type="hidden" id="notify_set_filter"         title="设置是否开启净化"/>
                        <input type="hidden" id="notify_add_filter_rule"     title="增加规则"/>
                        <input type="hidden" id="notify_del_filter_rule"     title="删除规则"/>
                        <input type="hidden" id="query_filter_rule"         title="查询规则列表"/>
                        <input type="hidden" id="notify_export_filter_rule" title="导出"/>
                        <input type="hidden" id="notify_import_filter_rule" title="导入"/>
                    <!--End 网页净化-->
                    
                <!--End 事件触发C++-->

 

关注其中的 <input type="hidden" id="notify_sysmenu_minimize"     title="最小化界面"/>这一句,在kwebapp.js种可以找 到
// 最小化        $.ImgMouseStyle($("#DivSystemBtn img").eq(1),3).click(function()        {            $("#notify_sysmenu_minimize").click();        });

哈哈,明白了,当点击 #DivSystemBtn里的第2个图片时,触发隐藏按钮notify_sysmenu_minimize的click事件,而notify_sysmenu_minimize的click事件在C#或者C++的程序里是可以截获的。这样就达到了web与winform 的交互目的,下面我来演示一下用C#如何实现一个窗体装载整个WEB页面并带有程序“最小化”功能。

 

1、创建一个"Windows窗体应用程序"项目,我把项目命名为KSWebShieldSVC,然后修改默认的From1.cs名称为FrmMain.cs,把“金山网盾”的webui文件夹拷贝到项目的bin/Debug目录下
2、修改窗体属性设置边框为无,并设置窗体大小为690*514(这个尺寸当然要根据您的web页的大小适当设置了)
3、往窗体中拖一个webBrowser1进来
4、 FrmMain_Load事件书写如下:
private void FrmMain_Load(object sender, EventArgs e)
        {
            string path = AppDomain.CurrentDomain.BaseDirectory + @"webui\kwebshield\main.htm";

            this.webBrowser1.Navigate(path);
        }
5、给webBrowser1添加DocumentCompleted事件:
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            HtmlDocument htmlDoc = webBrowser1.Document;
            HtmlElement btnElement = htmlDoc.All["notify_sysmenu_minimize"];
            if (btnElement != null)
            {
                btnElement.Click += new HtmlElementEventHandler(HtmlBtnClose_Click);
            }
        }

6、书写最小化按钮的单击事件:
   private void HtmlBtnClose_Click(object sender, EventArgs e)  
        {
            if(base.WindowState != FormWindowState.Minimized)
            base.WindowState = FormWindowState.Minimized;
           
        }
OK,此时运行程序,界面显示后,点击web上的最小化按钮,程序就最小化了,呵呵,真爽

下次将讲解一下如何拖动窗体,并放出DEMO,敬请期待!!!
我纳闷,为什么我写的文章无法发布到博客园首页而只能发布到候选区呢?

 

 

posted @ 2010-02-25 09:21  碧血黄沙-java、c#  阅读(2273)  评论(1编辑  收藏  举报