trichview.com

trichview.support




Re: Copying HTML?


Return to index


Author

Message

Sergey Tkachenko

Posted: 04/22/2004 21:44:06


> I assume in this case I would change the .inc file, uninstall RichView and

> re-install it, making sure I write over the old BPL moved to

> \windows\system32?


It's not necessary to reinstall RichView packages, but yes, you need to

reinstall RichViewActions


> > > (ii) the actual HTML for the selected/copied segment of the web page

> (like

> > > in 'View Source' in IE).

> >

> > It's not supported by default, but I can give a code returning it.

>

> Thanks! I'll just focus on (i) for the moment . . .

>


Below is the code for saving HTML from the Clipboard in file.

You can use TStringStream instead of TFileStream to get it as a text string.

It contains a small header before the actual HTML data (specifying a

position in the string where HTML starts)



var Stream: TFileStream;

    cf: Cardinal;

    mem: Cardinal;

    ptr: Pointer;

    Size: Integer;

begin

  cf := RegisterClipboardFormat('HTML Format');

  if not Clipboard.HasFormat(cf) then begin

    Application.MessageBox('Clipboard does not contain HTML',nil,MB_OK or

MB_ICONSTOP);

    exit;

  end;

  Clipboard.Open;

  Stream := TFileStream.Create('Clipboard.htm', fmCreate);

  try

    mem := Clipboard.GetAsHandle(cf);

    Size := GlobalSize(mem);

    ptr := GlobalLock(mem);

    Stream.WriteBuffer(ptr^, Size);

    GlobalUnlock(mem);

  finally

    Stream.Free;

    Clipboard.Close;

  end;

  Application.MessageBox('Clipboard.htm is saved!',nil,MB_OK or

MB_ICONINFORMATION);

end;





Powered by ABC Amber Outlook Express Converter