惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Project Zero
Project Zero
月光博客
月光博客
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
O
OpenAI News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Know Your Adversary
Know Your Adversary
Last Week in AI
Last Week in AI
S
Securelist
Engineering at Meta
Engineering at Meta
博客园 - 司徒正美
P
Privacy & Cybersecurity Law Blog
T
Tailwind CSS Blog
F
Fortinet All Blogs
博客园 - 三生石上(FineUI控件)
Scott Helme
Scott Helme
MyScale Blog
MyScale Blog
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
C
Cisco Blogs
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
小众软件
小众软件
U
Unit 42
Microsoft Azure Blog
Microsoft Azure Blog
Hacker News: Ask HN
Hacker News: Ask HN
Hugging Face - Blog
Hugging Face - Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
SecWiki News
SecWiki News
宝玉的分享
宝玉的分享
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
Lohrmann on Cybersecurity
IT之家
IT之家
Security Archives - TechRepublic
Security Archives - TechRepublic
I
InfoQ
S
Security @ Cisco Blogs
Webroot Blog
Webroot Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
F
Full Disclosure
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The GitHub Blog
The GitHub Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Jina AI
Jina AI
Cyberwarzone
Cyberwarzone
人人都是产品经理
人人都是产品经理
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
B
Blog RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - 学剑学诗两不成

VB:如何实现在代码中弹出toolbar的ButtonMenu VB:如何发送WM_KEYDOWN和WM_KEYUP消息 VB:如何改变ComboBox自身的高度 VB:如何设置Richtextbox的行间距 VB:如何允许/禁止RICHTEXTBOX中的OLE对象拉伸 一个很有用的自定义函数 - 学剑学诗两不成 - 博客园 VB:如何隐藏/显示treeview的ToolTips - 学剑学诗两不成 - 博客园 VB:如何启用/禁用本地连接 VB:如何选定文件或文件夹 - 学剑学诗两不成 - 博客园 一个远程调用api函数的模块(转贴) VB:如何用需要身份验证的SMTP邮件服务器发信 - 学剑学诗两不成 - 博客园 VB:如何监听打开的窗口和程序 VB:如何隐藏ListView的某一列 vb:如何禁止鼠标指针进入某个区域 如何使frame控件的caption居中显示 - 学剑学诗两不成 - 博客园 怎样去掉窗体上的图标 - 学剑学诗两不成 - 博客园 VB中对string array快速插入、删除某个元素的办法 - 学剑学诗两不成 - 博客园 bug:在windows xp下用ImageList_GetImageCount返回值不正确(VB) - 学剑学诗两不成 - 博客园 VB中字符串数组快速复制的一种方法 - 学剑学诗两不成 - 博客园
利用IDocHostUIHandler接口屏蔽WebBrowser的弹出菜单
学剑学诗两不成 · 2006-02-27 · via 博客园 - 学剑学诗两不成

       简单说两句:大致就是实现IDocHostUIHandler接口,挂接IDocHostUIHandler接口可以利用ICustomDoc接口或IOleObject接口实现,这里演示了利用ICustomDoc接口进行挂接。由于只是想屏蔽webbroswer的弹出菜单,所以只在IDocHostUIHandler的ShowContextMenu方法上做点文章就够了,IDocHostUIHandler的其它的方法不必进行处理,但是你必须实现它们,哪怕你只写上一些注释,好了,下面看代码:
'窗体上一个按钮,一个tetbox,一个checkbox,一个WebBrowser
'这里我依旧引用Edanmo's OLE interfaces & functions v1.81(对应文件olelib.tlb)
Option Explicit
Implements IDocHostUIHandler
Dim mshow As Boolean
Dim mICustomDoc As ICustomDoc

Private Sub Check1_Click()
    mshow = Check1.Value
End Sub

Private Sub Command1_Click()
    Me.WebBrowser1.Navigate Text1.Text
End Sub

Private Sub Form_Load()
    Me.WebBrowser1.Navigate "about:blank"
End Sub

Private Sub IDocHostUIHandler_EnableModeless(ByVal fEnable As olelib.BOOL)
    IDocHostUIHandler.EnableModeless fEnable
End Sub

Private Function IDocHostUIHandler_FilterDataObject(ByVal pDO As olelib.IDataObject) As olelib.IDataObject
    Set IDocHostUIHandler_FilterDataObject = IDocHostUIHandler.FilterDataObject(pDO)
End Function

Private Function IDocHostUIHandler_GetDropTarget(ByVal pDropTarget As olelib.IDropTarget) As olelib.IDropTarget
    Set IDocHostUIHandler_GetDropTarget = IDocHostUIHandler.GetDropTarget(pDropTarget)
End Function

Private Function IDocHostUIHandler_GetExternal() As Object
    Set IDocHostUIHandler_GetExternal = IDocHostUIHandler.GetExternal
End Function

Private Sub IDocHostUIHandler_GetHostInfo(pInfo As olelib.DOCHOSTUIINFO)
     IDocHostUIHandler.GetHostInfo pInfo
End Sub

Private Sub IDocHostUIHandler_GetOptionKeyPath(pOLESTRchKey As Long, ByVal dw As Long)
    IDocHostUIHandler.GetOptionKeyPath pOLESTRchKey, dw
End Sub

Private Sub IDocHostUIHandler_HideUI()
    IDocHostUIHandler.HideUI
End Sub

Private Sub IDocHostUIHandler_OnDocWindowActivate(ByVal fActivate As olelib.BOOL)
     IDocHostUIHandler.OnDocWindowActivate fActivate
End Sub

Private Sub IDocHostUIHandler_OnFrameWindowActivate(ByVal fActivate As olelib.BOOL)
    IDocHostUIHandler.OnFrameWindowActivate fActivate
End Sub

Private Sub IDocHostUIHandler_ResizeBorder(prcBorder As olelib.RECT, ByVal pUIWindow As olelib.IOleInPlaceUIWindow, ByVal fRameWindow As olelib.BOOL)
    IDocHostUIHandler.ResizeBorder prcBorder, pUIWindow, fRameWindow
End Sub

Private Sub IDocHostUIHandler_ShowContextMenu(ByVal dwContext As olelib.ContextMenuTarget, pPOINT As olelib.POINT, ByVal pCommandTarget As olelib.IOleCommandTarget, ByVal HTMLTagElement As Object)
    If mshow = True Then
        IDocHostUIHandler.ShowContextMenu dwContext, pPOINT, pCommandTarget, HTMLTagElement
    End If
End Sub

Private Sub IDocHostUIHandler_ShowUI(ByVal dwID As Long, ByVal pActiveObject As olelib.IOleInPlaceActiveObject, ByVal pCommandTarget As olelib.IOleCommandTarget, ByVal pFrame As olelib.IOleInPlaceFrame, ByVal pDoc As olelib.IOleInPlaceUIWindow)
    IDocHostUIHandler.ShowUI dwID, pActiveObject, pCommandTarget, pFrame, pDoc
End Sub

Private Sub IDocHostUIHandler_TranslateAccelerator(lpmsg As olelib.MSG, pguidCmdGroup As olelib.UUID, ByVal nCmdID As Long)
    IDocHostUIHandler.TranslateAccelerator lpmsg, pguidCmdGroup, nCmdID
End Sub

Private Function IDocHostUIHandler_TranslateUrl(ByVal dwTranslate As Long, ByVal pchURLIn As Long) As Long
    IDocHostUIHandler_TranslateUrl = IDocHostUIHandler.TranslateUrl(dwTranslate, pchURLIn)
End Function

Private Sub IDocHostUIHandler_UpdateUI()
    IDocHostUIHandler.UpdateUI
End Sub

Private Sub WebBrowser1_DownloadComplete()
    Set mICustomDoc = Me.WebBrowser1.Document
    mICustomDoc.SetUIHandler Me
End Sub

        最后,需要说明的是,这个程序可能有一些问题,以至于在vb的IDE中它不能很好的工作(至于是什么原因,现在没时间研究了,以后再说吧,有知道的,欢迎你告诉我),不过,编译成exe文件后,它还是可以实现我们的目的的。