VB IE控制

原创 2007年10月03日 11:07:00

VERSION 5.00
Begin VB.UserControl uctlIe
   ClientHeight    =   450
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   510
   ScaleHeight     =   450
   ScaleWidth      =   510
End
Attribute VB_Name = "uctlIe"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
Private WithEvents IEWindow As SHDocVw.WebBrowser
Attribute IEWindow.VB_VarHelpID = -1
Event BeforeNavigate2(ByVal pDisp As Object, ByVal URL As String, ByVal Flags As Long, ByVal TargetFrameName As String, PostData As Variant, ByVal Headers As String, Cancel As Boolean)
Event NewWindow2(ByVal pDisp As Object, ByVal Cancel As Boolean)
Event NavigateError(ByVal pDisp As Object, URL As Variant, Frame As Variant, StatusCode As Variant, Cancel As Boolean)
Event NavigateComplete2(ByVal pDisp As Object, ByVal URL As String)
Event ClientToHostWindow(CX As Long, CY As Long)
Event CommandStateChange(ByVal Command As Long, ByVal Enable As Boolean)
Event DocumentComplete(ByVal pDisp As Object, URL)
Event DownloadBegin()
Event DownloadComplete()
Event FileDownload(Cancel As Boolean)
Event OnFullScreen(ByVal FullScreen As Boolean)
Event OnMenuBar(ByVal MenuBar As Boolean)
Event OnQuit()
Event OnStatusBar(ByVal StatusBar As Boolean)
Event OnTheaterMode(ByVal TheaterMode As Boolean)
Event OnToolBar(ByVal ToolBar As Boolean)
Event OnVisible(ByVal Visible As Boolean)
Event PrintTemplateInstantiation(ByVal pDisp As Object)
Event PrintTemplateTeardown(ByVal pDisp As Object)
Event PrivacyImpactedStateChange(ByVal bImpacted As Boolean)
Event ProgressChange(ByVal Progress As Long, ByVal ProgressMax As Long)
Event PropertyChange(ByVal szProperty As String)
Event SetSecureLockIcon(ByVal SecureLockIcon As Long)
Event StatusTextChange(ByVal Text As String)
Event TitleChange(ByVal Text As String)
Event UpdatePageStatus(ByVal pDisp As Object, nPage, fDone)
Event WindowClosing(ByVal IsChildWindow As Boolean, Cancel As Boolean)
Event WindowSetHeight(ByVal Height As Long)
Event WindowSetLeft(ByVal Left As Long)
Event WindowSetResizable(ByVal Resizable As Boolean)
Event WindowSetTop(ByVal Top As Long)
Event WindowSetWidth(ByVal Width As Long)

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_SETTEXT = &HC


Private Sub Class_Initialize()
    Set IEWindow = New SHDocVw.WebBrowser
End Sub

'请求连接前触发的事件
Private Sub IEWindow_BeforeNavigate2(ByVal pDisp As Object, URL, Flags, TargetFrameName, PostData, Headers, Cancel As Boolean)
    RaiseEvent BeforeNavigate2(pDisp, URL, Flags, TargetFrameName, PostData, Headers, Cancel)
End Sub

'当需要创建新窗口时触发的事件
Private Sub IEWindow_NewWindow2(pDisp As Object, Cancel As Boolean)
    RaiseEvent NewWindow2(pDisp, Cancel)
End Sub

'当访问出错触发的事件
Private Sub IEWindow_NavigateError(ByVal pDisp As Object, URL As Variant, Frame As Variant, StatusCode As Variant, Cancel As Boolean)
    RaiseEvent NavigateError(pDisp, URL, Frame, StatusCode, Cancel)
End Sub

'当访问完成触发的事件
Private Sub IEWindow_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
    RaiseEvent NavigateComplete2(pDisp, URL)
End Sub

Public Property Get IEObject() As SHDocVw.WebBrowser
    Set IEObject = IEWindow
End Property

Public Property Let IEObject(ByVal vNewValue As SHDocVw.WebBrowser)
    Set IEWindow = vNewValue
End Property

Private Sub IEWindow_ClientToHostWindow(CX As Long, CY As Long)
    RaiseEvent ClientToHostWindow(CX, CY)
End Sub

Private Sub IEWindow_CommandStateChange(ByVal Command As Long, ByVal Enable As Boolean)
    RaiseEvent CommandStateChange(Command, Enable)
End Sub

Private Sub IEWindow_DocumentComplete(ByVal pDisp As Object, URL)
    RaiseEvent DocumentComplete(pDisp, URL)
End Sub

Private Sub IEWindow_DownloadBegin()
    RaiseEvent DownloadBegin
End Sub

Private Sub IEWindow_DownloadComplete()
    RaiseEvent DownloadComplete
End Sub

Private Sub IEWindow_FileDownload(Cancel As Boolean)
    RaiseEvent FileDownload(Cancel)
End Sub

Private Sub IEWindow_OnFullScreen(ByVal FullScreen As Boolean)
    RaiseEvent OnFullScreen(FullScreen)
End Sub

Private Sub IEWindow_OnMenuBar(ByVal MenuBar As Boolean)
    RaiseEvent OnMenuBar(MenuBar)
End Sub

Private Sub IEWindow_OnQuit()
    RaiseEvent OnQuit
End Sub

Private Sub IEWindow_OnStatusBar(ByVal StatusBar As Boolean)
    RaiseEvent OnStatusBar(StatusBar)
End Sub

Private Sub IEWindow_OnTheaterMode(ByVal TheaterMode As Boolean)
    RaiseEvent OnTheaterMode(TheaterMode)
End Sub

Private Sub IEWindow_OnToolBar(ByVal ToolBar As Boolean)
    RaiseEvent OnToolBar(ToolBar)
End Sub

Private Sub IEWindow_OnVisible(ByVal Visible As Boolean)
    RaiseEvent OnVisible(Visible)
End Sub

Private Sub IEWindow_PrintTemplateInstantiation(ByVal pDisp As Object)
    RaiseEvent PrintTemplateInstantiation(pDisp)
End Sub

Private Sub IEWindow_PrintTemplateTeardown(ByVal pDisp As Object)
    RaiseEvent PrintTemplateTeardown(pDisp)
End Sub

Private Sub IEWindow_PrivacyImpactedStateChange(ByVal bImpacted As Boolean)
    RaiseEvent PrivacyImpactedStateChange(bImpacted)
End Sub

Private Sub IEWindow_ProgressChange(ByVal Progress As Long, ByVal ProgressMax As Long)
    RaiseEvent ProgressChange(Progress, ProgressMax)
End Sub

Private Sub IEWindow_PropertyChange(ByVal szProperty As String)
    RaiseEvent PropertyChange(szProperty)
End Sub

Private Sub IEWindow_SetSecureLockIcon(ByVal SecureLockIcon As Long)
    RaiseEvent SetSecureLockIcon(SecureLockIcon)
End Sub

Private Sub IEWindow_StatusTextChange(ByVal Text As String)
    RaiseEvent StatusTextChange(Text)
End Sub

Private Sub IEWindow_TitleChange(ByVal Text As String)
    RaiseEvent TitleChange(Text)
End Sub

Private Sub IEWindow_UpdatePageStatus(ByVal pDisp As Object, nPage, fDone)
    RaiseEvent UpdatePageStatus(pDisp, nPage, fDone)
End Sub

Private Sub IEWindow_WindowClosing(ByVal IsChildWindow As Boolean, Cancel As Boolean)
    RaiseEvent WindowClosing(IsChildWindow, Cancel)
End Sub

Private Sub IEWindow_WindowSetHeight(ByVal Height As Long)
    RaiseEvent WindowSetHeight(Height)
End Sub

Private Sub IEWindow_WindowSetLeft(ByVal Left As Long)
    RaiseEvent WindowSetLeft(Left)
End Sub

Private Sub IEWindow_WindowSetResizable(ByVal Resizable As Boolean)
    RaiseEvent WindowSetResizable(Resizable)
End Sub

Private Sub IEWindow_WindowSetTop(ByVal Top As Long)
    RaiseEvent WindowSetTop(Top)
End Sub

Private Sub IEWindow_WindowSetWidth(ByVal Width As Long)
    RaiseEvent WindowSetWidth(Width)
End Sub

Private Sub Class_Terminate()
    Set IEWindow = Nothing
End Sub

Public Sub Navigate(ByVal URL As String, ByVal Flags As Long, ByVal TargetFrameName As String, PostData As Variant, ByVal Headers As String)
    IEWindow.Navigate URL, Flags, TargetFrameName, PostData, Headers
End Sub

Public Sub Navigate2(ByVal URL As String, ByVal Flags As Long, ByVal TargetFrameName As String, PostData As Variant, ByVal Headers As String)
    IEWindow.Navigate2 URL, Flags, TargetFrameName, PostData, Headers
End Sub

Public Sub SetIEWindowText(IEWindow As SHDocVw.WebBrowser, ByVal strText As String)
    SendMessage IEWindow.hwnd, WM_SETTEXT, 0, ByVal strText
End Sub

 

VB与IE浏览器交互——自动填表

VB填充IE上的输入框并提交       假设登录页面的HTML代码如下:                           testPage                      ...

vb操作ie浏览器

相信现在绝大多数计算机上使用的是IE浏览器。如何通过编程控制IE的操作呢,本文将一步步介绍如何通过VB   调用IE的对象库来对IE进行控制。   本文使用的编程工具是VB6英文企业版,浏览器是IE5...
  • sysdzw
  • sysdzw
  • 2009年09月11日 00:07
  • 4158

【开源项目】花密(Flower Password)VB版之IE浏览器模块

'***************************************************************** ' Copyright (c) 2011-2012 FlowerP...
  • xlsdg
  • xlsdg
  • 2012年04月11日 09:59
  • 471

VB修改IE UserAgent方法,怎么修改浏览器UserAgent

常用浏览器修改User-Agent的方法 IE浏览器修改User-agent,修改注册表 User-Agent在注册表的位置 [HKEY_LOCAL_MACHINE\SOFT...
  • qzmrock
  • qzmrock
  • 2013年02月24日 22:30
  • 2889

*继承IObjectSafety接口,实现vb activeX控件安全性(IE不提示安全问题)

原文http://support.microsoft.com/kb/182598/zh-cn 从 Visual Basic 6.0 CD-ROM(安装目录) 中获取 OLE 自动化类型库生成器。若要...
  • icbyboy
  • icbyboy
  • 2013年04月16日 08:32
  • 819

vb-复制ie临时文件夹下所有mp3文件到指定目录,并且将utf8编码转换过来

Option Explicit '引用Microsoft Scripting RunTime Dim m_objFSO As New FileSystemObject '定义文件系统对象 P...
  • sysdzw
  • sysdzw
  • 2011年04月27日 18:35
  • 1797

VB完全控制IE浏览器,操作ie对象,响应ie事件

IE浏览器完全控制   ,相信现在绝大多数计算机上使用的是IE浏览器。如何通过编程控制IE的操作呢,本文将一步步介绍如何通过VB  调用IE的对象库来对IE进行控制。   本文使用的编程工具是VB6...

基于VB.NET的IE7(模仿)浏览器

  • 2014年02月22日 16:46
  • 2.71MB
  • 下载

VB写的很好的IE浏览器源码

  • 2002年12月30日 00:00
  • 104KB
  • 下载

vb中两种重要的控制语句

今天我又给大家来分享我的学习收获了!闲话少叙,直接上菜!   条件判断语句        vb中有两种比较重要的条件判断语句!分别是If...Then与Select Case两种条件判断语句。  If...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:VB IE控制
举报原因:
原因补充:

(最多只允许输入30个字)