Dear Hakan,
This example automatically fills the values of the Gets and click the button:
webview.prg
Code: Select all | Expand
#include "FiveWin.ch"
static hDLL, s_nCalls, s_cJsonResult
function Main()
local hWebView
hDLL = LoadLibrary( "webview.dll" )
hWebView = WebView_Create( 0, 0 )
WebView_Navigate( hWebView, Html() ) // or use an URL
WebView_Bind( hWebView, "SendToFWH", SendToFWHAddress(), hWebView )
SysWait( 2 )
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 )
FreeLibrary( hDLL )
return nil
function WebView_SaveValues( cCalls, cJsonResult )
s_nCalls = Val( cCalls )
s_cJsonResult = cJsonResult
MsgInfo( s_nCalls, s_cJsonResult )
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>
<fieldget>
<label>username:</label>
<input type="text" id="user"></input><br><br>
<label>password:</label>
<input type="text" id="passwd"></input><br><br>
</fieldget>
<button id="submit" onclick='SendToFWH( GetValues() )'>Ok</button>
</body>
<script>
function GetValues() {
return { "username" : document.getElementById( "user" ).value,
"password" : document.getElementById( "passwd" ).value }
}
</script>
</html>
ENDTEXT
return cHtml
DLL FUNCTION WEBVIEW_CREATE( nDebug AS LONG, hWndParent AS LONG ) AS LONG PASCAL FROM "webview_create" LIB hDLL
DLL FUNCTION WEBVIEW_RUN( hWebView AS LONG ) AS VOID PASCAL FROM "webview_run" LIB hDLL
DLL FUNCTION WEBVIEW_NAVIGATE( hWebView AS LONG, cUrl AS LPSTR ) AS VOID PASCAL FROM "webview_navigate" LIB hDLL
DLL FUNCTION WEBVIEW_DESTROY( hWebView AS LONG ) AS VOID PASCAL FROM "webview_destroy" LIB hDLL
DLL FUNCTION WEBVIEW_BIND( hWebView AS LONG, cName AS LPSTR, pFunc AS LONG, pVoid AS LONG ) AS VOID PASCAL FROM "webview_bind" LIB hDLL
DLL FUNCTION WEBVIEW_EVAL( hWebView AS LONG, cJavaScript AS LPSTR ) AS VOID PASCAL FROM "webview_eval" LIB hDLL
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
#include <hbvm.h>
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
![Image](https://github.com/FiveTechSoft/screenshots/blob/master/webview_unitary.gif?raw=true)