Antonio Linares wrote:Dear Randal,
Please review FWH\samples\webviewuni.prg
#include "FiveWin.ch"
function Main()
local oWnd
DEFINE WINDOW oWnd
MsgInfo( Test( oWnd:hWnd ) )
ACTIVATE WINDOW oWnd CENTERED
return nil
#pragma BEGINDUMP
#include <Windows.h>
#include <ExDisp.h>
#include <hbapi.h>
HB_FUNC( TEST )
{
IWebBrowser2 * webView2;
BSTR url;
VARIANT emptyVar;
HWND hWnd;
CoInitialize(NULL);
CoCreateInstance( &CLSID_WebBrowser, NULL, CLSCTX_INPROC_SERVER, &IID_IWebBrowser2, (void**) &webView2 );
url = SysAllocString(L"https://www.google.com");
VariantInit( &emptyVar );
webView2->lpVtbl->Navigate( webView2, url, &emptyVar, &emptyVar, &emptyVar, &emptyVar);
SysFreeString(url);
webView2->lpVtbl->get_HWND( webView2, ( LONG_PTR * ) &hWnd );
SetParent( hWnd, ( HWND ) hb_parnll( 1 ) );
webView2->lpVtbl->put_Visible( webView2, VARIANT_TRUE );
SetForegroundWindow( hWnd );
hb_retptr( webView2 );
}
#pragma ENDDUMP
void run() {
MSG msg;
BOOL res;
bRunning = TRUE;
while ( bRunning && (res = GetMessage(&msg, nullptr, 0, 0)) != -1) {
if (msg.hwnd) {
TranslateMessage(&msg);
DispatchMessage(&msg);
continue;
}
if (msg.message == WM_APP) {
auto f = (dispatch_fn_t *)(msg.lParam);
(*f)();
delete f;
}
}
}
The other problem I have is when you call TWebview:New() a blank window is displayed momentarily before my dialog is displayed. I saw a reference to this in past posts however, I didn't not see any fix that addresses this. You can see this in the webview.prg and webview5.prg samples also.
#include "FiveWin.ch"
function Main()
local oWnd, oWebView
DEFINE WINDOW oWnd TITLE "Using a webview from an existing window"
oWnd:Center()
oWebView = TWebView():New(, oWnd:hWnd )
oWebView:Navigate( "http://www.google.com" )
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" )
ACTIVATE WINDOW oWnd CENTER ;
ON RESIZE If( nWidth != nil, oWebView:SetSize( nWidth, nHeight ), oWebView:SetSize( 800, 500 ) )
oWebView:Destroy()
return nil
#include "FiveWin.ch"
function Main()
local oDlg, oWebView
DEFINE DIALOG oDlg SIZE 1200, 700
ACTIVATE DIALOG oDlg CENTER ;
ON INIT ( oWebView := TWebView():New( , oDlg:hWnd ),;
oWebView:Navigate( "http://www.google.com" ), .T. )
return nil
Antonio Linares wrote:Here you have the updated webview DLLs:
https://github.com/FiveTechSoft/FWH_tools/blob/master/fivetech_webview.zip
Please test them using FWH\samples\webview.prg and webview5.prg
In webview5.prg you can check how closing the webview does not closes the FWH app!
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 69 guests