?
Solved

Delphi 3 & WebBrowser (C to Delphi)

Posted on 1997-05-02
11
Medium Priority
?
507 Views
Last Modified: 2010-04-06
How to translate this from C++ to Delphi 3?

       LPDISPATCH lpDispatch = NULL;
       LPOLECOMMANDTARGET lpOleCommandTarget = NULL;

       lpDispatch = m_ctlWebBrowser.GetDocument();
       ASSERT(lpDispatch);

       lpDispatch->QueryInterface(IID_IOleCommandTarget,
                                  (void**)&lpOleCommandTarget);
       ASSERT(lpOleCommandTarget);

       lpDispatch->Release();

       // print contents of web browser control
       lpOleCommandTarget->Exec(NULL, OLECMDID_PRINT, 0, NULL,NULL);

       lpOleCommandTarget->Release();

the answer is somewhere in ActiveX.pas

If I translate this into Delphi it doesn't work. I am using the Internet Explorer 3.02 WebBrowser ActiveX control.

webbrowser.document.queryinterfacce(OleCommandTarget, OCT);
OCT.Exec(GUID_NULL, OLEID_PRINT, 0, variant, variant);

The error it returns is unidentifiable. (BTW the above is as I remeber it - didn't check the syntax).
0
Comment
Question by:kolarb
[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
  • 6
  • 4
11 Comments
 
LVL 2

Author Comment

by:kolarb
ID: 1335858
Adjusted points to 300
0
 
LVL 2

Author Comment

by:kolarb
ID: 1335859
Edited text of question
0
 
LVL 2

Author Comment

by:kolarb
ID: 1335860
Adjusted points to 600
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 2

Expert Comment

by:gysbert1
ID: 1335861
If you can contact me via E-Mail and send me the info I need I will have a look if I can do this for you ...

I do not have a copy of the activeX control or any info thereof. You say this works fine in C++ ? Since I have translated many programs in the past I should be able to do this.

If you could mail me the Info you have gathered thusfar and the control, as well as a small compilable sample app in c++ (I assume you are not using visual c but straigt c++) I will give it a go ...

My adress is prefect@iafrica.com
0
 
LVL 3

Accepted Solution

by:
sperling earned 1800 total points
ID: 1335862
WB is of type TWebBrowser.

procedure TForm1.Button1Click(Sender: TObject);
var
  pg      : PGUID;
  Dummy   : OleVariant;
  RetVal  : INTEGER;
begin
  pg := nil;
  RetVal :=
  (WB.ControlInterface.Document as IOLECommandTarget).Exec
    ( pg^, OLECMDID_PRINT, 0, Dummy, Dummy);
end;


The trick is how to pass a nil pointer to Exec.

I do believe this is what you needed, if not, let me know. I'm sorry it took so long.

Regards,

Erik.
0
 
LVL 2

Author Comment

by:kolarb
ID: 1335863
Thanks Eric, this worked fine and I noticed what a little change it needed from my program. I never tried to actually send a nil pointer instead of a GUID_NULL.

But I still need help regarding this topic. Delphi is not firing any events with the WebBrowser app. For Delphi2 there was a patch available from Borland - of course since all of the main units were rewriten this patch is not applicable anymore. I need to fire this Print command from an WebBrowser event.

So I am asking you to help me enable events on the browser.

I am appending comment from Peter Maude from the activeX newsgroup on Borland.com.



> When I looked at the Wrapper file for the OCX shDocVw.pas it appeared
> that Delphi had set the DWebBroweser events as the event Interface. In
> the initConrolData method the DWebBrowserEvents is specified as the
> EventIID.  When you look at the Base Implementation of TActiveXControl
> you can see that a connection Point is created for the EventIID.

> Here is the problem. DWebBrowser is a Dual Interface, is the Internet
> Explorer firing the events down what it assumes should be an implemented
> interface as opposed to the Invoke method on the base IDispatch.

> Borland only implement the Invoke type handlers and not the full dual
> implementation. BUT they create a Connection point for the Full
> implementation. Therefore when the Internet explorer tries to connect an
> outgoing interfaces it will think it can send events down the more
> optimised dual implementation, which in reality is only a IDispatch
> handler ?
0
 
LVL 3

Expert Comment

by:sperling
ID: 1335864
Well, for the amount of points you're offering I'll gladly attempt to resolve this Q too... I'll fiddle around with the generated classes for the webbrowser, and let you know when I've found a solution.

Regards,

Erik.
0
 
LVL 2

Author Comment

by:kolarb
ID: 1335865
I originally wanted to append this to the question too, but your answer came very quickly. :)
0
 
LVL 3

Expert Comment

by:sperling
ID: 1335866
What events don't work?

I've tried OnProgressChange and OnNavigateComplete, and they both works as intended...

Regards,

Erik.


0
 
LVL 2

Author Comment

by:kolarb
ID: 1335867
Hi -- sperling. Looks like my beta version of Delphi3 was to blame for webbrowser not working properly.


PS: please wait a little bit more, and I will give you 2400 quality points :)
0
 
LVL 3

Expert Comment

by:sperling
ID: 1335868
No rush ;)

You getting things to work?

Regards,

Erik.
0

Featured Post

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!

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month11 days, 18 hours left to enroll

752 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