Hi Antonio,
When is it released new version?
New Class TWebView in next FWH build
- Antonio Linares
- Site Admin
- Posts: 42597
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 40 times
- Been thanked: 86 times
- Contact:
Re: New Class TWebView in next FWH build
Hi Antonio,
Can we set starting x,y, which monitor and status bar TWebview class? (22.06)
Thanks
Can we set starting x,y, which monitor and status bar TWebview class? (22.06)
Thanks
Regards,
Hakan ONEMLI
Harbour & MSVC 2022 & FWH 23.04
Hakan ONEMLI
Harbour & MSVC 2022 & FWH 23.04
- Antonio Linares
- Site Admin
- Posts: 42597
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 40 times
- Been thanked: 86 times
- Contact:
Re: New Class TWebView in next FWH build
Dear Hakan,
You can use SetWindowPos( oWebView:GetWindow(), 0, nX, nY, nWidth, nHeight, 4 )
You can run any javascript so you can do this from your FWH app:
oWebView:Eval( "window.status = 'Some text in the status bar!!';" )
Regarding your monitor question please review this:
https://stackoverflow.com/questions/51822908/how-to-programmatically-start-an-application-on-a-specific-monitor-on-windows-10
You can use SetWindowPos( oWebView:GetWindow(), 0, nX, nY, nWidth, nHeight, 4 )
You can run any javascript so you can do this from your FWH app:
oWebView:Eval( "window.status = 'Some text in the status bar!!';" )
Regarding your monitor question please review this:
https://stackoverflow.com/questions/51822908/how-to-programmatically-start-an-application-on-a-specific-monitor-on-windows-10
- Giovany Vecchi
- Posts: 223
- Joined: Mon Jun 05, 2006 9:39 pm
- Location: Brasil
Re: New Class TWebView in next FWH build
Antonio, WebView is already working inside a dialog, windows or Panel?
- Antonio Linares
- Site Admin
- Posts: 42597
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 40 times
- Been thanked: 86 times
- Contact:
Re: New Class TWebView in next FWH build
Dear Giovany,
Yes, Class TWebView provides a Method SetParent( oWnd ) so you can make it child of any window, dialog or control
Yes, Class TWebView provides a Method SetParent( oWnd ) so you can make it child of any window, dialog or control

- Giovany Vecchi
- Posts: 223
- Joined: Mon Jun 05, 2006 9:39 pm
- Location: Brasil
Re: New Class TWebView in next FWH build
Antonio Linares wrote:Dear Giovany,
Yes, Class TWebView provides a Method SetParent( oWnd ) so you can make it child of any window, dialog or control
I was creating a class for this, but as I'm not an expert in C++, I stopped to wait for the native fivewin class.
In this class I was making I can put the webview in windows and even in Panels.
Code: Select all | Expand
#include "FiveWin.ch"
///#include "hbclass.ch"
#define HKEY_LOCAL_MACHINE 2147483650
#define SW_HIDE 0
#define SW_SHOW 5
#define GWL_STYLE -16
static nLeft := 0.1
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
FUNCTION WEB_VIEW_TST_WND_NATIVE()
Local lc_oWebViewFw
lc_oWebViewFw := WebViewFw():New()
lc_oWebViewFw:WebViewFw_Start()
lc_oWebViewFw:WebViewFw_Navigate("http://www.google.com.br")
lc_oWebViewFw:WebViewFw_Run()
lc_oWebViewFw:End()
RETURN NIL
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
FUNCTION WEB_VIEW_TST_WND_FW()
Local lc_oWndTst
Local lc_oWebViewFw
DEFINE WINDOW lc_oWndTst FROM 100, 100 TO 768, 1024 ;
PIXEL ;
TITLE "Teste WebView2"
lc_oWndTst:bInit := <||
lc_oWebViewFw := WebViewFw():New(lc_oWndTst)
lc_oWebViewFw:WebViewFw_Start()
lc_oWebViewFw:WebViewFw_Navigate("http://www.google.com.br")
lc_oWebViewFw:WebViewFw_Run()
Return Nil
>// cEnd
lc_oWndTst:bValid := <||
lc_oWebViewFw:End()
Return .T.
>//cEnd
ACTIVATE WINDOW lc_oWndTst NORMAL
RETURN NIL
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//Classe WebViewFw / 10/05/2022 - 16:45
Class WebViewFw
Data oWndDlgContainer
Data hWebView //As Pointer Init Nil
Data hWndWebView //As Pointer Init Nil
Data lStartRun As Logic Init .F. //Verifica a chamada de WEBVIEW_RUN
Method New(f_oWndDlgContainer) Constructor
Method End()
Method WebViewFw_Start()
Method WebViewFw_Run()
Method WebViewFw_Navigate(f_cUrlHtml)
Method WebViewFw_SetHtmlFile(f_cHtmlFile)
Method WebViewFw_Eval(f_cExpJavaScript)
EndClass
//-----------------------------------------------------------------------------
Method New(f_oWndDlgContainer) Class WebViewFw
::oWndDlgContainer := f_oWndDlgContainer
Return Self
//-----------------------------------------------------------------------------
Method End() Class WebViewFw
If !HB_ISNIL(::hWebView) .and. !HB_ISNIL(::oWndDlgContainer)
WEBVIEW_TERMINATE(::hWebView)
WEBVIEW_DESTROY(::hWebView)
SendMessage( ::hWebView, WM_CLOSE)
EndIf
Return Nil
//-----------------------------------------------------------------------------
Method WebViewFw_Start() Class WebViewFw
Local lc_nStyle
Local lc_nBarContainer_nHeight := 0
Local lc_lLoopReSize := .F.
If !Hb_IsNil(::oWndDlgContainer)
::hWebView := WEBVIEW_CREATE(,::oWndDlgContainer:hWnd)
::oWndDlgContainer:bResized := <||
If !lc_lLoopReSize
lc_lLoopReSize := .T.
hb_idleSleep(.001)
WEBVIEW_SET_SIZE(::hWebView, ::oWndDlgContainer:nWidth,;
::oWndDlgContainer:nHeight,0)
lc_lLoopReSize := .F.
EndIf
Return Nil
> //cEnd
Else
::hWebView := WEBVIEW_CREATE()
EndIf
Return Nil
//-----------------------------------------------------------------------------
Method WebViewFw_Run() Class WebViewFw
If !::lStartRun
WEBVIEW_RUN(::hWebView)
EndIf
::lStartRun := .T.
Return Nil
//-----------------------------------------------------------------------------
Method WebViewFw_Navigate(f_cUrlHtml,f_lMemoReadFile) Class WebViewFw
Local lc_cUrlHtml := ""
Default f_cUrlHtml := "http://www.google.com.br",;
f_lMemoReadFile := .F.
lc_cUrlHtml := f_cUrlHtml
If hb_FileExists(lc_cUrlHtml) .and. f_lMemoReadFile
lc_cUrlHtml := hb_MemoRead(lc_cUrlHtml)
EndIf
WEBVIEW_NAVIGATE(::hWebView,f_cUrlHtml)
Return Nil
//-----------------------------------------------------------------------------
Method WebViewFw_SetHtmlFile(f_cHtmlFile) Class WebViewFw
WEBVIEW_SET_HTML(::hWebView, f_cHtmlFile)
Return Nil
//-----------------------------------------------------------------------------
Method WebViewFw_Eval(f_cExpJavaScript)
Local lc_uReturn
WebView_Bind( ::hWebView, "SendToFWH", SendToFWHAddress(), ::hWebView )
? SENDTOFWHADDRESS()
lc_uReturn := WebView_Eval( ::hWebView, f_cExpJavaScript )
Return lc_uReturn
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
function WebView_SaveValues( cCalls, cJsonResult )
Local s_nCalls, s_cJsonResult
s_nCalls = Val( cCalls )
s_cJsonResult = cJsonResult
MsgInfo( s_nCalls, s_cJsonResult )
return nil
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
#include <hbvm.h>
#include <fwh.h>
// Window size hints
#define WEBVIEW_HINT_NONE 0 // Width and height are default size
#define WEBVIEW_HINT_MIN 1 // Width and height are minimum bounds
#define WEBVIEW_HINT_MAX 2 // Width and height are maximum bounds
#define WEBVIEW_HINT_FIXED 3 // Window size can not be changed by a user
void * webview_create(int debug, void * window );
void webview_run( void * w );
void webview_terminate( void * w);
void webview_destroy( void * w );
void webview_terminate(void * w);
void webview_dispatch( void * w, void * func, void *arg);
void webview_navigate( void * w, const char * url );
void webview_set_html( void * w, const char * html );
void webview_init( void * w, const char *js);
void webview_eval( void * w, const char * javascript );
void webview_bind( void * w, const char * name, void * func, void * pvoid );
void webview_unbind( void * w, const char * name);
void webview_return( void * w, const char * seq, int status, const char * result);
void webview_set_size( void * w, int width, int height,int hints);
int webview_get_window( void * w );
void webview_set_title( void * w, const char *title);
// Creates a new webview instance. If debug is non-zero - developer tools will
// be enabled (if the platform supports them). Window parameter can be a
// pointer to the native window handle. If it's non-null - then child WebView
// is embedded into the given parent window. Otherwise a new window is created.
// Depending on the platform, a GtkWindow, NSWindow or HWND pointer can be
// passed here.
HB_FUNC( WEBVIEW_CREATE )
{
INT iDebug = ( INT ) 0 ;
HWND hWnd = ( HWND ) fw_parH(2) ;
if ( HB_ISNUM( 2 ) )
hb_retptr( webview_create( iDebug , &hWnd ));
else
hb_retptr( webview_create( iDebug , 0 ));
}
// Runs the main loop until it's terminated. After this function exits - you
// must destroy the webview.
HB_FUNC( WEBVIEW_RUN )
{
webview_run( hb_parptr( 1 ) );
}
// Destroys a webview and closes the native window.
HB_FUNC( WEBVIEW_DESTROY )
{
webview_destroy( hb_parptr( 1 ) );
}
// Stops the main loop. It is safe to call this function from another other
// background thread.
HB_FUNC( WEBVIEW_TERMINATE )
{
webview_terminate( hb_parptr( 1 ) );
}
// Posts a function to be executed on the main thread. You normally do not need
// to call this function, unless you want to tweak the native window.
HB_FUNC( WEBVIEW_DISPATCH )
{
webview_dispatch( hb_parptr( 1 ), hb_parptr( 2 ), hb_parptr( 3 ) );
//webview_bind( hb_parptr( 1 ), hb_parc( 2 ), hb_parptr( 3 ), hb_parptr( 4 ) );
}
// Navigates webview to the given URL. URL may be a data URI, i.e.
// "data:text/html,<html>...</html>". It is often ok not to url-encode it
// properly, webview will re-encode it for you.
HB_FUNC( WEBVIEW_NAVIGATE )
{
webview_navigate( hb_parptr( 1 ), hb_parc( 2 ) );
}
// Set webview HTML directly.
HB_FUNC( WEBVIEW_SET_HTML )
{
webview_set_html( hb_parptr( 1 ), hb_parc( 2 ) );
}
// Injects JavaScript code at the initialization of the new page. Every time
// the webview will open a the new page - this initialization code will be
// executed. It is guaranteed that code is executed before window.onload.
HB_FUNC( WEBVIEW_INIT )
{
webview_init( hb_parptr( 1 ), hb_parc( 2 ) );
}
// Evaluates arbitrary JavaScript code. Evaluation happens asynchronously, also
// the result of the expression is ignored. Use RPC bindings if you want to
// receive notifications about the results of the evaluation.
HB_FUNC( WEBVIEW_EVAL )
{
webview_eval( hb_parptr( 1 ), hb_parc( 2 ) ) ;
}
// Binds a native C callback so that it will appear under the given name as a
// global JavaScript function. Internally it uses webview_init(). Callback
// receives a request string and a user-provided argument pointer. Request
// string is a JSON array of all the arguments passed to the JavaScript
// function.
HB_FUNC( WEBVIEW_BIND )
{
webview_bind( hb_parptr( 1 ), hb_parc( 2 ), hb_parptr( 3 ), hb_parptr( 4 ) );
}
// Removes a native C callback that was previously set by webview_bind.
HB_FUNC( WEBVIEW_UNBIND )
{
webview_unbind( hb_parptr( 1 ), hb_parc( 2 ) );
}
// Allows to return a value from the native binding. Original request pointer
// must be provided to help internal RPC engine match requests with responses.
// If status is zero - result is expected to be a valid JSON result value.
// If status is not zero - result is an error JSON object.
HB_FUNC( WEBVIEW_RETURN )
{
webview_return( hb_parptr( 1 ), hb_parc( 2 ), hb_parni( 3 ), hb_parc( 4 ) );
}
// Updates native window size. See WEBVIEW_HINT constants.
HB_FUNC( WEBVIEW_SET_SIZE ) // Handle WebView, int width, int height, int hints
{
webview_set_size( hb_parptr( 1 ), hb_parni( 2 ), hb_parni( 3 ), hb_parni( 4 ) );
}
// Returns a native window handle pointer. When using GTK backend the pointer
// is GtkWindow pointer, when using Cocoa backend the pointer is NSWindow
// pointer, when using Win32 backend the pointer is HWND pointer.
HB_FUNC( WEBVIEW_GET_WINDOW )
{
hb_retni( webview_get_window( hb_parptr( 1 ) ) );
}
// Updates the title of the native window. Must be called from the UI thread.
HB_FUNC( WEBVIEW_SET_TITLE )
{
webview_set_title( 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
- Antonio Linares
- Site Admin
- Posts: 42597
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 40 times
- Been thanked: 86 times
- Contact:
Re: New Class TWebView in next FWH build
Dear Giovany,
Good work
Your implementation forces to have webview.dll accessible and webview.dll it is not accessible on all Windows versions
Thats why FWH uses dynamic linking instead of static linking, so the FWH app works fine no matter if webview.dll can be loaded or not
Good work

Your implementation forces to have webview.dll accessible and webview.dll it is not accessible on all Windows versions
Thats why FWH uses dynamic linking instead of static linking, so the FWH app works fine no matter if webview.dll can be loaded or not
- Giovany Vecchi
- Posts: 223
- Joined: Mon Jun 05, 2006 9:39 pm
- Location: Brasil
Re: New Class TWebView in next FWH build
Yes, I couldn't put it in window or panels without using the static dll. I didn't try with hb_DynCall passing the variable with &. In several windows 7 it gives an error in the system entry. On Windows 10 it works correctly.