WM_CONTEXTMENU,就调用系统的窗口处理函数 Exit Function End If SubClass_WndMessage = True End Function
>>步骤4----在窗体中加入如下代码: Private Const GWL_WNDPROC = (-4)
Private Sub Text1_MouseDown(Button As Integer, Shift As _ Integer, X As Single, Y As Single)
If Button = 1 Then Exit Sub OldWinProc = GetWindowLong(Text1.hWnd, GWL_WNDPROC) '''' 取得窗口函数的地址 Call SetWindowLong(Text1.hWnd, GWL_WNDPROC, AddressOf _ SubClass_WndMessage) '''' 用SubClass_WndMessage代替窗口函数处理消息 End Sub
Private Sub Text1_MouseUp(Button As Integer, Shift _ As Integer, X As Single, Y As Single) If Button = 1 Then Exit Sub Call SetWindowLong(Text1.hWnd, GWL_WNDPROC, OldWinProc) '''' 恢复窗口的默认函数 PopupMenu a '''' 弹出自定义菜单 End Sub
================================================================================================ 选择网页上的内容。
''''引用 Microsoft HTML Object Library
Dim oDoc As HTMLDocument Dim oElement As Object Dim oTxtRgn As Object Dim sSelectedText As String Set oDoc = WebBrowser1.Document''''获得文档对象 Set oElement = oDoc.getElementById("T1")''''获得ID="T1"的对象 Set oTxtRgn = oDoc.selection.createRange''''获得文档当前正选择的区域对象 sSelectedText = oTxtRgn.Text''''选择区域文本赋值
oElement.Focus''''"T1"对象获得焦点
oElement.Select''''全选对象"T1"
Debug.Print "你选择了文本:" & sSelectedText
上面这段儿还附送了其他功能,呵呵。精简一下是这样: Dim oDoc As Object Dim oTxtRgn As Object Dim sSelectedHTML As String Set oDoc = WebBrowser1.Document ''''获得文档对象 Set oTxtRgn = oDoc.selection.createRange ''''获得文档当前正选择的区域对象 sSelectedHTML = oTxtRgn.htmlText ''''选择区域文本赋值
Text1.Text=sSelectedHTML ''''文本框显示抓取得HTML源码 ......''''或者继续分析源码
================================================================================== Private Declare Function URLDownloadToFile Lib "urlmon" _ Alias "URLDownloadToFileA" _ (ByVal pCaller As Long, _ ByVal szURL As String, _ ByVal szFileName As String, _ ByVal dwReserved As Long, _ ByVal lpfnCB As Long) As Long Private Sub Command1_Click()
Dim sourceUrl As String Dim targetFile As String Dim hfile As Long sourceUrl = "http://123.com/123.asp?姓名=张&性别=女" targetFile = "c:\temp\xxx.html" hfile = URLDownloadToFile(0&, sourceUrl, targetFile, 0&, 0&) End Sub
URLDownloadToFile: 说明: Downloads bits from the Internet and saves them to a file.
适用于: VB4-32,5,6 声明: Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
操作系统支持: Requires Windows NT 4.0 or later; Requires Windows 95 or later
库文件 Urlmon 参数:
pCaller: Address of the controlling IUnknown interface of the calling Microsoft?ActiveX?component (if the caller is an ActiveX component). If the calling application is not an ActiveX component, this value can be set to NULL. Otherwise, the caller is a Component Object Model (COM) object that is contained in another component (such as an ActiveX control within the context of an HTML page). This parameter represents the outermost IUnknown of the calling component. The function attempts the download within the context of the ActiveX client framework and allows the caller''''s container to receive callbacks on the progress of the download.
szURL: Address of a string value containing the URL to be downloaded. Cannot be set to NULL.
szFileName: Address of a string value containing the name of the file to create for bits that come from the download.
dwReserved: Reserved. Must be zero.
lpfnCB: Address of the caller''''s IBindStatusCallback interface. URLDownloadToFile calls this interface''''s IBindStatusCallback::OnProgress method on a connection activity, including the arrival of data. IBindStatusCallback::OnDataAvailable is never called. Implementing IBindStatusCallback::OnProgress allows a caller to implement a user interface or other progress monitoring functionality. It also allows the download operation to be canceled by returning E_ABORT from the IBindStatusCallback::OnProgress call. This can be set to NULL.
返回值: Returns one of the following values: E_OUTOFMEMORY The buffer length is invalid or there was insufficient memory to complete the operation. S_OK The operation succeeded.
具体的解释我就不翻译了 ================================================================================================
Option Explicit Enum OLECMDID OLECMDID_OPEN = 1 OLECMDID_NEW = 2 OLECMDID_SAVE = 3 OLECMDID_SAVEAS = 4 OLECMDID_SAVECOPYAS = 5 OLECMDID_PRINT = 6 OLECMDID_PRINTPREVIEW = 7 OLECMDID_PAGESETUP = 8 OLECMDID_SPELL = 9 OLECMDID_PROPERTIES = 10 OLECMDID_CUT = 11 OLECMDID_COPY = 12 OLECMDID_PASTE = 13 OLECMDID_PASTESPECIAL = 14 OLECMDID_UNDO = 15 OLECMDID_REDO = 16 OLECMDID_SELECTALL = 17 OLECMDID_CLEARSELECTION = 18 OLECMDID_ZOOM = 19 OLECMDID_GETZOOMRANGE = 20 OLECMDID_UPDATECOMMANDS = 21 OLECMDID_REFRESH = 22 OLECMDID_STOP = 23 OLECMDID_HIDETOOLBARS = 24 OLECMDID_SETPROGRESSMAX = 25 OLECMDID_SETPROGRESSPOS = 26 OLECMDID_SETPROGRESSTEXT = 27 OLECMDID_SETTITLE = 28 OLECMDID_SETDOWNLOADSTATE = 29 OLECMDID_STOPDOWNLOAD = 30 OLECMDID_ONTOOLBARACTIVATED = 31 OLECMDID_FIND = 32 OLECMDID_DELETE = 33 OLECMDID_HTTPEQUIV = 34 OLECMDID_HTTPEQUIV_DONE = 35 OLECMDID_ENABLE_INTERACTIO 上一页 [1] [2] [3] [4] 下一页 [C语言系列]怎么使用webbrowser获取页面中的button元素。并触… [C语言系列]C#实现 WebBrowser中新窗口打开链接用默认或者指定… [C语言系列]c#WebBrowser查找并选择文本 [C语言系列]利用Webbrowser修改里的html代码里全部的"link"替… [C语言系列]C#清除IE缓存临时文件实现WebBrowser强制刷新 [C语言系列]一个参数解决应用程序中WebBrowser的缓存问题 [C语言系列]自动关闭webBrowser弹出的所有窗口 [C语言系列]WebBrowser在同一个窗口打开网页,禁止在新窗口打… [Web开发]c# tabcontrol webbrowser 新标签页打开超链接 [C语言系列]C# webBrowser强制在本窗口打开,禁止在新窗口打开
|