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
Solved

Error in Use TBrowser

Posted on 2001-06-10
7
895 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
error 1.1 400 Bad request idhttp delphi 18 144
Printing problem 2 101
Delphi and Access based Enumeration 9 70
Firemonkey BASS_Init into a thread 17 30
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

840 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