Using IE AcitveX from FWH

Post Reply
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Using IE AcitveX from FWH

Post by James Bott »

I am trying to control Internet Explorer from within FWH. I am testing \samples\webexp.prg. I can get IE to run in a window, but I cannot get anything else to work; toolbar, statusbar, or menubar.

Code: Select all

   oActiveX:setProp( "ToolBar", t. )
   oActiveX:setProp( "MenuBar", .t. )
   oActiveX:SetProp( "StatusBar", .t. )
None are visible.

Also, is it possible to do a print and preview using ActiveX? I can do them using the right-click menu, but I cannot find any documentation on how to call them using ActiveX. I would like to call printing and preview from the FW toolbar.

I did find that I can do:

Code: Select all

   oActiveX:print()
But this just makes a screenshot--it doesn't print the entire HTML page.

I am using FWH Aug 2006 build, xHarbour, IE7 and XP Pro.

James
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Using IE AcitveX from FWH

Post by Enrico Maria Giordano »

James Bott wrote:I am trying to control Internet Explorer from within FWH. I am testing \samples\webexp.prg. I can get IE to run in a window, but I cannot get anything else to work; toolbar, statusbar, or menubar.

Code: Select all

   oActiveX:setProp( "ToolBar", t. )
   oActiveX:setProp( "MenuBar", .t. )
   oActiveX:SetProp( "StatusBar", .t. )
None are visible.
From MSDN (WebBrowser control, Toolbar property):
The WebBrowser object ignores this property.
And the same is for the other properties above.
James Bott wrote:Also, is it possible to do a print and preview using ActiveX? I can do them using the right-click menu, but I cannot find any documentation on how to call them using ActiveX. I would like to call printing and preview from the FW toolbar.

I did find that I can do:

Code: Select all

   oActiveX:print()
But this just makes a screenshot--it doesn't print the entire HTML page.

I am using FWH Aug 2006 build, xHarbour, IE7 and XP Pro.

James
It seems that WebBrowser control doesn't offer a Print method. I saw some sample using VB SendKeys.

EMG
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

>It seems that WebBrowser control doesn't offer a Print method.

Thanks Enrico, that's the same conclusion I came to. I have seen a print/preview activeX control in my Google searches, so I will look into that.

James
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Actually the webbrowser control does have a print method. See the docs here:

http://msdn2.microsoft.com/en-us/librar ... print.aspx
Prints the document currently displayed in the WebBrowser control using the current print and page settings.
However, it does not do what it says, but rather creates a screenshot which only shows the visible part of the page complete with scrollbars.

I also tried this:

SHELLEXECUTE( 0, "print", cFile ,0,0, 1 )

Which does work with an HTML file, however, I am using an XML file and it won't work with that.

Still looking for a solution.

James
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

I found that TActiveX inherits from TControl and thus TWindow so the print() method is that of TWindow. So, oActivex:print() is really calling TWindow:print().

oActiveX:do("print") errors out. This leads me to believe that the activeX object is not a webBrowser object since the webBrowser class does have a print method.

Does "shell.explorer" return a "webBrowser" object or some other object?

oActiveX = TActiveX():New( oWnd, "Shell.Explorer" )

James
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

James Bott wrote:Actually the webbrowser control does have a print method. See the docs here:

http://msdn2.microsoft.com/en-us/librar ... print.aspx
Prints the document currently displayed in the WebBrowser control using the current print and page settings.
That documentation is for .NET platform that is a completely different thing.
James Bott wrote:However, it does not do what it says, but rather creates a screenshot which only shows the visible part of the page complete with scrollbars.
What you are calling is the Print method inherited from TWindow.

EMG
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

James Bott wrote:Does "shell.explorer" return a "webBrowser" object or some other object?
It should be a WebBrowser object.

EMG
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Enrico,

Do you have any idea how I can simlate pressing the right mouse button, then the letter "I"? Can I use PostMessage() to do this?

If I can figure out how to do this, then we can simulate calling the right-click menu and selecting Print. I can then call this from a toolbar button.

James
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

This is a working sample:

Code: Select all

#include "Fivewin.ch"


#define OLECMDID_PRINT 6
#define OLECMDEXECOPT_PROMPTUSER 1


STATIC FUNCTION MAIN()

    LOCAL oWnd, oBar, oIe

    DEFINE WINDOW oWnd

    DEFINE BUTTONBAR oBar OF oWnd

    DEFINE BUTTON OF oBar;
           ACTION oIe:Do( "ExecWB", OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER )

    oIe = TActiveX():New( oWnd, "Shell.Explorer" )

    //oIe:SetProp( "ToolBar", 1 )

    oIe:Do( "Navigate", "www.google.com" )

    oWnd:oClient = oIe

    ACTIVATE WINDOW oWnd

    RETURN NIL
EMG
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Wow, Encrico, that's just what I needed! Thanks.

Where did you find the documentation for that? I expect there might be more useful things there.

I must have spent three hours searching the net for documentation and I didn't find that.

James
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Here:

http://msdn.microsoft.com/library/defau ... rowser.asp

At the paragraph:
Printing the Current Page with the WebBrowser Control
Click on Show Example.

EMG
Last edited by Enrico Maria Giordano on Thu Jan 04, 2007 6:17 pm, edited 2 times in total.
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Enrico,

I get a "cannot display page" error when trying that link.

James
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Enrico,

OK I figured out that the link is missing a ? after ...default.asp. Now it works.

James
Post Reply