参考
http://www.delphibbs.com/delphibbs/dispq.asp?lid=2510118
请问如何让TWebBrowser变成只读的?
---------------------------转自网络
web:TWebBrowser
function TWordEditForm.GetDocument: _Document;
var
Doc: _Document;
begin
if Web.Document=nil then
Result := nil
else begin
Web.Document.QueryInterface(_Document,Doc);
Result := Doc;
end;
end;
保存:
procedure TWordEditForm.ProtectDocument;
begin
if not Assigned(FDocument) then Exit;
if (FDocument.ProtectionType <> -1) then
FDocument.Unprotect(EmptyParam);
FDocument.Protect(wdAllowOnlyComments, EmptyParam, EmptyParam);
end;
你可以在word->工具->保护文档 菜单项设置,看到的就是这种效果。
-----------------------------------
和这个方法类似,就是控制只读,至于复制粘贴就好处理了,作一个剪贴板监视器,一有数据来就清空数据(为什么要监视剪贴板,因为楼主的键盘上面有个拷屏的按钮),注意红色部分
unit Main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Clipbrd, StdCtrls, ExtCtrls, ShellApi; //加入clipbrd单元
type
TForm1 = class(TForm)
memResult: TMemo;
ScrollBox1: TScrollBox;
Image1: TImage;
private
{ Private declarations }
ClipHwnd: HWND; //
public
procedure WndProc(var Msg: TMessage); override;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
{ TForm1 }
procedure TForm1.WndProc(var Msg: TMessage);
{begin
SendMessage(ClipHwnd, Msg.Msg, Msg.WParam, Msg.LParam);
if (Clipboard.HasFormat(CF_TEXT) or Clipboard.HasFormat(CF_OEMTEXT)) then
memResult.Lines.Add(DateToStr(Now) + #13#10 + ' ' + Clipboard.asText);}
var
DropHandle: THandle;
FilesCount: Integer;
FileName: array[0..MAX_PATH] of Char;
I: Integer;
begin
case Msg.Msg of
WM_DRAWCLIPBOARD: {//处理剪贴内容变化消息} begin
Clipboard.Clear[red];// 在这里根据条件清空数据就行了,[/red]
SendMessage(ClipHwnd, Msg.Msg, Msg.WParam, Msg.LParam); //向下一个监视器传递内容变化消息
end;
WM_CHANGECBCHAIN:
SendMessage(ClipHwnd, Msg.Msg, Msg.WParam, Msg.LParam); //向下一个监视器传递监视器删除消息
else //其它消息按原来的处理方法
inherited WndProc(Msg);
end;
end;
constructor TForm1.Create(AOwner: TComponent);
begin
inherited;
ClipHwnd := SetClipBoardViewer(Handle); // 观察者窗口
end;
destructor TForm1.Destroy;
begin
ChangeClipboardChain(Handle, ClipHwnd);
SendMessage(ClipHwnd, WM_CHANGECBCHAIN, Handle, ClipHwnd); // 还原
inherited;
end;
end.