Retrieving a web page via shell.explorer

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Wed Sep 03, 2008 1: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Davide » Wed Sep 03, 2008 2: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
Davide
 
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Postby Patrick Mast » Wed Sep 03, 2008 3: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
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby Antonio Linares » Wed Sep 03, 2008 8: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
Code: Select all  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Thu Sep 04, 2008 8:13 am

Davide, Patrick,

Got it working! :-D

wow!!!
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Patrick Mast » Thu Sep 04, 2008 8:24 am

Antonio Linares wrote:Got it working! :-D
wow!!!
This is FUN isn't it?? ;-)
Show us! ;-)

Patrick
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby Antonio Linares » Thu Sep 04, 2008 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Thu Sep 04, 2008 8:30 am

In example:

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Thu Sep 04, 2008 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Patrick Mast » Thu Sep 04, 2008 8: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
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby Antonio Linares » Thu Sep 04, 2008 9:28 am

This is the code:

test.prg
Code: Select all  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Patrick Mast » Thu Sep 04, 2008 9:38 am

Antonio,

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

Patrick
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby Davide » 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
Davide
 
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Postby Horizon » Wed Nov 19, 2008 9: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.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 36 guests