我用delphi做了个框架,其中用TWebBrowser控件嵌入了一些Web页面,想在Web页面中发送消息给delphi框架,请问怎样发送消息给后台框架?

解决方案 »

  1.   

    使用THTTPServer可接收页面请求。
      

  2.   

    还是在delphi中捕获webbrowser中的各种事件比较好些吧。估计你是想知道用户在干哪方面的事情。比如当用户点击某些部位等操作。就是把所有页面的事件重载到delphi程序中去。
      

  3.   

    盒子上有个例子,用HTML做程序界面。 
    HTM中的关键代码: 
    <area shape="rect" coords="629,430,747,465" href="Email_" alt="发邮件" > 
    <area shape="rect" coords="465,243,608,362" href="photo2_" alt="照片二" > 
    <area shape="rect" coords="243,235,383,368" href="photo1_" alt="照片一" > 
    <area shape="rect" coords="20,323,138,358" href="button4_" alt="按这里退出程序" > 
    <area shape="rect" coords="20,267,138,302" href="button3_" alt="这是按钮三" > 
    <area shape="rect" coords="24,217,142,252" href="button2_" alt="这是按钮二" > 
    <area shape="rect" coords="24,166,142,201" href="button1_" alt="这是按钮一" > delphi中的关键代码: 
    procedure TForm1.WebBrowser1BeforeNavigate2(Sender: TObject; 
     const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData, 
     Headers: OleVariant; var Cancel: WordBool); 
    begin 
    If Pos('button1_', URL)>0 Then 
     Begin 
       ShowMessage('你选择了按钮一!'); 
       Cancel:=True; 
     End; 
     If Pos('button2_', URL)>0 Then 
       Begin 
         ShowMessage('你选择了按钮二!'); 
         Cancel:=True; 
       End; 
       If Pos('button3_', URL)>0 Then 
       Begin 
         ShowMessage('你选择了按钮三!'); 
         Cancel:=True; 
       End; 
        If Pos('button4_', URL)>0 Then  close;   If Pos('photo1_', URL)>0 Then 
       Begin 
         ShowMessage('你选择了图片一!'); 
         Cancel:=True; 
       End; 
        If Pos('photo2_', URL)>0 Then 
       Begin 
         ShowMessage('你选择了图片二!'); 
         Cancel:=True; 
       End; 
         If Pos('Email_', URL)>0 Then 
       Begin 
         ShowMessage('发邮件!'); 
         Cancel:=True; 
       End; 
    end; 
      

  4.   

    使用IE扩展 Protocols 协议。http://blog.sina.com.cn/s/blog_4ac69eaa0100055x.html
      

  5.   

    http://download.csdn.net/user/adayuer 这里有个用 TWebBrowser 做界面的demo。你可以看看。