WEBBROWSER 技巧一(收藏)[1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 cutemouse 的 blog

转载

看到很多关于webbrowser控件禁止右键的提问,回复的方法很多,其中有提到使用微软提供的webbrowser扩展com服务器对象(wbcustomizer.dll),但是该方法在我们想使用webbrowser编辑网页(webbrowser1.document.execcommand "editmode")的时候有很多弊端,比如不能显示选中的文本等。另有些方法也就不用一一列举了。

这儿我想提到的是关于mshtml.htmldocument

引用microsoft html object library

rem #窗体代码#

dim withevents m_dom as mshtml.htmldocument
private function m_dom_oncontextmenu() as boolean
        m_dom_oncontextmenu = false
end function

 private sub webbrowser1_downloadcomplete()
      set m_dom = webbrowser1.document
 end sub

rem 好了,右键菜单没有了

 

===============================================================================

控件调用和获得收藏夹里面

基本上用 specialfolder(6 ) 就可以得到收藏夹的路径, 然后你可以用dir去循环读入每个目录,然后dir里面的file, file的名字就是你要的收藏的名字, 路径可以自己根据从上面得到的路径去得到.
如果你不用dir也可以用vb的dir控件.
private type shitemid
    cb as long
    abid as byte
end type

public type itemidlist
    mkid as shitemid
end type
public function specialfolder(byref csidl as long) as string
    'locate the favorites folder
    dim r as long
    dim spath as string
    dim idl as itemidlist
    const noerror = 0
    const max_length = 260
    r = shgetspecialfolderlocation(mdimain.hwnd, csidl, idl)
    if r = noerror then
        spath = space$(max_length)
        r = shgetpathfromidlist(byval idl.mkid.cb, byval spath)
        if r then
            specialfolder = left$(spath, instr(spath, vbnullchar) - 1)
        end if
    end if
end function
===================================================================================================
全屏

是的,webbrowser本生是一个控件, 你要它全屏,就是要它所在的窗体全屏, 可以用setwindowlong取消窗体的 title, 用call showwindow(findwindow("shell_traywnd", ""), 0) 隐藏tray,就是下边那个包含开始那一行. 用call showwindow(findwindow("shell_traywnd", ""), 9) 恢复. 够详细了吧.

然后在form1.windowstate = 2 就可以了.

==============================================================================================================
选择网页上的内容。
private sub command1_click()
'请先选中一些内容
me.webbrowser1.execwb olecmdid_copy, olecmdexecopt_dodefault
msgbox clipboard.gettext
end sub

==============================================================================================================
用ie来下载文件
private declare function dofiledownload lib "shdocvw.dll" (byval lpszfile as string) as long


private sub command1_click()
  
   dim sdownload as string
  
   sdownload = strconv(text1.text, vbunicode)
   call dofiledownload(sdownload)
  
end sub

private sub form_load()
text1.text = "http://www.chat.ru/~softdaily/fo-ag162.zip"
form1.caption = "audiograbber 1.62 full"
text2.text = "http://www6.50megs.com/audiograbber/demos/cr-ag161.zip"
end sub


================================================================================================================

我要动态加载和删除webbrowser控件应该怎么做?

private sub command1_click()
   form1.controls.add "shell.explorer.2", "newweb", form1
    with form1!newweb
        .visible = true
        .width = 10000
        .height = 10000
        .left = 0
        .top = 0
        .navigate2 "www.csdn.net"
    end with
end sub

private sub command2_click()
     controls.remove form1!newweb
end sub

form1.controls.add "shell.explorer.2", newweb(newweb.count), form1
    with form1!newweb(newweb.count)
        .visible = true
        .width = 1000
        .height = 1000
        .left = newweb(newweb.count - 1).left + newweb(newweb.count - 1).width
        .top = 0
        '.navigate2 "www.csdn.net"
    end with
为什么他说我

本文关键:WEBBROWSER
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top