Ich hab das für meinen HTML Editor mal geschrieben. Der benutzt zwar den WebBrowser, allerdings eine andere Variante.
Importiere einfach die dhtmled.OCX in C:\Programme\Gemeinsame Dateien\Microsoft Shared\Triedit.
Anschließend findest du zwei neue Kompos, u.a. die TDHTMLEdit. Dort kannst du Browsemode:= true einstellen und hast einen Browser.
Alternativ schau, wie du auf die DOM des Webbrowsers kommst.
Probiers mal so:
Klassendefinition:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
| TMain = class(TForm,IHTMLEditDesigner,IHTMLEditHost) ... WebEdit: TDHTMLEdit; ... function SnapRect(const pIElement: IHTMLElement; var prcNew: tagRECT; eHandle: _ELEMENT_CORNER): HResult; stdcall; function PreHandleEvent(inEvtDispId: Integer; const pIEventObj: IHTMLEventObj): HResult; stdcall; function PostHandleEvent(inEvtDispId: Integer; const pIEventObj: IHTMLEventObj): HResult; stdcall; function TranslateAccelerator(inEvtDispId: Integer; const pIEventObj: IHTMLEventObj): HResult; stdcall; function PostEditorEventNotify(inEvtDispId: Integer; const pIEventObj: IHTMLEventObj): HResult; stdcall; ... |
...
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48:
| function TMain.PostHandleEvent(inEvtDispId: Integer; const pIEventObj: IHTMLEventObj): HResult; begin Result := S_FALSE; end;
function TMain.PreHandleEvent(inEvtDispId: Integer; const pIEventObj: IHTMLEventObj): HResult; begin Result := S_FALSE; end;
function TMain.TranslateAccelerator(inEvtDispId: Integer; const pIEventObj: IHTMLEventObj): HResult; begin Result := S_FALSE; end;
function TMain.PostEditorEventNotify(inEvtDispId: Integer; const pIEventObj: IHTMLEventObj): HResult; begin if inEvtDispId = -606 then begin sb.Panels[0].Text := IntToStr(pIEventObj.clientX) + ':' + IntToStr(pIEventObj.clientY); end; Result := S_FALSE;
end;
function TMain.SnapRect(const pIElement: IHTMLElement; var prcNew: tagRECT; eHandle: _ELEMENT_CORNER): HResult; begin prcNew.left := 20 * (prcNew.left div 20); prcNew.top := 20 * (prcNew.top div 20); prcNew.right := 20 * (prcNew.right div 20); prcNew.bottom := 20 * (prcNew.bottom div 20); Result := S_OK; end;
if (WebEdit.QueryStatus(DECMD_COPY) and DECMDF_ENABLED)= DECMDF_ENABLED then WebEdit.Dom.ExecCommand('COPY',true,emptyparam);
if (WebEdit.QueryStatus(DECMD_COPY) and DECMDF_ENABLED)= DECMDF_ENABLED then WebEdit.Dom.ExecCommand('COPY',true,emptyparam); |
ganz wichtig am Ende:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7:
| initialization OleInitialize(nil);
finalization OleUninitialize;
end. |
grez
msch