TWebBrowser的“试图激活未注册的丢失目标“错误 |
尚未結案
|
wzpuma
一般會員 發表:10 回覆:19 積分:5 註冊:2003-02-27 發送簡訊給我 |
我用TWebBrowser的ExecWB设置页面字体大小。类似“字体”菜单上的从“最大”到“最小”五项(对应整数0~4, Largest等假设为五个菜单项的名字,Tag 属性分别设为0~4)。代码如下:
procedure TForm1.MainMenu1Change(Sender: TObject; Source: TMenuItem;
Rebuild: Boolean);
var t: OleVariant;
Begin
Largest.Checked :=false;
Larger.Checked :=false;
Middle.Checked :=false;
Small.Checked :=false;
Smallest.Checked :=false;
TMenuItem(Sender).Checked :=true;
t :=TMenuItem(Sender).Tag;
WebBrowser1.ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER,t,t);
end;
运行出现“试图激活未注册的丢失目标“错误。且只要用ExecWB就出现此错误,
这是为何?
|
hagar
版主 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
參考 Borland 的解答: http://bdn.borland.com/article/0,1410,27043,00.html
轉貼如下:
Abstract: How to resolve the error "Trying to revoke a drop target that has not been registered".
TWebBrowser.ExecWB can generate the error "Trying to revoke a drop target that has not been registered" under 2 different conditions:
1. TWebBrowser is not yet ready to accept the command. For following may generate this error:
Navigate('e:\pictures\picture1.jpg');
ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER);
To resolve the problem use QueryStatusWB and wait for it to return OLECMDF_SUPPORTED + OLECMDF_ENABLED. Below is an example that fixes the problem:
Navigate('e:\pictures\picture1.jpg');
while QueryStatusWB( OLECMDID_PRINT) <> OLECMDF_SUPPORTED + OLECMDF_ENABLED do
Forms.Application.ProcessMessages;
ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER);
2. Even though you use QueryStatusWB, Copy and Paste may still fail. Add the following to the end of your unit to resolve the problem:
initialization
OleInitialize(nil);
finalization
OleUninitialize; ---
每個人都是一本書
|
wzpuma
一般會員 發表:10 回覆:19 積分:5 註冊:2003-02-27 發送簡訊給我 |
initialization
OleInitialize(nil);
finalization
OleUninitialize;
啥意思?是因为OLE对象需要初始化和终止化吗?加入上述代码好像行不通。
我曾提了一问题“OLE对象的Initialization & Finalization”,见“http://delphi.ktop.com.tw/topic.php?TOPIC_ID=29182”,william回答曰“Unless you are using the TWebBrower in a thread other than the main thread, there is no need to initialize and finalize.”
|
euzen
一般會員 發表:0 回覆:1 積分:0 註冊:2003-05-17 發送簡訊給我 |
引言: initialization OleInitialize(nil); finalization OleUninitialize; 啥意思?是因为OLE对象需要初始化和终止化吗?加入上述代码好像行不通。 我曾提了一问题“OLE对象的Initialization & Finalization”,见“http://delphi.ktop.com.tw/topic.php?TOPIC_ID=29182”,william回答曰“Unless you are using the TWebBrower in a thread other than the main thread, there is no need to initialize and finalize.”把 initialization OleInitialize(nil); finalization OleUninitialize; 放在所有的func,proc之后,end. 之前。 在USES部分加入 OLE2 如果编译的时候提示 OLE2 没找到,在LIB path里加入$(DELPHI)\Lib\Delphi2 發表人 - euzen 於 2003/05/17 16:07:06 |
vclphi
一般會員 發表:28 回覆:39 積分:13 註冊:2003-03-06 發送簡訊給我 |
|
wzpuma
一般會員 發表:10 回覆:19 積分:5 註冊:2003-02-27 發送簡訊給我 |
|
wzpuma
一般會員 發表:10 回覆:19 積分:5 註冊:2003-02-27 發送簡訊給我 |
引言: 參考 Borland 的解答: http://bdn.borland.com/article/0,1410,27043,00.html 轉貼如下: Abstract: How to resolve the error "Trying to revoke a drop target that has not been registered". TWebBrowser.ExecWB can generate the error "Trying to revoke a drop target that has not been registered" under 2 different conditions: 1. TWebBrowser is not yet ready to accept the command. For following may generate this error: Navigate('e:\pictures\picture1.jpg'); ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER); To resolve the problem use QueryStatusWB and wait for it to return OLECMDF_SUPPORTED OLECMDF_ENABLED. Below is an example that fixes the problem: Navigate('e:\pictures\picture1.jpg'); while QueryStatusWB( OLECMDID_PRINT) <> OLECMDF_SUPPORTED OLECMDF_ENABLED do Forms.Application.ProcessMessages; ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER);第一段看不大懂,用Navigate,如: var Flags: OLEVariant; Flags := 0; WebBrowser1.Navigate("www.yahoo.com", Flags, Flags, Flags, Flags); 都要加上一段:while QueryStatusWB( OLECMDID_PRINT) <> OLECMDF_SUPPORTED OLECMDF_ENABLED do Forms.Application.ProcessMessages; 才安全吗?如我并不PRINT,只是Navigate当如何? 要 Uses activex; 不是ole2 發表人 - wzpuma 於 2003/06/03 16:45:59 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |