易截截图软件、单文件、免安装、纯绿色、仅160KB

vb程序中webbrowser 接受SendMessage 的消息

webbrowser 不能收到SendMessage的消息
主要是因为1webbrowser 的句柄找不到。经过努力搜索,终于解决了。做个记录.
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) 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 Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
Const MK_LBUTTON = &H1
'获得webbrowser的句柄
Public Function GetBrowserWindow(窗体句柄 As Long) As Long
    Dim hwndPeer As Long
    hwndPeer = FindWindowEx(窗体句柄, 0, "Shell Embedding", vbNullString)'网上很多帮助就找到这里就结束了,那是不能收到消息的。
    hwndPeer = FindWindowEx(hwndPeer, 0, "Shell DocObject View", vbNullString)
    hwndPeer = FindWindowEx(hwndPeer, 0, "Internet Explorer_Server", vbNullString)
    GetBrowserWindow = hwndPeer
End Function
'按钮单击
Private Sub 命令_Click()
    Dim t As String, x As Long, y As Long, w As WebBrowser, wbhwnd As Long, k As Long
    x = 537'从WebBrowser控件左上角起0,0,坐标不是平时left、right、top、height那个坐标,可以直接复制控件到画图里面,看分辨录。
    y = 44 * &H10000'弄成高位
    wbhwnd = GetBrowserWindow(Form1.hwnd)
    k = PostMessage(wbhwnd, WM_LBUTTONDOWN, MK_LBUTTON, ByVal ((y) + x))
    k = PostMessage(wbhwnd, WM_LBUTTONUP, 0, (x + (y)))
End Sub
'测试通过。


相关文档:

VB操作WORD

 Dim wdapp As Word.Application
    Dim wddoc As Word.Document
    Dim wdtable As Word.Table
   
    Set wdapp = CreateObject("word.application")
   
    Set wddoc = wdapp.Documents.Add
   ......

VB六个数取最大值和最小数

mxl=1                          && 最大的文本框编号
mnl=1                  &n ......

VB 简单计算器

Option Explicit
Dim potflag As Integer      '标识是否用小数点
Dim numcol As Integer       ' 点击运算符的个数
Dim LastInput               ' 指示上一次操作的内容
Dim colflag ......

VB怎样判断、防止程序重复执行

Private Sub Form_load()
    '判断程序是否已经运行
    If App.PrevInstance
Then
     MsgBox "本程序已经运行!", vbInformation Or vbOKOnly, "提示信息"
     Unload
Me
     Exit Sub
&n ......

VB 编程中如何使窗口右上角的关闭按钮(X)失效

1、Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As
Integer)
        Cancel = True
       End Sub
    2、Private Sub
Form_Unload(Cancel As Integer)
        Cancel = ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号