Page 1 of 2

html5 IE gadget project

Posted: Wed Jun 13, 2018 9:07 am
by idle
Webview is a small cross platform c lib of embedding a browser supporting JS and CSS injection with two way coms.
It's not a gadget yet but just a test before I turn it into a gadget for a larger embedded web server project.
I'd like to get some feedback, does it work as expected.
It should launch a webview to an animated html5 page @ https://html5up.net/hyperspace
Once closed it should then show a webview with two clickable buttons that will pop up alerts of the button you clicked.

note don't set the compiler to compile in the current directory as it will quirk back to IE4 :?
though you can create the executable there and run it.

Does it work on win7 or Win8 with it's default browser?

Files are here, save and open webview.pbi compile with x86

https://www.dropbox.com/sh/ali08ef86qa2 ... 61Zra?dl=0

Webview also supports linux and osx and the two way coms feature opens up the possibility to create workable html guis
if your not adverse to javascript, could also use spiderbasic

c source files here
https://github.com/zserge/webview

Re: html5 IE gadget project

Posted: Wed Jun 13, 2018 10:24 am
by Kwai chang caine
Hello IDLE :D
I run your code and it search "Ressource.rc"
I remove the "Ressource.rc" in the compiler panel and apparently that works 8)

Image

I'm on W7 x86 / v5.61 x86 :wink:
Thanks for sharing 8)

Re: html5 IE gadget project

Posted: Wed Jun 13, 2018 10:46 am
by idle
What no Gif ! :mrgreen:

Thanks for testing, what version of windows did you try it on kcc?

I updated the file and remoed the rc manifest reference.

Re: html5 IE gadget project

Posted: Wed Jun 13, 2018 10:56 am
by chi
Finally :P
Image

Works on Win7 x64 (SP1) with PB 5.70b1 x86! Keep up the good work ^^

Re: html5 IE gadget project

Posted: Wed Jun 13, 2018 11:08 am
by idle
chi wrote:Finally :P
Image

Works on Win7 x64 (SP1) with PB 5.70b1 x86! Keep up the good work ^^
Finally indeed. and that beats a gif! :lol:

Re: html5 IE gadget project

Posted: Wed Jun 13, 2018 11:15 am
by Kiffi
Hello idle,

well done! Kudos! Image

Works on Windows 7 (64bit) like a charm. :D

(i will test it later in the evening with Linux Mint)

Greetings ... Peter

Re: html5 IE gadget project

Posted: Wed Jun 13, 2018 11:26 am
by idle
Kiffi wrote:Hello idle,

well done! Kudos! Image

Works on Windows 7 (64bit) like a charm. :D

(i will test it later in the evening with Linux Mint)

Greetings ... Peter
Hi Kiffi, you might need to change the def of webview_api to
#define WEBVIEW_API __declspec(dllexport)
and add
#include <stdio.h>
#include <tchar.h>

Re: html5 IE gadget project

Posted: Thu Jun 14, 2018 2:10 pm
by Kwai chang caine
MASTER Idle wrote:What no Gif ! :mrgreen:
:lol: :lol:
MASTER Idle wrote:Thanks for testing
Always a pleasure to read you, and test your jewels codes, my friend of the other side of the world, 8) where there is no kangarou :oops: :lol:
MASTER Idle wrote:what version of windows did you try it on kcc?
You are so surprising to not see GIF, that apparently you not see too, my config writing above :lol:
Your fan above wrote:I'm on W7 x86 / v5.61 x86 :wink:

Re: html5 IE gadget project

Posted: Thu Jun 14, 2018 5:48 pm
by juror
A series of 5 or 6 JScript errors on my system as it loads. Occasional errors on other functions. Blank HTML window with "Can't reach this page upon closing. Very encouraging so far.

cheers

W10 x64
PB 32 5.6

Re: html5 IE gadget project

Posted: Thu Jun 14, 2018 10:11 pm
by idle
juror wrote:A series of 5 or 6 JScript errors on my system as it loads. Occasional errors on other functions. Blank HTML window with "Can't reach this page upon closing. Very encouraging so far.

cheers

W10 x64
PB 32 5.6
Did you build it as an exe and run it?
Compiling with F5 will result in it quirking back to IE4, I suspect it's an inherited manifest issue.
I'm on w10 x64 compiled with PB 5.62 x86

Re: html5 IE gadget project

Posted: Thu Jun 14, 2018 10:40 pm
by juror
"Create executable" - in it's own folder with the dll and lib files

line 2
char 6997
Unable to get property 'create element' of undefined or null reference
code 0
URL htps://html5up.net/uploads/demos/hyperspace/assets/js/jquery.min.js
do you want to continue running scripts

get it 5 or 6 times - each with a slightly different line/char

when the page does open
script error https//platform.twitter.com/widgets.js?1529011964999

I do run an ad blocker in chrome, which is my main browser.

cheers
(hope there are no typos above)

Re: html5 IE gadget project

Posted: Fri Jun 15, 2018 2:23 am
by idle
Thanks for testing it Juror, odd that it's still quirking on your system.
I found that by setting the Feature_Browser_Emulation in the host application directly worked with F5 compile
It's being set in the dll but maybe it's not working as expected when it's hosted.

Can you try this, It will set the compatibility to IE 9 which should be OK for html5

plus if you have no script set in IE that could possibly be another explanation?

Code: Select all

PrototypeC webview_external_invoke_cb_t(*webview,arg.s)
PrototypeC webview_dispatch_fn(*webview,arg.s) ;


Structure webview_priv 
	hwnd.i;
	*browser 
	is_fullscreen.i;
	saved_style.l;
	saved_ex_style.l;
	saved_rect.RECT ;
EndStructure 

Structure webview 
	url.s
	title.s;
	width.l;
	height.l;
	resizable.l;
	nDebug.l;
	*external_invoke_cb.webview_external_invoke_cb_t ;
	priv.webview_priv;
	*userdata;
EndStructure ;

Structure webview_dispatch_arg
	*fn.webview_dispatch_fn;
	*webview.webview;
	*arg;
EndStructure ;

#WEBVIEW_DIALOG_TYPE_OPEN = 0
#WEBVIEW_DIALOG_TYPE_SAVE = 1
#WEBVIEW_DIALOG_TYPE_ALERT = 2

ImportC "webview.lib" 
  webview.l(title.s,url.s,width.l,height.l,resizable.l);
  webview_init.l(*webview.webview)
  webview_loop.l(*webview.webview,blocking.l);
  webview_eval.l(*webview.webview,*js.p-utf8);
  webview_inject_css.l(*webview.webview,css.s);
  webview_set_title.l(*webview.webview,title.s);
  webview_set_fullscreen(*webview.webview,fullscreen.l);
  webview_set_color(*webview.webview,r.a,g.a,b.a,a.a);
  webview_dialog(*webview.webview,webview_dialog_type,flags.l,title.s,arg.s,*result.string,resultsz.i);
  webview_dispatch(*webview.webview,*fn.webview_dispatch_fn,*arg);
  webview_terminate(*webview.webview);
  webview_exit(*webview.webview);
  webview_debug(format.s,*args,*args1=0,*args2=0,*args3=0,*args4=0,*args5=0,*args6=0,*args7=0,*args8=0);
  webview_print_log(*s.string); 
EndImport   

Procedure SetFeature_Browser_Emulation() 
  Protected lpValueName.s,lpData.l,phkResult
  lpValueName.s = GetFilePart(ProgramFilename()) 
  lpData = $9000;11001 ;9000 
  If RegCreateKeyEx_(#HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", 0, #Null, #REG_OPTION_VOLATILE, #KEY_ALL_ACCESS, #Null, @phkResult, @lpdwDisposition) = #ERROR_SUCCESS
    RegSetValueEx_(phkResult, lpValueName, 0, #REG_DWORD, @lpData, SizeOf(LONG))
    RegCloseKey_(phkResult)
  EndIf 
EndProcedure 

Procedure DelFeature_Browser_Emulation() 
  Protected phkResult,lpValueName.s  
  lpValueName.s = GetFilePart(ProgramFilename()) 
  If RegOpenKeyEx_(#HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", 0, #KEY_SET_VALUE, @phkResult) = #ERROR_SUCCESS
      RegDeleteValue_(phkResult, lpValueName)
      RegCloseKey_(phkResult)
  EndIf
EndProcedure   


ProcedureC WebviewEval(*wv,*arg)
  Protected *msg,input.s 
  input = PeekS(*arg,-1,#PB_UTF8)
  *msg = UTF8("alert('You clicked " + input + "');")
  ;it's safe to call webview_eval now 
  webview_eval(*wv,*msg);
  
EndProcedure   

ProcedureC CBExternInvoke(*wv,*arg) 
  ;webview called this function  
  Debug PeekS(*arg,-1,#PB_UTF8) 
  ;passes the function pointer to the browser which then calls the function when its ready
  webview_dispatch(*wv,@webvieweval(),*arg)  
EndProcedure   

Global wv.webview 

SetFeature_Browser_Emulation()

;if you just want to display a page, blocks until window is closed no interaction 
webview("PB_WebView: Supports HTML5","https://html5up.net/hyperspace",800,600,1) 
;webview("PB_WebView: Supports HTML5","http://localhost:8080",800,600,1) 

dir.s = GetCurrentDirectory() ; open webview.pbi from explorer should set it 

;if you want a bit more control 
wv\title = "PB_WebView Demo 2 way comms" 
wv\width = 800 
wv\height = 600 
wv\resizable = 1 
wv\url = "file://" + dir + "index.html" 
wv\resizable =1 
wv\external_invoke_cb = @CBExternInvoke()
  
webview_init(@wv)

While webview_loop(@wv,1) = 0  
Wend 
webview_exit(@wv)

DelFeature_Browser_Emulation()


Re: html5 IE gadget project

Posted: Fri Jun 15, 2018 2:49 pm
by juror
Seems to work fine now except when you end the program you receive a window

Title: PB WebView Demo 2 way coms

Can't reach this page
Make sure the web address is correct
search on Bing
Refresh the page (doesn't refresh)

cheers

Re: html5 IE gadget project

Posted: Fri Jun 15, 2018 11:24 pm
by idle
Hi Juror, thanks for your patience.

It didn't find the index.html, it was looking for it from the currentdirectory
Anyway thanks for testing it and confirming it works
I will get around to making it into a gadget soon.

Re: html5 IE gadget project

Posted: Sat Jun 16, 2018 3:06 am
by juror
No need for thanks. Looks like it will be a fine contribution to PB.