FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Retrieving a web page via shell.explorer
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Retrieving a web page via shell.explorer
Posted: Wed Sep 03, 2008 12:58 PM

Davide,

>
Some of the properties I sent you this morning allows even to be changed directly inside the ActiveX control. This way you could even change the appearance of your page locally, allowing you to use your web server as a "template" for your local application (now it's time to be really excited ).
>

Thats exactly how I browse the images in my demo :-)

I modify the InnerHTML on the fly ;-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Retrieving a web page via shell.explorer
Posted: Wed Sep 03, 2008 01:52 PM

Very useful documentation links, thanks to Davide:

"Shell.Explorer" document object:

http://msdn.microsoft.com/en-us/library/ms531073(VS.85).aspx

Navigate2 method:

http://msdn.microsoft.com/en-us/library/aa752094(VS.85).aspx

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Retrieving a web page via shell.explorer
Posted: Wed Sep 03, 2008 02:33 PM
Antonio Linares wrote:
Navigate2 method:
http://msdn.microsoft.com/en-us/library/aa752094(VS.85).aspx

Main problem here is how to translate a string like "user=username&password=mypwd" into a ByteArray (please see sub PackBytes() at http://support.microsoft.com/kb/167658) in order to do:

oActiveX:Do( "Navigate2", cURL, , , vPostData, "Content-Type: application/x-www-form-urlencoded"+CRLF)

Once this is solved we can post data to a script on a server (any script on the internet) and retrieve the dynamically generated page directly in the oActiveX object.

Hi,
Davide
Posts: 246
Joined: Sat Mar 03, 2007 08:42 PM
Retrieving a web page via shell.explorer
Posted: Wed Sep 03, 2008 03:35 PM
Davide wrote:
Antonio Linares wrote:
Navigate2 method:
http://msdn.microsoft.com/en-us/library/aa752094(VS.85).aspx

Main problem here is how to translate a string like "user=username&password=mypwd" into a ByteArray (please see sub PackBytes() at http://support.microsoft.com/kb/167658) in order to do:

oActiveX:Do( "Navigate2", cURL, , , vPostData, "Content-Type: application/x-www-form-urlencoded"+CRLF)

Once this is solved we can post data to a script on a server (any script on the internet) and retrieve the dynamically generated page directly in the oActiveX object.

Hi,
Davide

Now we are talking! :-)

Patrick
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Retrieving a web page via shell.explorer
Posted: Wed Sep 03, 2008 08:10 PM
Davide,

Here you have it. Lets try it :-)

I am calling CreateObject() so the OLE engine is properly initialized. Not needed once we use the ActiveX. Here it seems to work fine, at least there are no GPFs and it is returning a string.

test.prg
#include "FiveWin.ch"

function Main()

   local oExplorer := CreateObject( "shell.explorer" )

   MsgInfo( GetPostData( "user=username&password=mypwd" ) )
   
return nil   

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>

HRESULT hb_oleVariantToItem( PHB_ITEM pItem, VARIANT * pVariant );

HB_FUNC( GETPOSTDATA )
{
   VARIANT vPostData = {0};
   LPSAFEARRAY psa;
   LPCTSTR cszPostData = hb_parc( 1 );
   UINT cElems = lstrlen( cszPostData );
   LPSTR pPostData;

   VariantInit( &vPostData );

   psa = SafeArrayCreateVector( VT_UI1, 0, cElems );
   if( ! psa )
   {
      hb_retnl( E_OUTOFMEMORY );
      return;
   }

   SafeArrayAccessData( psa, ( LPVOID * ) &pPostData );
   memcpy( pPostData, cszPostData, cElems );
   SafeArrayUnaccessData( psa );

   V_VT( &vPostData ) = VT_ARRAY | VT_UI1;
   V_ARRAY( &vPostData ) = psa;

   hb_oleVariantToItem( hb_param( -1, HB_IT_ANY ), &vPostData );
}

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Retrieving a web page via shell.explorer
Posted: Thu Sep 04, 2008 08:13 AM

Davide, Patrick,

Got it working! :-D

wow!!!

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 246
Joined: Sat Mar 03, 2007 08:42 PM
Retrieving a web page via shell.explorer
Posted: Thu Sep 04, 2008 08:24 AM
Antonio Linares wrote:Got it working! :-)
wow!!!
This is FUN isn't it?? :-)
Show us! :-)

Patrick
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Retrieving a web page via shell.explorer
Posted: Thu Sep 04, 2008 08:27 AM
Patrick,

Please provide me a php from a https site, like this:

https://www.test.com/test.php // or from a subdomain, doesn't matter

and tell me what values to post, and display them from your php, and I will build the test in a moment :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Retrieving a web page via shell.explorer
Posted: Thu Sep 04, 2008 08:30 AM
In example:

test.php
<? echo "This is a test\n"; ?>
<? echo $HTTP_POST_VARS['first']; ?>
<? echo $HTTP_POST_VARS['last']; ?>
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Retrieving a web page via shell.explorer
Posted: Thu Sep 04, 2008 08:39 AM

Patrick,

Never mind, it is not needed. I am building the test on our secure server :-)

Just a moment...

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 246
Joined: Sat Mar 03, 2007 08:42 PM
Retrieving a web page via shell.explorer
Posted: Thu Sep 04, 2008 08:40 AM
Antonio Linares wrote:Never mind, it is not needed. I am building the test on our secure server :-)
Just a moment...

Ok! :-)

Patrick
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Retrieving a web page via shell.explorer
Posted: Thu Sep 04, 2008 09:28 AM
This is the code:

test.prg
#include "FiveWin.ch"

function Main()

   local oWnd, oActiveX
   
   DEFINE WINDOW oWnd
   
   @ 0, 0 ACTIVEX oActiveX PROGID "Shell.Explorer" OF oWnd
   
   oWnd:oClient = oActiveX
   
   ACTIVATE WINDOW oWnd ;
      ON INIT oActiveX:Do( "Navigate2",;
                           "https://www.fivetechsoft.com/secure/english/test.php",,,;
                           GetPostData( "first=fivewin&last=FiveTech Software" ),;
                           "Content-Type: application/x-www-form-urlencoded" + CRLF )
   
return nil

Here you can download the EXE:
http://rapidshare.com/files/142522826/test.zip.html

Besides the published GetPostData() source code, a modified Class TActiveX is required that will be included in next FWH build.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 246
Joined: Sat Mar 03, 2007 08:42 PM
Retrieving a web page via shell.explorer
Posted: Thu Sep 04, 2008 09:38 AM

Antonio,

Works just fine here! Congrats!
This opens so many posibilities! ;-)

Patrick

Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Retrieving a web page via shell.explorer
Posted: Thu Sep 04, 2008 10:47 AM

Antonio,
great! now we can really communicate with the world.
I'm looking forward for the next FWH build.
Hi

Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Retrieving a web page via shell.explorer
Posted: Wed Nov 19, 2008 09:01 AM

Antonio,

I just want to post some data to my web page, but i don't want to see any explorer screen. Can I do it your last example?

Thanks,

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06