这种方式很爽,不知如何实现阿。只要能在webbrowser与主程序代码交互的都行。多谢。

解决方案 »

  1.   

    实现IDocHostUIHandler::GetExternal,然后在脚本中用window.external引用应用程序中的代码
      

  2.   

    脚本调用一般都是COM吧,比如QQ的“添加表情”<script language="VBScript">Sub AddEmotion(strUrl) 
    On Error Resume Next
    set cpAdder = CreateObject("QQCPHelper.CPAdder")
    if 0 = err then
    call cpAdder.AddCustomEmotion(strUrl)
            end if
    end subSub OnContextMenu()
    set srcEvent = external.menuArguments.event
    set EventElement = external.menuArguments.document.elementFromPoint(srcEvent.clientX, srcEvent.clientY) if "HTMLImg" = TypeName(EventElement) then
    Call AddEmotion(EventElement.href)
    end if
    end sub
    call OnContextMenu()</script>就是写了个QQCPHelper.CPAdder组件,然后实现了AddCustomEmotion接口。
    关于处理HTML事件,我看到过,没用过,下面的文章也许有用:
    http://www.codeproject.com/useritems/luo31.asp
    http://www.codeproject.com/shell/dlgdhtmlevents.asp