
I load images and save on a Hash
then I use on html {IMGHOME} then replace the images before to release the chtml
If the images are on resources not load the images
I tried also with
hImages["IMGHOME"] := "data:image/png;base64," + hb_base64encode( GetResources("DASH_HOME") )
Please try this test
test.prg
Code: Select all | Expand
#include "fivewin.ch"
function Main()
local oWnd, oWebView
DEFINE WINDOW oWnd TITLE "Invoicing"
BuildMainBar(oWnd)
oWebView := TWebView2():New( oWnd )
oWebView:SetHtml( Html() )
SET MESSAGE OF oWnd TO "Invoicing app" CENTER NOINSET
ACTIVATE WINDOW oWnd ;
ON RESIZE ( oWebView:SetSize( WndWidth( oWebView:oWnd:hWnd ) - 17,;
WndHeight( oWebView:oWnd:hWnd ) - 80 ) )
RETURN NIL
Function Html()
LOCAL hImages := LoadImages() // Carica l'hash delle immagini
LOCAL cHtml
LOCAL cKey
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="{IMGHOME}" alt="Home">
</div>
</div>
</body>
</html>
ENDTEXT
FOR EACH cKey IN hImages:Keys
cHtml := StrTran(cHtml, "{" + cKey + "}", hImages[cKey])
NEXT
return cHtml
Function LoadImages()
LOCAL hImages := {=>}
hImages["IMGHOME"] := "data:image/png;base64," + hb_base64encode( hb_memoRead( "DASH_HOME" ) )
RETURN hImages
static function BuildMainBar(oWnd)
local oBar
DEFINE BUTTONBAR oBar OF oWnd 2015 SIZE 90, 60
return nil
test.rc (please put your image)
Code: Select all | Expand
1 24 "WindowsXP.Manifest"
DASH_HOME 10 "dashboard/home.png"
try with
Function LoadImages()
LOCAL hImages := {=>}
LOCAL cImageData := GetResources("DASH_HOME")
IF Empty(cImageData) .OR. ValType(cImageData) != "C"
MsgInfo("Error!")
ELSE
hImages["IMGHOME"] := "data:image/png;base64," + hb_base64encode(cImageData)
ENDIF
RETURN hImages