By default, Delphi's TWEBBROWSER control is not supported, which makes some multi-line text boxes unable to enter, and the solution is as follows: Unit unit1;
InterfaceUses Windows, Messages, Sysutils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Olectrls, Shdocvw_TLB, ActiveX, Stdctrls;
type TForm1 = class (TForm) WebBrowser1: TWebBrowser; Button1: TButton; Button2: TButton; procedure FormDestroy (Sender: TObject); procedure FormCreate (Sender: TObject); procedure Button1Click (Sender: TObject); procedure Button2Click (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; End; Procedure TFORM1.MSGHANDLER (VAR MSG: TMSG; VAR HANDLED: BOOLEAN);
Const Dialogkeys: Set of byte = [VK_LEFT, VK_RIGHT, VK_BACK, VK_UP, VK_DOWN, $ 30 .. $ 39, $ 41..42, $ 44.. $ 55, $ 57, $ 59 .. $ 5A];
Var Ioipao: IoleinplaceActiveObject; Dispatch: iDispatch;
Begin
{EXIT IF WE Don't get back awebbrowser object} if (webbrowser1 = nil)
= 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 FOLEINPLACTIVEOBJECT: = IOIPAO; End; End; if foleinplaceactiveObject <> nil dam_keydown or (msg.Message = WM_KEYUP))
And (msg.wparam in dialogkeys)
THEN
// Nothing - Do Not Pass on the dialogkeys
Else foleinplaceactiveObject.translateAccelerator (msg); end;
Initialization Oleinitialize (NIL);
Finalization oleuninitialize;