WBCustomizer.dll 这个
1、注册::在开始菜单中输入RegSvr32 路径(WBCustomizer.dll文件所在的绝对路径),若果注册成功,会提示
2、引用 :在工程--》引用中,选择microsoft webbrows customizer sample object
3、使用:
如下举例
Dim CustomWB As WBCustomizer Set CustomWB = New WBCustomizer With CustomWB .EnableAccelerator vbKeyN, vbKeyControl, True '表示启用ctrl+N键 .EnableAccelerator vbKeyO, vbKeyControl, fasle '禁用ctrl+O键 .EnableContextMenus = True '启用右键菜单 若赋值false 禁用右键菜单 .EnableAllAccelerators = True Set .WebBrowser = WebBrowser1 End With
新建空白窗体,然后粘帖下面代码:
1 Option Explicit 2 Public WithEvents br As VBControlExtender 3 4 Private Sub br_ObjectEvent(Info As EventInfo) 5 If Info.Name = "NewWindow2" Then 6 'Dim fm As New Form1 7 'fm.Show 8 'Info.EventParameters(0) = br.object ‘根据需要可实现在自己的新开窗口打开弹出窗口 9 Info.EventParameters(1) = True '拦截弹出窗口 10 End If 11 End Sub 12 13 Private Sub Form_Click() 14 br.object.Navigate "http://www.baidu.com/" 15 End Sub 16 17 Private Sub Form_Load() 18 On Error Resume Next 19 If Licenses.Count = 0 Then Licenses.Add "Shell.Explorer.2", "Shell.Explorer.2" 20 Set br = Me.Controls.Add("Shell.Explorer.2", "br") 21 'br.Width = 150 * Screen.TwipsPerPixelX 22 'br.Height = 50 * Screen.TwipsPerPixelY 23 br.Visible = True 24 End Sub