why does the sample below works correctly when initiated by the button click and it hangs on the "Busy" check when run by the ON INIT clause ?
Thanks,
Davide
FWH 9.03 (same behaviour on previous versions)
- Code: Select all Expand view
#include "FiveWin.ch"
***************
function Main()
***************
Local oWnd,oBtn
DEFINE Window oWnd TITLE "Test IE"
@ 0,0 BUTTON oBtn OF oWND ACTION Go() // This Works fine
// ACTIVATE WINDOW oWnd // This Works fine
ACTIVATE WINDOW oWnd ON INIT Go() // This Doesn't work
? "Wait"
return nil
*************
Function Go()
*************
Local cHtm:="",oWnd,oActiveX,i:=0,oHtm
Local cValue:=GetPostData("first=fivewin&last=Test IE ActiveX")
DEFINE WINDOW oWnd TITLE "IE ActiveX"
oActiveX = TActiveX():New( oWnd, "Shell.Explorer" )
oWnd:oClient := oActiveX // To fill the entire window surface
oActiveX:Do( "Navigate2", "https://www.fivetechsoft.com/secure/english/test.php",,,;
cValue,"Content-type: application/x-www-form-urlencoded"+CRLF)
ACTIVATE WINDOW oWnd MAXIMIZED VALID ( oActiveX:End() , .t. )
Do While oActiveX:GetProp( "Busy" ) .and. (i<40) // Wait 20 sec. max
SysWait(.5) ; i++
Enddo
oHtm:=oActiveX:GetProp( "Document" ) // -> Object Document
If Empty(oHtm)
? "Error downloading Document"
Else
oHtm:=oHtm:Body // -> Object Body
If Empty(oHTM)
? "Error downloading Body"
Else
cHtm := oHtm:InnerHTML // -> html page
Endif
Endif
? cHtm // Let's see if it works ************************
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