tWebBrowser中不能回车以及copy

I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
在tWebBrowser中,如果navigate到的页面上有textarea框,我发现就是不能在里面用回车换行,一定要用alt+13才行。另外不能ctrl+c。 是不是该控件的bug,还是哪里设置不对?
 
回复贴子:
 回复人:Daiver(Daiver) (2000-11-30 19:09:00) 得0分
是Delphi的BUG来的,在VB中没有这种情况(老BILl)还是对自己好啊!)在程序员大本营中有解决的办法,是DELphi中的技巧2,我只是看了,没有去试过,你可以去试试 啊,有什么结果记得E_mail给我(Daiver@163.net)
 回复人:easypaper() (2000-11-30 19:24:00) 得0分
关于复制的问题,不是DELPHI的BUG,是因为你的程序里面少了一点东西。
在初始化函数里面,增加
OleInitialize(nil);
在推出程序之前,增加:
OleUninitialize();
解可以解决这个问题。
至于回车的问题,可以算是vcl的bug(其实是封装机制问题,vcl将回车给吃掉了)。
 
 回复人:menxin() (2000-12-4 20:31:00) 得0分
没办法彻底解决,你应该用www.intelligo.com/iedelphi 上的Embedded.
 回复人:pengpenghu(碰碰和) (2000-12-9 10:10:00) 得0分
我无法打开这个网站www.intelligo.com/iedelphi ,你有没有现成的?
 回复人:Nicrosoft(奈软) (2000-12-9 10:27:00) 得0分
这个控件不是vcl的,是IE自带的ocx,所以不可能是delphi的bug
 回复人:alaclp(陈石) (2001-2-22 8:21:00) 得0分
在主窗体中添加TappliationEvent,在其事件中写如下代码,
//uses Activex
procedure TMainFrm.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
{ fixes the malfunction of some keys within webbrowser control }
const
StdKeys = [VK_TAB, VK_RETURN]; { standard keys }
ExtKeys = [VK_DELETE, VK_BACK, VK_LEFT, VK_RIGHT]; { extended keys }
fExtended = $01000000; { extended key flag }
var
WebBrowser1: TWebBrowser;
begin
if Pages.PageCount = 0 then Exit;
WebBrowser1 := GetCurrentWeb;
Handled := False;
with Msg do
if ((Message >= WM_KEYFIRST) and (Message <= WM_KEYLAST)) and
((wParam in StdKeys) or {$IFDEF VER120}(GetKeyState(VK_CONTROL) < 0) or {$ENDIF}
(wParam in ExtKeys) and ((lParam and fExtended) = fExtended)) then
try
if IsChild(WebBrowser1.Handle, hWnd) then
{ handles all browser related messages }
begin
with WebBrowser1.Application as IOleInPlaceActiveObject do
Handled := TranslateAccelerator(Msg) = S_OK;
if not Handled then
begin
Handled := True;
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end;
except end;
end; // IEMessageHandler
另外,easypaper所说的oleini..., oleunini...,不只写在那里,有何作用?
 
 回复人:aton() (2001-2-28 19:33:00) 得0分
先要使WebBrowser获得焦点
  TWebBrowser非常特殊,它从TWinControl继承来的SetFocus方法并不能使得它所包含的文档获得焦点,从而不能立即使用Internet Explorer本身具有得快捷键,解决方法如下:<
  procedure TForm1.SetFocusToDoc;
  begin
   if WebBrowser1.Document <> nil then
    with WebBrowser1.Application as IOleobject do
     DoVerb(OLEIVERB_UIACTIVATE, nil, WebBrowser1, 0, Handle, GetClientRect);
  end;
  除此之外,我还找到一种更简单的方法,这里一并列出:
  if WebBrowser1.Document <> nil then
   IHTMLWindow2(IHTMLDocument2(WebBrowser1.Document).ParentWindow).focus
  刚找到了更简单的方法,也许是最简单的:
  if WebBrowser1.Document <> nil then
   IHTMLWindow4(WebBrowser1.Document).focus
  还有,需要判断文档是否获得焦点这样来做:
  if IHTMLWindow4(WebBrowser1.Document).hasfocus then
 
 
顶部