Solved

Error in Use TBrowser

Posted on 2001-06-10
7
892 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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

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