Page 1 of 1

Using IE AcitveX from FWH

Posted: Wed Jan 03, 2007 4:34 pm
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

Re: Using IE AcitveX from FWH

Posted: Wed Jan 03, 2007 6:21 pm
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

Posted: Wed Jan 03, 2007 6:26 pm
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

Posted: Wed Jan 03, 2007 9:36 pm
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

Posted: Wed Jan 03, 2007 10:19 pm
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

Posted: Wed Jan 03, 2007 11:08 pm
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

Posted: Wed Jan 03, 2007 11:09 pm
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

Posted: Thu Jan 04, 2007 1:01 am
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

Posted: Thu Jan 04, 2007 11:37 am
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

Posted: Thu Jan 04, 2007 4:24 pm
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

Posted: Thu Jan 04, 2007 4:52 pm
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

Posted: Thu Jan 04, 2007 5:49 pm
by James Bott
Enrico,

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

James

Posted: Thu Jan 04, 2007 5:54 pm
by James Bott
Enrico,

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

James

Posted: Thu Jan 04, 2007 6:18 pm
by Enrico Maria Giordano
Thank you, I've just fixed the link in my message.

EMG