Autor Beitrag
Björn karpenstein
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 96

Windows XP, Linux
D7, K3
BeitragVerfasst: Di 27.09.05 12:27 
Hallo ich möchte auf einen WebBrowser STRG-A und STRG-C machen, hab auch was gefunden, aber wie füge ich das wieder ein??? TClipboard gibt mir den Text den ich vor ner halben Std. in die Zwischenablage kopiert habe.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
initialization
  OleInitialize(nil);

finalization
  OleUninitialize;


Ist es richtig, dass der Abschnitt oben ans Ende der Unit (vor end. kommt) ?

Der Quelltext ist folgender:


ausblenden Delphi-Quelltext
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:
uses ActiveX, OleCtrls;

procedure TFormular_Posteingang.DataSource1DataChange(Sender: TObject;
  Field: TField);
var clpb: TClipboard;
begin

  if DirectoryExists(ExtractFilePath(Application.ExeName)+'anlagen\'+AdoQuery1.fieldByName('id').AsString) then
  begin
    ShellListView1.Root  := ExtractFilePath(Application.ExeName)+'anlagen\'+AdoQuery1.fieldByName('id').AsString;
  end else
  begin
    ShellListView1.Root := ExtractFilePath(Application.ExeName)+'anlagen\leer\';
  end;

  WB_LoadHTML(WebBrowser1, AdoQuery1.fieldByName('email').AsString);

  if WebBrowser1.CanFocus then WebBrowser1.SetFocus;
  try
   begin
    WebBrowser1.ExecWB(OLECMDID_SELECTALL, OLECMDEXECOPT_PROMPTUSER);
    WebBrowser1.ExecWB(OLECMDID_COPY, OLECMDEXECOPT_PROMPTUSER);
   end;
  except
  end;

  clpb := TClipboard.Create;

  RichEdit1.Lines.Text := clpb.AsText;
end;
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Mo 03.10.05 16:06 
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:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
 TMain = class(TForm,IHTMLEditDesigner,IHTMLEditHost)
  ...
  WebEdit: TDHTMLEdit;
  ...
    // *** Implementation of IHTMLHost
    function SnapRect(const pIElement: IHTMLElement; var prcNew: tagRECT; eHandle: _ELEMENT_CORNER): HResult; stdcall;
    // *** Implementation of IHTMLEditDesigner ***
    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;
...


...

ausblenden volle Höhe Delphi-Quelltext
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
    // onmousemove
    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;


// - kopieren -
// WebEdit-> ThtmlEdit
  if (WebEdit.QueryStatus(DECMD_COPY) and DECMDF_ENABLED)= DECMDF_ENABLED then
    WebEdit.Dom.ExecCommand('COPY',true,emptyparam);

// - einfügen -
  if (WebEdit.QueryStatus(DECMD_COPY) and DECMDF_ENABLED)= DECMDF_ENABLED then
    WebEdit.Dom.ExecCommand('COPY',true,emptyparam);



ganz wichtig am Ende:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
initialization
OleInitialize(nil);

finalization
OleUninitialize;

end.
grez
msch

_________________
ist das politisch, wenn ich linksdrehenden Joghurt haben möchte?