FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Using IE AcitveX from FWH
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Using IE AcitveX from FWH
Posted: Wed Jan 03, 2007 04:34 PM
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.

   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:

   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
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Using IE AcitveX from FWH
Posted: Wed Jan 03, 2007 06:21 PM
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.

   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:

   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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Using IE AcitveX from FWH
Posted: Wed Jan 03, 2007 06:26 PM

>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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Using IE AcitveX from FWH
Posted: Wed Jan 03, 2007 09:36 PM
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
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Using IE AcitveX from FWH
Posted: Wed Jan 03, 2007 10:19 PM

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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Using IE AcitveX from FWH
Posted: Wed Jan 03, 2007 11:08 PM
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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Using IE AcitveX from FWH
Posted: Wed Jan 03, 2007 11:09 PM
James Bott wrote:Does "shell.explorer" return a "webBrowser" object or some other object?


It should be a WebBrowser object.

EMG
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Using IE AcitveX from FWH
Posted: Thu Jan 04, 2007 01:01 AM

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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Using IE AcitveX from FWH
Posted: Thu Jan 04, 2007 11:37 AM
This is a working sample:

#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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Using IE AcitveX from FWH
Posted: Thu Jan 04, 2007 04:24 PM

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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Using IE AcitveX from FWH
Posted: Thu Jan 04, 2007 04:52 PM
Here:

http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/WebBrowser/WebBrowser.asp

At the paragraph:

Printing the Current Page with the WebBrowser Control


Click on Show Example.

EMG
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Using IE AcitveX from FWH
Posted: Thu Jan 04, 2007 05:49 PM

Enrico,

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

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Using IE AcitveX from FWH
Posted: Thu Jan 04, 2007 05:54 PM

Enrico,

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

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Using IE AcitveX from FWH
Posted: Thu Jan 04, 2007 06:18 PM

Thank you, I've just fixed the link in my message.

EMG

Continue the discussion