急急急!!! Twebbrowse运行时为什么不能与任何程序互相复制,粘贴!(100分)

  • 主题发起人 主题发起人 HongKong5
  • 开始时间 开始时间
H

HongKong5

Unregistered / Unconfirmed
GUEST, unregistred user!
我把twebbrowse内容复制一下,但在其他程序用粘贴时,该程序的弹出式菜单的粘贴项为灰,不能粘贴.相反操作也是如此。
 
var
Form1: TForm1;
FOleInPlaceActiveObject: IOleInPlaceActiveObject;
SaveMessageHandler: TMessageEvent;

...

implementation

...

procedure TForm1.FormActivate(Sender: TObject);
begin
SaveMessageHandler := Application.OnMessage;
Application.OnMessage := MyMessageHandler;
end;

procedure TForm1.FormDeactivate(Sender: TObject);
begin
Application.OnMessage := SaveMessageHandler;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Application.OnMessage := SaveMessageHandler;
FOleInPlaceActiveObject := nil;
end;

procedure TForm1.MyMessageHandler(var Msg: TMsg; var Handled: Boolean);
var
iOIPAO: IOleInPlaceActiveObject;
Dispatch: IDispatch;
begin
{ exit if we don't get back a webbrowser object }
if WebBrowser = nil then
begin
Handled := False;
Exit;
end;

Handled:=(IsDialogMessage(WebBrowser.Handle, Msg) = True);

if (Handled) and (not WebBrowser.Busy) then
begin
if FOleInPlaceActiveObject = nil then
begin
Dispatch := WebBrowser.Application;
if Dispatch <> nil then
begin
Dispatch.QueryInterface(IOleInPlaceActiveObject, iOIPAO);
if iOIPAO <> nil then
FOleInPlaceActiveObject := iOIPAO;
end;
end;

if FOleInPlaceActiveObject <> nil then
if ((Msg.message = WM_KEYDOWN) or (Msg.message = WM_KEYUP)) and
((Msg.wParam = VK_BACK) or (Msg.wParam = VK_LEFT) or (Msg.wParam = VK_RIGHT)) then
//nothing - do not pass on Backspace, Left or Right arrows
else
FOleInPlaceActiveObject.TranslateAccelerator(Msg);
end;
end;
 
You have to add the following line to the bottom of your unit:

initialization
OleInitialize(nil);

finalization
OleUninitialize;


 
多谢,能否讲一下!
 
hubdog:
讲一下呀!
 
程序中有时候可以,有时候不可以,我也很烦这个,hubdog
能不能讲讲为什么要特殊处理过?
 
这是别人帖的帖子,我只是copy一下,别问我:)
 
需要引用那些单元?
 
activex
OleCtrls
SHDocVw
大概差不多了
 
接受答案了.
 
后退
顶部