Solved

Error in Use TBrowser

Posted on 2001-06-10
7
902 Views
Last Modified: 2012-05-04
Hi
I Use from TBrowser in Delphi 5.
I want Open Pint Window , I Use Under Instruction :
WebBrowser1.ExecW(OLECMDID_PRINT,OLECMDEXECOPT_DODEFAULT);
Print Window Showed But When Close a Error Showed :
"trying to revoke a drop target that has not been registered ".
please help me
0
Comment
Question by:mpzlarge40
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 6173606
try these two ways and see if they give error:

var
vInput,vOutput : OleVariant;
begin
 WebBrowser1.ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DODEFAULT,vInput,vOutput);
end;

or this one:

var
vInput,vOutput : OleVariant;
begin
try
 WebBrowser1.ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DODEFAULT,vInput,vOutput);
except
  on E: EOleException do begin
    if (E.ErrorCode <> -2147221248) then begin
      Raise;
    end;
  end;
end;
0
 

Author Comment

by:mpzlarge40
ID: 6174852
Dear inthe
sorry , this ways don't solve this problem
Masoud Pour Zahmatkesh
0
 
LVL 17

Expert Comment

by:inthe
ID: 6174940
Hi,
do you have initialization etc as below:

var
I,O : OleVariant;
begin
WebBrowser1.ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DODEFAULT,I,O);
end;

initialization
  OleInitialize(nil);

finalization
  OleUninitialize;

end.


at the bottom of your unit put these and try again.
Regards Barry
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mpzlarge40
ID: 6174979
Hi
Dear inthe

delphi Error : undeclared idemtifier : OleInitialize
delphi Error : undeclared idemtifier : OleUnInitialize

This Function are Api Windows Functions.
but Delphi show top Error.

0
 
LVL 17

Accepted Solution

by:
inthe earned 50 total points
ID: 6175523
hi,
uses activex;
(sorry i assumed you would already have that in your uses section)
if you include a proper messages handler you would need it,twebbrowser has many bugs and needs a message handler usually just to survive common tasks.
ps,
i always recommend embeddedwb from:
http://www.euromind.com/iedelphi/
as it is a far better implementation of the browser and has most of the bugs ironed out ;-)
0
 

Author Comment

by:mpzlarge40
ID: 6188342
Thank
Very Thank From inthe.
inthe is the BEST programmer in delphi

Masoud Pour Zahmatkesh
0
 
LVL 17

Expert Comment

by:inthe
ID: 6189624
hi Masoud ,
can you paste the whole exact unit here that gives the error.

i just done some tests,
new project -add twebbrowser and one button:
on buttonclick event add the print procedure.
now i get the error.

i know from this now that the reason in my case for the error is because the browser is empty (i have not assigned/loaded anything into it)

but if i now add a second button and put
webbrowser1.oleobject.navigate('www.blah.com')
then wait for it to finish loading then press the print button i dont get the error.
i would suggest do something like:

procedure TForm1.Button1Click(Sender: TObject);
var
I,O : OleVariant;
begin
if assigned(webbrowser1.document) then
WebBrowser1.ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DODEFAULT,I,O)
else
showmessage('no document loaded');
end;


i hope this is the reason your error ocurs because it is easy to solve by doing as above (or out the print code in the twebbrowsers onDocumentComplete() event handler. :-)

let me know how it goes.
Regards Barry
 
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to define IfThen functions in one common unit? 4 71
FMX TEdit KeyUp handler detecting  "enter" key 4 57
Firemonkey Queue list 1 49
TAction.OnAfterExecute? 2 30
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question