CWebBrowser 中处理回车相应的问题

Q:我做了一个mfc程序,其中视图是继承自 CFormView,在 CFormView上呢放置了一个WebBrowser控件,用来显示一个html文件,我在视图的成员函数OnInitialUpdate()中写了如下代码:其中CWebBrowser2 m_htmlShow;
 
运行程序的时候,出现了上述网页,
我想问的是,
本来这个网页里有一个编辑框,供用户输入数据使用,没有集成在我的程序的时候,可以输入换行。可在我的程序里浏览这个网页时候,输入数据却无法换行,不知道是什么原因。
 
A:因为回车键消息被你的窗口拦截了,没给控件处理机会。
Q:请问如何传递回车消息给CWebBrowser2控件??现在是页面里面不响应回车
A:如果是回车的话不调用CDialog::PretranslateMessage,调用CWnd::
 

This   article   may   contain   URLs   that   were   valid   when   originally   published,   but   now   link   to   sites   or   pages   that   no   longer   exist.   To   maintain   the   flow   of   the   article,   we've   left   these   URLs   in   the   text,   but   disabled   the   links.    
  --------------------------------------------------------------------------------   
WebBrowser   Keystroke   Problems    
     
  lot   of   people   have   noticed   that   when   they're   hosting   the   WebBrowser   control   in   MFC,   ATL,   or   standard   C++   applications,   they   sometimes   run   into   trouble   with   certain   keys.   These   keystroke   problems   usually   occur   when   typing   into   intrinsic   controls   such   as   text   boxes   that   reside   on   Web   pages   loaded   by   the   WebBrowser   control.   Usually   these   keys   are   accelerator   keys   such   as   Backspace,   Delete,   and   Tab.   The   problem   is   that   the   intrinsic   controls   on   a   Web   page   do   not   automatically   receive   these   accelerator   keys.   When   the   WebBrowser   control   receives   an   accelerator   key   message,   it   does   not   automatically   pass   it   to   child   controls   on   a   Web   page.   Therefore,   you   must   somehow   let   the   WebBrowser   control   know   that   it   should   pass   these   messages   to   controls   on   your   Web   page.           The   solution   is   always   the   same   whether   you   are   hosting   the   control   in   MFC,   ATL,   or   standard   C++:   call   the   TranslateAcclerator   method   of   the   IOleInPlaceActiveObject   interface   that   is   implemented   by   the   WebBrowser   control.   But   where   and   how   you   should   do   this   is   often   unclear.   Let's   see   how   to   work   around   keystroke   problems   in   MFC,   ATL,   and   standard   C++   applications   that   are   hosting   the   WebBrowser   control.  
   
   
  MFC   Dialogs    
   
          You   can   create   three   types   of   applications   in   MFC:   dialog-based,   single-document   interface   (SDI),   and   multiple-document   interface   (MDI).   Each   type   requires   a   different   solution   to   the   keystroke   problems.  
   
          When   hosting   the   WebBrowser   control   in   an   MFC   dialog-based   application,   the   TranslateAccelerator   method   is   automatically   called   for   you,   so   you   don't   run   into   these   problems   with   keystrokes.   But   understanding   how   MFC   works   when   you   are   hosting   the   WebBrowser   control   in   a   dialog-based   application   will   help   you   diagnose   and   solve   problems   with   keystrokes   in   other   situations.  
   
          In   an   MFC   application,   the   Windows®   message   pump   is   managed   for   you.   In   a   dialog-based   application,   a   method   called   IsDialogMessage   is   invoked   each   time   a   message   enters   the   loop.   Among   other   things,   this   function   will   call   TranslateAccelerator   for   any   controls   in   the   dialog.   IsDialogMessage   will   pass   the   MSG   structure   that   was   received   from   a   call   to   the   GetMessage   function   in   the   message   pump   to   the   TranslateAccelerator   method.   MFC   does   this   by   creating   an   instance   of   a   class   called   COccManager   that   manages   all   the   OLE   controls   on   your   dialog.   The   IsDialogMessage   method   is   a   member   of   the   COccManager   class.    
   
          The   IsDialogMessage   method   first   gets   a   handle   to   the   window   that   has   the   focus.   If   this   window   is   a   c

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值