Using IE AcitveX from FWH

Using IE AcitveX from FWH

Postby James Bott » Wed Jan 03, 2007 4: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.

Code: Select all  Expand view
   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  Expand view
   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
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Using IE AcitveX from FWH

Postby Enrico Maria Giordano » Wed Jan 03, 2007 6: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.

Code: Select all  Expand view
   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  Expand view
   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
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby James Bott » Wed Jan 03, 2007 6: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby James Bott » Wed Jan 03, 2007 9: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby James Bott » 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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Enrico Maria Giordano » 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
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Enrico Maria Giordano » 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
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby James Bott » Thu Jan 04, 2007 1: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Enrico Maria Giordano » Thu Jan 04, 2007 11:37 am

This is a working sample:

Code: Select all  Expand view
#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
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby James Bott » Thu Jan 04, 2007 4: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Enrico Maria Giordano » Thu Jan 04, 2007 4: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
Last edited by Enrico Maria Giordano on Thu Jan 04, 2007 6:17 pm, edited 2 times in total.
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby James Bott » Thu Jan 04, 2007 5:49 pm

Enrico,

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

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

Postby James Bott » Thu Jan 04, 2007 5:54 pm

Enrico,

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

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

Postby Enrico Maria Giordano » Thu Jan 04, 2007 6:18 pm

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

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 60 guests

cron