>独自に拡張する感じでしょうか?
現状ですと mod_WebView2 で書かれたサンプル等を見てどういう風に書けば良いかを考える必要があると思います。
参考に「進む」「戻る」を mod_WebView2_10115038版, mod_wv2s版 で書いてみました。置き換え方を比較してみてください。
書き換え方が分かると Hiroさん とこのサンプルを見るとなんとなく他の処理の書き方も見えてくるかもしれません(?)
https://blog.goo.ne.jp/hiro239415/e/5041aec497e02427c2b123aef07977e3
下記のサンプルにはそれぞれのモジュールと「WebView2Loader.dll」「wv2s.dll」が必要になります。
↓は mod_WebView2_10115038版
/* ---------------------------------------------------------
include
--------------------------------------------------------- */
#include "mod_WebView2_10115038.hsp"
#uselib "msvcrt"
#cfunc wcslen "wcslen" int
/* ---------------------------------------------------------
define
--------------------------------------------------------- */
#define global WV2Ctrl_get_CoreWebView2 25
#define global WV2_Navigate 5
#define global WV2_get_CanGoBack 38
#define global WV2_get_CanGoForward 39
#define global WV2_get_GoBack 40
#define global WV2_get_GoForward 41
#define global WV2_add_DocumentTitleChanged 46
#define global WV2_del_DocumentTitleChanged 47
#define global WV2_get_DocumentTitle 48
/* ---------------------------------------------------------
Main Window
--------------------------------------------------------- */
WebView2_InitWnd 0
title "WebView2"
pEnv = WebView2_CreateEnv() : if ( pEnv == 0 ){ dialog "err WebView2_CreateEnv" : end }
curCtrl = WebView2_CreateCtrl(pEnv, hwnd)
curView = WebView2_GetView(curCtrl)
WebView2_Size curCtrl, 0, 32, ginfo_winx, ginfo_winy
objsize 64, 32
pos 0, 0 : button gosub "戻る", *GoBack : idBtn_goBack = stat
pos 64, 0 : button gosub "進む", *GoForward : idBtn_goForward = stat
onexit *ON_EXIT
// Event登録
oncmd gosub *EVENT_TITLE, 0x9000
dim dp, WV2_DATA_SIZE
WebView2_EventInit WV2_EVENT_TITLECHANGED, hwnd, 0x9000, dp
ret = CCall2(curView, WV2_add_DocumentTitleChanged, 2, dp, varptr(dp(6)))
resRecvHdl = varptr(dp(WV2_DATA_VT))
dim token, 2 ; この token は WV2_del_DocumentTitleChanged するときに必要となる
token = dp(WV2_DATA_TOKENL), dp(WV2_DATA_TOKENH)
// 初期ページへNavigate
sdim bufTmpUni,256 : cnvstow bufTmpUni, "https://hsp.tv"
ret = CCall2(curView, WV2_Navigate, 1, varptr(bufTmpUni))
// 別ページに Navigate して「戻る」可能なことを示してみる
wait 50
sdim bufTmpUni,256 : cnvstow bufTmpUni, "https://hsp.tv/make/hsp3.html"
ret = CCall2(curView, WV2_Navigate, 1, varptr(bufTmpUni))
stop
/* ---------------------------------------------------------
Label Go***
--------------------------------------------------------- */
*GoBack
ret = CCall2(curView, WV2_get_GoBack, 0)
return
*GoForward
ret = CCall2(curView, WV2_get_GoForward, 0)
return
*CHECK_CanGo
if CCall2(curView, WV2_get_CanGoBack, 1, varptr(p1)) == 0 : objenable idBtn_goBack, p1
if CCall2(curView, WV2_get_CanGoForward, 1, varptr(p1)) == 0 : objenable idBtn_goForward, p1
return
/* ---------------------------------------------------------
Label Event
--------------------------------------------------------- */
*EVENT_TITLE
if ( CCall2(curView, WV2_get_DocumentTitle, 1, varptr(p1)) == 0 ){
dupptr wTitle, p1, wcslen(p1)*2+2, 2
title "WebView2 - " + cnvwtos(wTitle)
CoTaskMemFree p1
}else {
title "WebView2"
}
gosub *CHECK_CanGo
return
/* ---------------------------------------------------------
onexit
--------------------------------------------------------- */
*ON_EXIT
if ( resRecvHdl ){
ret = CCall2(curView, WV2_del_DocumentTitleChanged, 2, token(0), token(1))
}
if curView : WebView2_Release curView
if curCtrl : WebView2_Release curCtrl
if pEnv : WebView2_Release pEnv
end
↓は mod_wv2s版
/* ---------------------------------------------------------
include
--------------------------------------------------------- */
#include "mod_wv2s.hsp"
#uselib "msvcrt"
#cfunc wcslen "wcslen" int
#uselib "ole32.dll"
#func CoTaskMemFree "CoTaskMemFree" sptr
/* ---------------------------------------------------------
define
--------------------------------------------------------- */
#define global WV2Ctrl_get_CoreWebView2 25
#define global WV2_Navigate 5
#define global WV2_get_CanGoBack 38
#define global WV2_get_CanGoForward 39
#define global WV2_get_GoBack 40
#define global WV2_get_GoForward 41
#define global WV2_add_DocumentTitleChanged 46
#define global WV2_del_DocumentTitleChanged 47
#define global WV2_get_DocumentTitle 48
/* ---------------------------------------------------------
Main Window
--------------------------------------------------------- */
title "wv2s"
WV2Env 0, 0
pEnv = stat : if ( pEnv == 0 ){ dialog "err wv2s_WV2Env" : end }
WV2Ctrl pEnv, hwnd
curCtrl = stat
prm = varptr(curView)
ComCall curCtrl, WV2Ctrl_get_CoreWebView2, prm, 1
WV2SetSize curCtrl, 0, 32, ginfo_winx, ginfo_winy
objsize 64, 32
pos 0, 0 : button gosub "戻る", *GoBack : idBtn_goBack = stat
pos 64, 0 : button gosub "進む", *GoForward : idBtn_goForward = stat
onexit *ON_EXIT
// Event登録
oncmd gosub *EVENT_TITLE, 0x9000
WV2HdlNew 0/*type:II*/, hwnd, 0x9000
resRecvHdl = stat
dim token, 2 ; この token は WV2_del_DocumentTitleChanged するときに必要となる
prm = resRecvHdl, varptr(token)
ComCall curView, WV2_add_DocumentTitleChanged, prm, 2
// 初期ページへNavigate
WV2Navigate curCtrl, "https://hsp.tv"
// 別ページに Navigate して「戻る」可能なことを示してみる
wait 50
WV2Navigate curCtrl, "https://hsp.tv/make/hsp3.html"
stop
/* ---------------------------------------------------------
Label Go***
--------------------------------------------------------- */
*GoBack
prm = 0
ComCall curView, WV2_get_GoBack, prm, 0
return
*GoForward
prm = 0
ComCall curView, WV2_get_GoForward, prm, 0
return
*CHECK_CanGo
prm = varptr(p1)
ComCall curView, WV2_get_CanGoBack, prm, 1
if stat == 0 : objenable idBtn_goBack, p1
prm = varptr(p1)
ComCall curView, WV2_get_CanGoForward, prm, 1
if stat == 0 : objenable idBtn_goForward, p1
return
/* ---------------------------------------------------------
Label Event
--------------------------------------------------------- */
*EVENT_TITLE
prm = varptr(p1)
ComCall curView, WV2_get_DocumentTitle, prm, 1
if ( stat == 0 ){
dupptr wTitle, p1, wcslen(p1)*2+2, 2
title "wv2s - " + cnvwtos(wTitle)
CoTaskMemFree p1
}else {
title "wv2s"
}
gosub *CHECK_CanGo
return
/* ---------------------------------------------------------
onexit
--------------------------------------------------------- */
*ON_EXIT
if ( resRecvHdl ){
prm = token(0), token(1)
ComCall curView, WV2_del_DocumentTitleChanged, prm, 2
}
if curView : ComDel curView
if curCtrl : ComDel curCtrl
if pEnv : ComDel pEnv
end
実は私も WV2HdlGet 等とか一部よく分かってないとこもあります。。。