Page 2 of 4

PostPosted: Wed Sep 03, 2008 12:58 pm
by Antonio Linares
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 ;-)

PostPosted: Wed Sep 03, 2008 1:52 pm
by Antonio Linares
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

PostPosted: Wed Sep 03, 2008 2:33 pm
by Davide
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

PostPosted: Wed Sep 03, 2008 3:35 pm
by Patrick Mast
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

PostPosted: Wed Sep 03, 2008 8:10 pm
by Antonio Linares
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     

PostPosted: Thu Sep 04, 2008 8:13 am
by Antonio Linares
Davide, Patrick,

Got it working! :-D

wow!!!

PostPosted: Thu Sep 04, 2008 8:24 am
by Patrick Mast
Antonio Linares wrote:Got it working! :-D
wow!!!
This is FUN isn't it?? ;-)
Show us! ;-)

Patrick

PostPosted: Thu Sep 04, 2008 8:27 am
by Antonio Linares
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 ;-)

PostPosted: Thu Sep 04, 2008 8:30 am
by Antonio Linares
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']; ?>

PostPosted: Thu Sep 04, 2008 8:39 am
by Antonio Linares
Patrick,

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

Just a moment...

PostPosted: Thu Sep 04, 2008 8:40 am
by Patrick Mast
Antonio Linares wrote:Never mind, it is not needed. I am building the test on our secure server :-)
Just a moment...

Ok! ;-)

Patrick

PostPosted: Thu Sep 04, 2008 9:28 am
by Antonio Linares
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.

PostPosted: Thu Sep 04, 2008 9:38 am
by Patrick Mast
Antonio,

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

Patrick

PostPosted: Thu Sep 04, 2008 10:47 am
by Davide
Antonio,
great! now we can really communicate with the world.
I'm looking forward for the next FWH build.
Hi

PostPosted: Wed Nov 19, 2008 9:01 am
by Horizon
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,