Antonio buenas tardes, como estas?
Como hacemos para identificar si la maquina (PC), esta lista para correr webview?
De antemano gracias
function IsWebViewAvailable()
local hDLL := LoadLibrary( "webview.dll" )
local lAvailable := hDLL != 0
if lAvailable
FreeLibrary( hDLL )
endif
return lAvailable
Application
===========
Path and name: C:\fwh2304\samples\webviewlogin.exe (32 bits)
Size: 4,197,376 bytes
Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20221118)
FiveWin version: FWH 23.04
C compiler version: Borland/Embarcadero C++ 7.4 (32-bit)
Windows 11 64 Bits, version: 6.2, Build 9200
Time from start: 0 hours 0 mins 0 secs
Error occurred at: 07/05/23, 06:33:50
Error description: Error BASE/1072 Argument error: <>
Args:
[ 1] = P 0x71680000
[ 2] = N 0
Stack Calls
===========
Called from: webviewlogin.prg => ISWEBVIEWAVAILABLE( 209 )
Called from: webviewlogin.prg => MAIN( 9 )
// Please install https://developer.microsoft.com/en-us/m ... /webview2/ x86 version before using it
#include "FiveWin.ch"
function Main()
local oWebView := TWebView():New()
local lReady := IsWebViewAvailable()
msginfo(lReady)
oWebView:SetHtml( Html() )
oWebView:SetTitle( "Please identify with your credentials" )
oWebView:SetSize( 1200, 800 )
oWebView:SetUserAgent( "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Mobile Safari/537.36" )
oWebView:Bind( "SendToFWH" )
oWebView:bOnBind = { | cJson, cCalls | Login( cJson, cCalls, oWebView ) }
sleep( 300 )
oWebView:Run()
oWebView:Destroy()
return nil
function Login( cJson, cCalls, oWebView )
local hData
hb_jsonDecode( cJson, @hData )
if hData[ 1 ][ "username" ] != "Antonio" .or. hData[ 1 ][ "password" ] != "1234"
oWebView:Return( cCalls, 0, "{ 'result': 'incorrect values' }" )
else
oWebView:Return( cCalls, 0, "{ 'result': 'correct!' }" )
endif
return nil
function Html()
local cHtml
TEXT INTO cHtml
<!DOCTYPE html>
<html>
<head>
<title>Identify</title>
<style>
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
background-color: #F2F2F2;
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
.container {
max-width: 400px;
margin: 0 auto;
padding: 40px;
background-color: #FFFFFF;
border-radius: 5px;
display: flex;
flex-direction: column;
align-items: center;
box-shadow: 0px 0px 44px rgba(0, 0, 0, 0.7) !important;
overflow:none !important;
}
.logo {
margin-bottom: 40px;
display: flex;
align-items: center;
}
.logo img {
max-width: 100%;
height: auto;
}
.btn {
display: inline-block;
padding: 12px 24px;
background-color: #4CAF50;
color: #FFFFFF;
font-size: 16px;
text-decoration: none;
border-radius: 5px;
transition: background-color 0.3s ease;
}
.btn:hover {
background-color: #45A049;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
font-size: 16px;
font-weight: bold;
margin-bottom: 5px;
color: #333333;
}
.form-group input {
width: 100%;
padding: 12px;
font-size: 16px;
border-radius: 5px;
border: 1px solid #CCCCCC;
}
.btn {
display: inline-block;
padding: 12px 24px;
background-color: #4CAF50;
color: #FFFFFF;
font-size: 16px;
text-decoration: none;
border-radius: 5px;
transition: background-color 0.3s ease;
}
.btn:hover {
background-color: #45A049;
}
body {
background-color: #3498db;
}
.btn {
background-color: #2980b9;
}
.btn:hover {
background-color: #1a5276;
.logo {
margin-bottom: 40px;
}
.logo img {
max-width: 100%;
height: auto;
}
}
.myinput {
width: auto !important;
}
.mybtn {
text-align:center;
}
</style>
</head>
<body>
<div class="container">
<div class="logo">
<img src="https://fivetechsupport.com/forums/styles/prosilver/imageset/site_logo.gif" alt="Logo">
</div>
<form id="login-form" action="#" method="POST">
<div class="form-group">
<label for="username">Username:</label>
<input type="text" id="username" name="username" class="myinput" required>
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" id="password" name="password" class="myinput" required>
</div>
<div class="form-group mybtn" >
<button type="submit" class="btn">Iniciar sesión</button>
</div>
</form>
</div>
<script>
document.getElementById('login-form').addEventListener('submit', function(event) {
event.preventDefault();
var username = document.getElementById('username').value;
var password = document.getElementById('password').value;
var data = {
username: username,
password: password
};
var s = SendToFWH(data).then( s => { alert(s.result); } );
});
</script>
</body>
</html>
ENDTEXT
return cHtml
function IsWebViewAvailable()
local hDLL := LoadLibrary( "webview.dll" )
local lAvailable := hDLL != 0
if lAvailable
FreeLibrary( hDLL )
endif
return lAvailable
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: karinha, nageswaragunupudi, Willi Quintana and 45 guests