VB6之WebBrowser控件
UI短手或者GDI+用烦的童鞋可以借用WebBrowser打造漂亮的程序界面,只需要下载一个好看点的html代码就够了。
引用:
Microsoft Html Object Library
部件:
Microsoft Internet Controls
这里以一个简单的登陆界面作为示例,实现代码:
Private WithEvents HtmlDocument As MSHTML.HtmlDocument
Private WithEvents HtmlElement As MSHTML.HTMLButtonElement 'code by lichmama from cnblogs.com
Private Sub Form_Load()
With WebBrowser1
.Left =
.Top =
.Navigate "file://C:\Users\Administrator\Desktop\test.html"
End With
End Sub Private Sub Form_Resize()
With WebBrowser1
.Width = Me.Width
.Height = Me.Height
End With
End Sub Private Sub Form_Unload(Cancel As Integer)
Set HtmlElement = Nothing
Set HtmlDocument = Nothing
End Sub Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
With WebBrowser1
'get the HtmlDocument from webbrowser,
' and bind the control of button to [HtmlElement],
' and setup the event handler of [mybutton]'s onclick.
Set HtmlDocument = .Document
Set HtmlElement = HtmlDocument.getElementById("submit")
End With
End Sub Private Function HtmlDocument_oncontextmenu() As Boolean
'屏蔽右键菜单
HtmlDocument_oncontextmenu = False
End Function Private Function HtmlElement_OnClick() As Boolean
'in this section, we can do any operations to current page.
' think about it, if this is a submit button, we could verify the password, whatever.
username = HtmlDocument.getElementById("login_username").Value
password = HtmlDocument.getElementById("login_password").Value
Debug.Print "your username:", username
Debug.Print "your password:", password
HtmlElement_OnClick = False
End Function
test.html(@http://www.jb51.net/css/97304.html):
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>纯CSS3制作的 登录模板 简洁蓝白(非IE效果更好)</title>
<meta content="text/html; charset=unicode" http-equiv="Content-Type" />
<style>
h1, h2, h3, h4, h5, h6{
font-weight:normal;
margin:;
line-height:.1em;
color:#;
}
h1{font-size:2em;margin-bottom:.5em;}
h2{font-size:.75em;margin-bottom:.5142em;padding-top:.2em;}
h3{font-size:.5em;margin-bottom:.7em;padding-top:.3em;}
h4{font-size:.25em;margin-bottom:.6em;}
h5,h6{font-size:1em;margin-bottom:.5em;font-weight:bold;}
p, blockquote, ul, ol, dl, form, table, pre{line-height:inherit;margin: .5em ;}
ul, ol, dl{padding:;}
ul ul, ul ol, ol ol, ol ul, dd{margin:;}
li{margin: 2em;padding:;display:list-item;list-style-position:outside;}
blockquote, dd{padding: 2em;}
pre, code, samp, kbd, var{font:% mono-space,monospace;}
pre{overflow:auto;}
abbr, acronym{
text-transform:uppercase;
border-bottom:1px dotted #;
letter-spacing:1px;
}
abbr[title], acronym[title]{cursor:help;}
small{font-size:.9em;}
sup, sub{font-size:.8em;}
em, cite, q{font-style:italic;}
img{border:none;}
hr{display:none;}
table{width:%;border-collapse:collapse;}
th,caption{text-align:left;}
form div{margin:.5em ;clear:both;}
label{display:block;}
fieldset{margin:;padding:;border:none;}
legend{font-weight:bold;}
input[type="radio"],input[type="checkbox"], .radio, .checkbox{margin: .25em ;}
/* base */
body, table, input, textarea, select, li, button{
font:1em "Lucida Sans Unicode", "Lucida Grande", sans-serif;
line-height:.5em;
color:#;
}
body{
font-size:12px;
background:#c4f0f1;
text-align:center;
}
/* login form */
#login{
margin:5em auto;
background:#fff;
border:8px solid #eee;
width:500px;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
-moz-box-shadow: 10px #4e707c;
-webkit-box-shadow: 10px #4e707c;
box-shadow: 10px #4e707c;
text-align:left;
position:relative;
}
#login a, #login a:visited{color:#0283b2;}
#login a:hover{color:#;}
#login h1{
background:#0092c8;
color:#fff;
text-shadow:#007dab 1px ;
font-size:14px;
padding:18px 23px;
margin: .5em ;
border-bottom:1px solid #007dab;
}
#login .register{
position:absolute;
float:left;
margin:;
line-height:30px;
top:-40px;
right:;
font-size:11px;
}
#login p{margin:.5em 25px;}
#login div{
margin:.5em 25px;
background:#eee;
padding:4px;
-moz-border-radius:3px;
-webkit-border-radius:3px;
border-radius:3px;
text-align:right;
position:relative;
}
#login label{
float:left;
line-height:30px;
padding-left:10px;
}
#login .field{
border:1px solid #ccc;
width:280px;
font-size:12px;
line-height:1em;
padding:4px;
-moz-box-shadow:inset 5px #ccc;
-webkit-box-shadow:inset 5px #ccc;
box-shadow:inset 5px #ccc;
}
#login div.submit{background:none;margin:1em 25px;text-align:left;}
#login div.submit label{float:none;display:inline;font-size:11px;}
#login button{
border:;
padding: 30px;
height:30px;
line-height:30px;
text-align:center;
font-size:14px;
Font-Weight:bold;
color:#fff;
text-shadow:#007dab 1px ;
background:#0092c8;
-moz-border-radius:50px;
-webkit-border-radius:50px;
border-radius:50px;
cursor:pointer;
}
#login .forgot{text-align:right;font-size:11px;}
#login .back{padding:1em ;border-top:1px solid #eee;text-align:right;font-size:20px;}
#login .error{
float:left;
position:absolute;
left:%;
top:-5px;
background:#;
padding:5px 10px;
font-size:11px;
color:#fff;
text-shadow:# 1px ;
text-align:left;
white-space:nowrap;
border:1px solid #;
-moz-border-radius:3px;
-webkit-border-radius:3px;
border-radius:3px;
-moz-box-shadow: 5px #;
-webkit-box-shadow: 5px #;
box-shadow: 5px #;
}
</style>
<style id="wiz_custom_css" type="text/css">
body
{
font-family: 微软雅黑,Georgia,Helvetica,Arial,sans-serif,宋体,serif;
font-size: .5pt;
line-height: 1.5;
border:0px;
overflow:hidden;
}
html, body, div, span, applet, object, iframe, p, blockquote, pre,
abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td
{
color: inherit;
background-color: inherit;
}
h1 {
font-size:.5em;
font-weight:bold;
}
h2 {
font-size:.4em;
font-weight:bold;
}
h3 {
font-size:.3em;
font-weight:bold;
}
h4 {
font-size:.2em;
font-weight:bold;
}
h5 {
font-size:.1em;
font-weight:bold;
}
h6 {
font-size:.0em;
font-weight:bold;
}
img {
border:;
}
</style>
<meta name="GENERATOR" content="MSHTML 9.00.8112.16421" />
</head>
<body scroll="no">
<form id="login" method="post" action="">
<h1><strong>用户登录</strong></h1>
<div>
<label for="login_username"><strong>账户:</strong></label>
<input id="login_username" class="field required" title="请输入您的账户" name="username" />
</div>
<div>
<label for="login_password"><strong>密码:</strong></label>
<input id="login_password" class="field required" title="密码不能为空" name="password" type="password" />
</div>
<div class="submit">
<button type="submit" id="submit">登录</button>
</div>
</form>
</body>
</html>
然后,让我们来看看效果:

貌似还不错的样子
VB6之WebBrowser控件的更多相关文章
- vb6中webbrowser控件树转换备忘
Dim doc As HTMLDocument Set doc = WebBrowser1.Document Dim inputs As IHTMLElementCollection Set inpu ...
- C#中的WebBrowser控件的使用
0.常用方法 Navigate(string urlString):浏览urlString表示的网址 Navigate(System.Uri url):浏览url表示的网址 Navigate(st ...
- delphi WebBrowser控件上网页验证码图片识别教程(一)
步骤一:获取网页中验证码图片的url地址 在delphi中加入一个BitBtn和一个memo以及WebBrowser控件实现网页中验证码图片的url地址的获取 程序如下:procedure TForm ...
- <总结>delphi WebBrowser控件的使用中出现的bug
Delphi WebBrowser控件的使用中出现的bug: 1.WebBrowser.Visible=false:Visible属性不能使WebBrowser控件不可见,暂时用 WebBrowse ...
- C# WebBrowser控件使用教程与技巧收集
常用的方法 Navigate(string urlString):浏览urlString表示的网址 Navigate(System.Uri url):浏览url表示的网址 Navigate(strin ...
- C# 指定Webbrowser控件所用IE内核版本
如果电脑上安装了IE8或者之后版本的IE浏览器,Webbrowser控件会使用IE7兼容模式来显示网页内容.解决方法是在注册表中为你的进程指定引用IE的版本号. 比如我的程序叫做a.exe,以64位机 ...
- 在WPF的WebBrowser控件中屏蔽脚本错误的提示
在WPF中使用WebBrowser控件显示网页时,经常会报脚本错误的提示,如何屏蔽掉这些错误提示呢.方法是定义如下方法: public void SuppressScriptErrors(WebBro ...
- 修改WebBrowser控件的内核解决方案
方法一 加入你想让WebBrowser控件的渲染模式编程IE8的标准模式, 你可以通过设置注册表FEATURE_BROWSER_EMULATION 来实现. 示例: 注册表中注明当前本机装的IE版本H ...
- C# webBrowser控件使用
C# webBrowser控件使用心得 最近用到WebBrowser控件,遇到很多问题,也学习了不少新的东西.下面是我在C#下写的关于WebBrowser控件使用的代码. 1.WebBrowser常用 ...
随机推荐
- linux开发常用命令
最近经常查看服务器上的log文件,有时log文件太大查起来很不方便,看了看网上说可以部分查询,就先记录一下吧 Linux中查看部分文件内容命令head,tail,sed的用法: Linux中的查看文件 ...
- struts2.1.6教程一、准备工作及实例
1.解压struts-2.1.6-all.zip apps目录:struts2自带的例子程序 docs目录:官方文档. lib 目录:存放所有jar文件. Src 目录:源文%件存放地 2.六个基本包 ...
- iOS下KVO使用过程中的陷阱 (转发)
iOS下KVO使用过程中的陷阱 KVO,全称为Key-Value Observing,是iOS中的一种设计模式,用于检测对象的某些属性的实时变化情况并作出响应.网上广为流传普及的一个例子是利用KV ...
- 分布式版本控制git常见问题之gitignore冲突(精简版)
上次写的的太模糊了,现在简单直接写出个人心得,如下: 原因是有人提交了.gitignore里面的内容,所以和本地的不一样,这样就有问题,那么pull都不可以,所以要这样: git update-ind ...
- R实现地理位置与经纬度相互转换
本实例要实现目标通过输入城市名或者地名,然后找出其经度纬度值,以及通过可视化展现其线路流向以及周边地图展示 address_list数据: 山西省太原市小店区亲贤北街77号 贵州省贵阳市云岩区书香门第 ...
- mysqldump命令详解
1.数据备份的重要性: 保护公司的数据 网站的7x24提供服务 2.MySQL数据库备份: --all-databases , -A 导出全部数据库. mysqldump -uroot -p --al ...
- Spring自动化装配bean
1. 场景 用CD(Compact disc)和CD播放器(CDPlayer)阐述DI(依赖注入). 如果不将CD插入(注入)到CDPlayer中,那么CDPlayer其实没有太大的用处,所以,可以这 ...
- SQL数据库的多表查询
多表查询分为 内.外连接 外连接分为左连接(left join 或left outer join).右连接(right join 或者 right outer join).和完整外部连接 (full ...
- Spring学习(22)--- AOP之Advice应用(下)
(六)Advice parameters(advice带参数的情况) 例子: 修改MyAspect(添加around_init方法): package com.aop.schema; import o ...
- 【论文:麦克风阵列增强】Signal Enhancement Using Beamforming and Nonstationarity with Applications to Speech
作者:桂. 时间:2017-06-06 13:25:58 链接:http://www.cnblogs.com/xingshansi/p/6943833.html 论文原文:http://pan.bai ...