The following code is working fine with Borland C Compiler via STATIC linking of the DLL. I have added the missing C wrapper definitions.
Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local hWebView := WebView_Create()
WebView_Navigate( hWebView, Html() ) // or use an URL
SysWait( 2 )
WebView_Bind( hWebView, "SendToFWH", SendToFWHAddress(), hWebView )
WebView_Eval( hWebView, 'document.getElementById( "user" ).value = "fivetech"' )
WebView_Eval( hWebView, 'document.getElementById( "passwd" ).value = "1234"' )
SysWait( 2 )
WebView_Eval( hWebView, 'document.getElementById( "submit" ).click()' )
WebView_Run( hWebView )
WebView_Destroy( hWebView )
return nil
function Html()
local cHtml
TEXT INTO cHtml
data:text/html,
<html>
<head>
</head>
<body style="background-color:cyan">
<h2>Using WebView from FWH</h2>
<form method="post">
<label for="fname">username:</label>
<input type="text" id="user" name="username"><br><br>
<label for="lname">password:</label>
<input type="text" id="passwd" name="password"><br><br>
<input type="submit" id="submit" value="Submit" onclick="alert('ok')">
</form>
</body>
</html>
ENDTEXT
return cHtml
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
#include <hbvm.h>
void * webview_create(int debug, void * window );
void webview_run( void * w );
void webview_navigate( void * w, const char * url );
void webview_destroy( void * w );
void webview_eval( void * w, const char * javascript );
void webview_bind( void * w, const char * name, void * func, void * pvoid );
HB_FUNC( WEBVIEW_CREATE )
{
hb_retptr( webview_create( 0, NULL ) );
}
HB_FUNC( WEBVIEW_RUN )
{
webview_run( hb_parptr( 1 ) );
}
HB_FUNC( WEBVIEW_NAVIGATE )
{
webview_navigate( hb_parptr( 1 ), hb_parc( 2 ) );
}
HB_FUNC( WEBVIEW_DESTROY )
{
webview_destroy( hb_parptr( 1 ) );
}
HB_FUNC( WEBVIEW_BIND )
{
webview_bind( hb_parptr( 1 ), hb_parc( 2 ), hb_parptr( 3 ), hb_parptr( 4 ) );
}
HB_FUNC( WEBVIEW_EVAL )
{
webview_eval( hb_parptr( 1 ), hb_parc( 2 ) );
}
static void SendToFWH( const char * szNumRequests, const char * szJson, void * p )
{
hb_vmPushSymbol( hb_dynsymGetSymbol( "WEBVIEW_SAVEVALUES" ) );
hb_vmPushNil();
hb_vmPushString( szNumRequests, strlen( szNumRequests ) );
hb_vmPushString( szJson, strlen( szJson ) );
hb_vmFunction( 2 );
}
HB_FUNC( SENDTOFWHADDRESS )
{
hb_retnl( ( HB_LONG ) SendToFWH );
}
#pragma ENDDUMP