?
Solved

Error in Use TBrowser

Posted on 2001-06-10
7
Medium Priority
?
907 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 150 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month12 days, 18 hours left to enroll

777 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