Solved

Error in Use TBrowser

Posted on 2001-06-10
7
878 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
  • 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now