Hola,
Aqui tiene un ejemplo:
#include "FiveWin.ch"
#ifndef GW_CHILD
#define GW_CHILD 5
#endif
function Main()
local oWnd, oWebView
define window oWnd title "WebView" SIZE 1500, 1000
oWebView = TWebView2():New( oWnd )
oWebView:Navigate( openLocalFile( hb_dirBase() + "login.html" ) )
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" )
setFocus( GetWindow( oWnd:hWnd, GW_CHILD ) )
activate window oWnd center;
on resize oWebView:SetSize( nWidth, nHeight )
return nil
function openLocalFile( cFile )
local cUrl := hb_dirTemp() + "index.html"
hb_memoWrit( cUrl, hb_memoRead( cFile ) )
cUrl := urlEncode( "file:///" + strtran( cUrl, "\", "/" ) )
cUrl := strtran( cUrl, "+", "%20" )
cUrl := strtran( cUrl, " ", "%20" )
cUrl := strtran( cUrl, "%3A", ":" )
return cUrl
#pragma BEGINDUMP
#include <hbvm.h>
#include <hbapi.h>
#include <hbapiitm.h>
#include <hbapierr.h>
HB_FUNC( URLENCODE )
{
const char * cData = hb_parc( 1 );
HB_ISIZ nLen = hb_parclen( 1 );
HB_BOOL bComplete = hb_parldef( 2, HB_TRUE );
char * cRet;
HB_ISIZ nPos = 0, nPosRet = 0, nVal;
char cElem;
if( ! cData )
{
hb_errRT_BASE( EG_ARG, 3012, NULL,
HB_ERR_FUNCNAME, 1, hb_paramError( 1 ) );
return;
}
if( ! nLen )
{
hb_retc_null();
return;
}
/* Giving maximum final length possible */
cRet = ( char * ) hb_xgrab( nLen * 3 + 1 );
while( nPos < nLen )
{
cElem = cData[ nPos ];
if( cElem == ' ' )
{
cRet[ nPosRet ] = '+';
}
else if(
( cElem >= 'A' && cElem <= 'Z' ) ||
( cElem >= 'a' && cElem <= 'z' ) ||
( cElem >= '0' && cElem <= '9' ) ||
cElem == '.' || cElem == ',' || cElem == '&' ||
cElem == '/' || cElem == ';' || cElem == '_' )
{
cRet[ nPosRet ] = cElem;
}
else if( ! bComplete && ( cElem == ':' || cElem == '?' || cElem == '=' ) )
{
cRet[ nPosRet ] = cElem;
}
else /* encode! */
{
cRet[ nPosRet++ ] = '%';
nVal = ( ( HB_UCHAR ) cElem ) >> 4;
cRet[ nPosRet++ ] = nVal < 10 ? '0' + ( char ) nVal : 'A' + ( char ) nVal - 10;
nVal = ( ( HB_UCHAR ) cElem ) & 0x0F;
cRet[ nPosRet ] = nVal < 10 ? '0' + ( char ) nVal : 'A' + ( char ) nVal - 10;
}
nPosRet++;
nPos++;
}
hb_retclen_buffer( cRet, nPosRet );
}
#pragma ENDDUMP
login.html
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Inicio de Sesi贸n</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.login-container {
background-color: white;
padding: 2rem;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 400px;
}
.login-container h2 {
text-align: center;
color: #333;
margin-bottom: 1.5rem;
}
.form-group {
margin-bottom: 1rem;
}
label {
display: block;
margin-bottom: 0.5rem;
color: #555;
font-weight: bold;
}
input[type="text"],
input[type="password"] {
width: 100%;
padding: 0.75rem;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 1rem;
box-sizing: border-box;
}
input[type="text"]:focus,
input[type="password"]:focus {
outline: none;
border-color: #4CAF50;
box-shadow: 0 0 5px rgba(76, 175, 80, 0.3);
}
.btn-login {
width: 100%;
background-color: #4CAF50;
color: white;
padding: 0.75rem;
border: none;
border-radius: 4px;
font-size: 1rem;
cursor: pointer;
margin-top: 1rem;
}
.btn-login:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="login-container">
<h2>Iniciar Sesi贸n</h2>
<form action="/login" method="POST" id="loginForm">
<div class="form-group">
<label for="username">Nombre de usuario:</label>
<input type="text" id="username" name="username" autofocus required>
</div>
<div class="form-group">
<label for="password">Contrase帽a:</label>
<input type="password" id="password" name="password" required>
</div>
<button type="submit" class="btn-login">Iniciar Sesi贸n</button>
</form>
</div>
<script>
// Funcionalidad de demostraci贸n (opcional)
document.getElementById('loginForm').addEventListener('submit', function (e) {
e.preventDefault(); // Prevenir env铆o para demostraci贸n
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
if (username && password) {
alert('Login exitoso!\nUsuario: ' + username);
}
});
function setFocus(elementId) {
const el = document.getElementById(elementId);
if (el) {
el.focus()
el.click()
}
}
setTimeout(function(){ setFocus('username');},3*1000);
</script>
</body>
</html>