WebView window
WebView window
Hi,
The window of the WebView object creates a window. Is it possible to make the WebView open in a hidden form (without a window appearing on the screen) ?
The window of the WebView object creates a window. Is it possible to make the WebView open in a hidden form (without a window appearing on the screen) ?
- Antonio Linares
- Site Admin
- Posts: 42268
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: WebView window
You can make it children of another window so it will behave as a control
Or do you want it totally hidden ?
Or do you want it totally hidden ?
Re: WebView window
That's what I do. But this does not solve the problem of the window appearing (at least for 1 second) when creating a WebView
Re: WebView window
hi,
you can use "negative" Position at "Create" and later "move" to new Position / Parent
you can use "negative" Position at "Create" and later "move" to new Position / Parent
greeting,
Jimmy
Jimmy
- Antonio Linares
- Site Admin
- Posts: 42268
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: WebView window
Dear Jimmy,
He won't be able to do that as WebView_Create() called from TWebView():New() does not allow the use of coordinates
Maybe this may work:
#define SW_HIDE 0
#define SW_NORMAL 1
local oWebView := TWebView():New()
ShowWindow( oWebView:GetWindow(), SW_HIDE )
... then do the required startup code and finally:
ShowWindow( oWebView:GetWindow(), SW_NORMAL )
He won't be able to do that as WebView_Create() called from TWebView():New() does not allow the use of coordinates
Maybe this may work:
#define SW_HIDE 0
#define SW_NORMAL 1
local oWebView := TWebView():New()
ShowWindow( oWebView:GetWindow(), SW_HIDE )
... then do the required startup code and finally:
ShowWindow( oWebView:GetWindow(), SW_NORMAL )
Re: WebView window
Trying to execute this program:
The code block :bOnBind does not work. What am I doing wrong ?
Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local oWebKds := TWebView():New()
oWebKds := TWebView():New()
oWebKds:bOnBind = { | cJson, nCalls | MsgInfo( cJson, nCalls ) }
oWebKds:Bind( "SendKds" )
cUrl:="https://www.google.com"
buf:='function Kds_Url() { SendKds(document.body.innerHTML) } ;'+CRLF+ ;
'window.location.href="'+cUrl+'" ;'+CRLF+ ;
'Kds_Url() ;'
DEFINE DIALOG oKds FROM 0,0 TO 400,400 PIXEL ;
STYLE nOR(WS_POPUP) COLOR CLR_BLACK, CLR_WHITE
ACTIVATE DIALOG oKds ON PAINT (oWebKds:SetParent(oKds), oWebKds:Eval(buf))
return
- Antonio Linares
- Site Admin
- Posts: 42268
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: WebView window
This works fine:
Are trying to add javascript code to an exiting web site ?
Code: Select all | Expand
#include "FiveWin.ch"
//----------------------------------------------------------------------------//
function Main()
local oWebView := TWebView():New()
oWebView:bOnBind = { | cJson, nCalls | MsgInfo( cJson, nCalls ) }
oWebView:Bind( "SendToFWH" )
oWebView:Navigate( Html() )
Sleep( 200 )
oWebView:Run()
oWebView:Destroy()
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>
<button onclick='SendToFWH( 123 )'>Call FWH app from web browser</button>
<button onclick='SendToFWH( 456 )'>Test 2</button>
<button onclick='SendToFWH( document.body.innerHTML )'>Test 3</button>
</body>
</html>
ENDTEXT
return cHtml
//----------------------------------------------------------------------------//
- Antonio Linares
- Site Admin
- Posts: 42268
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: WebView window
Another example using Class TWebView Method Eval():
Code: Select all | Expand
#include "FiveWin.ch"
//----------------------------------------------------------------------------//
function Main()
local oWebView := TWebView():New()
oWebView:bOnBind = { | cJson, nCalls | MsgInfo( cJson, nCalls ) }
oWebView:Bind( "SendToFWH" )
oWebView:Navigate( Html() )
Sleep( 200 )
oWebView:Eval( "SendToFWH( document.body.innerHTML )" )
oWebView:Run()
oWebView:Destroy()
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>
<button onclick='SendToFWH( 123 )'>Call FWH app from web browser</button>
<button onclick='SendToFWH( 456 )'>Test 2</button>
<button onclick='SendToFWH( document.body.innerHTML )'>Test 3</button>
</body>
</html>
ENDTEXT
return cHtml
//----------------------------------------------------------------------------//
Re: WebView window
Yes, I need to make frequent site requests and read the changes. This is a very convenient algorithm for me and I do not understand why in this case the code block :bonBind does not work
the oWebKds:SetParent() method works, but the oWebKds:Eval() method does not
the oWebKds:SetParent() method works, but the oWebKds:Eval() method does not
- Antonio Linares
- Site Admin
- Posts: 42268
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: WebView window
This is working fine:
Code: Select all | Expand
#include "FiveWin.ch"
//----------------------------------------------------------------------------//
function Main()
local oWebView := TWebView():New()
oWebView:bOnBind = { | cJson, nCalls | MsgInfo( cJson, nCalls ) }
oWebView:Bind( "SendToFWH" )
oWebView:Navigate( "https://www.fivetechsoft.com" )
Sleep( 200 )
oWebView:Eval( "SendToFWH( document.body.innerHTML )" )
oWebView:Run()
oWebView:Destroy()
return nil
//----------------------------------------------------------------------------//
Re: WebView window
Try with
Code: Select all | Expand
ACTIVATE DIALOG oKds ON INIT ( oWebKds:SetParent(oKds), Sleep( 300 ) ) ON PAINT ( oWebKds:Eval(buf) )
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Re: WebView window
I checked, nothing has changed
Re: WebView window
Consider the following:
- The change in the content of the oWebView control does not cause the Paint event of the dialog to be executed
- In your javascript code, you are causing a recursive call to the same function.
I want to check that your code ( Eval() ) is executed? ( assuming there is no error in that code )
Change your code and resize dialog
If you want that function defined in ON PAINT to be executed, one of the possible options is to use a TIMER
- The change in the content of the oWebView control does not cause the Paint event of the dialog to be executed
- In your javascript code, you are causing a recursive call to the same function.
I want to check that your code ( Eval() ) is executed? ( assuming there is no error in that code )
Change your code and resize dialog
Code: Select all | Expand
DEFINE DIALOG oDlg FROM 0,0 TO 400,400 PIXEL TRUEPIXEL RESIZABLE
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Re: WebView window
I tried to write like this:
Three windows appear:
1-DIALOG "Test"
2-webview with GOOGLE.COM
3-webview is empty
Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local oWebKds := TWebView():New()
oWebKds := TWebView():New()
oWebKds:bOnBind = { | cJson, nCalls | MsgInfo( cJson, nCalls ) }
oWebKds:Bind( "SendKds" )
cUrl:="https://www.google.com"
buf:='function Kds_Url() { SendKds(document.body.innerHTML) } ;'+CRLF+ ;
'window.location.href="'+cUrl+'" ;'+CRLF+ ;
'document.addEventListener("DOMContentLoaded", Kds_Url()) ;'
DEFINE DIALOG oKds FROM 0,0 TO 400,400 PIXEL TRUEPIXEL RESIZABLE TITLE "Test"
ACTIVATE DIALOG oKds ON PAINT (sleep(200), oWebKds:Eval(buf))
return
1-DIALOG "Test"
2-webview with GOOGLE.COM
3-webview is empty
- Antonio Linares
- Site Admin
- Posts: 42268
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: WebView window
You are calling TWebView():New() twice
why ?
why ?