我用的是WebBrowser加载了一个网页游戏(别人是用flash做的),现在的问题是在进入游戏(flash游戏)后,没办法在聊天框中响影回车消息!在IE中回车是可以的,而在WebBrowser没办法响影,不知道为什么那位知道的可以告诉小弟吗?
最好能有代码,谢谢了!
或者加我QQ:66826628
网页游戏地址:http://www.66w.com

解决方案 »

  1.   

    {    
          Problem:    
       
          Web   forms   that   have   multi-line   text   boxes   and/or   Submit   buttons   do   not    
          respond   to   the   Enter   key   when   displayed   on   a   TWebbrowser.    
          Also   when   browsing   local   folders,   some   keys   don't   respond.    
       
          How   to   solve   it:    
      }    
       
      unit   Unit1;  
       
      interface  
       
      uses  
          Windows,   Messages,   SysUtils,   Variants,   Classes,   Graphics,   Controls,   Forms,  
          Dialogs,   OleCtrls,   ActiveX,   StdCtrls,   SHDocVw;  
       
      type  
          TForm1   =   class(TForm)  
              WebBrowser1:   TWebBrowser;  
              Button1:   TButton;  
              procedure   FormDestroy(Sender:   TObject);  
              procedure   FormCreate(Sender:   TObject);  
          private  
              {   Private   declarations   }    
              FOleInPlaceActiveObject:   IOleInPlaceActiveObject;    
              procedure   MsgHandler(var   Msg:   TMsg;   var   Handled:   Boolean);    
          public    
              {   Public   declarations   }    
          end;    
       
      var    
          Form1:   TForm1;    
       
       
      implementation    
       
      {$R   *.dfm}    
       
      procedure   TForm1.FormDestroy(Sender:   TObject);    
      begin    
          FOleInPlaceActiveObject   :=   nil;  
      end;  
       
      procedure   TForm1.FormCreate(Sender:   TObject);    
      begin    
          Application.OnMessage   :=   MsgHandler;  
          WebBrowser1.Navigate('www.google.com');  
      end;    
       
      procedure   TForm1.MsgHandler(var   Msg:   TMsg;   var   Handled:   Boolean);    
      const    
          DialogKeys:   set   of   Byte   =   [VK_LEFT,   VK_RIGHT,   VK_BACK,   $30..$39,   $41..$5A];    
      var  
          iOIPAO:   IOleInPlaceActiveObject;    
          Dispatch:   IDispatch;  
      begin  
          {   exit   if   we   don't   get   back   a   webbrowser   object   }    
          if   (WebBrowser1   =   nil)   then    
          begin    
              Handled   :=   System.False;    
              Exit;    
          end;    
       
          Handled   :=   (IsDialogMessage(WebBrowser1.Handle,   Msg)   =   System.True);    
       
          if   (Handled)   and   (not   WebBrowser1.Busy)   then    
          begin    
              if   FOleInPlaceActiveObject   =   nil   then    
              begin    
                  Dispatch   :=   WebBrowser1.Application;    
                  if   Dispatch   <>   nil   then    
                  begin    
                      Dispatch.QueryInterface(IOleInPlaceActiveObject,   iOIPAO);    
                      if   iOIPAO   <>   nil   then    
                          FOleInPlaceActiveObject   :=   iOIPAO;  
                  end;  
              end;    
       
              if   FOleInPlaceActiveObject   <>   nil   then    
                  if   ((Msg.message   =   WM_KEYDOWN)   or   (Msg.message   =   WM_KEYUP))   and    
                      (Msg.wParam   in   DialogKeys)   then    
                      //   nothing   -   do   not   pass   on   the   DialogKeys    
                  else    
                      FOleInPlaceActiveObject.TranslateAccelerator(Msg);    
          end;    
      end;  
       
      end.   
    看看这个代码可以不?