unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, DHTMLEDLib_TLB,MSHTML_TLB, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
DHTMLEdit1: TDHTMLEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
MousePos: TPOINT;
Element:IHTMLElement;
begin
GetCursorPos(MousePos);
Element:=DHTMLEdit1.DOM.elementFromPoint(MousePos.X,MousePos.Y);//光標所在位置的對象
Element.innerHTML:='<HR>'+Element.innerHTML+'<HR>';//前後各插入已橫線
end;
end.
在關閉的時候
Exception EAccessViolatino in module DHTMLEd.OCX at 00007DCB.
Access violation at address 01337DCB in module 'DHTMLEd.OCX'.Read of adress 000000C8.
換成下面的沒有錯誤.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, DHTMLEDLib_TLB,MSHTML_TLB, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
DHTMLEdit1: TDHTMLEdit;
[red]DHTMLSafe1: TDHTMLSafe;[/red]
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
MousePos: TPOINT;
Element:IHTMLElement;
begin
GetCursorPos(MousePos);
Element:=DHTMLEdit1.DOM.elementFromPoint(MousePos.X,MousePos.Y);//光標所在位置的對象
Element.innerHTML:='<HR>'+Element.innerHTML+'<HR>';//前後各插入已橫線
end;
end.