Quickly explained it acts almost like a About window/box but uses the webgadget,
the window can be closed normally or by clicking a inline close link.
Hopefully this gives you an idea on how to make a HTML GUI.
If your program is fully HTML GUI driven it would be best to have the window loop in the main program loop instead, this example was just a test.
This example also passes the html directly, it may be better to use local html gui files for GUI's with larger html "pages".
I also want to thank the PB Team for adding the callback as that is the key to making a HTML GUI as it allows custom things like "cmd:close"
Code: Select all
EnableExplicit
Procedure.l AboutHtml_NavigationCallback(gadget,url$)
Protected window.l
If url$="cmd:close"
window=GetGadgetData(gadget)
If IsWindow(window)
CloseWindow(window)
EndIf
ProcedureReturn #False
EndIf
ProcedureReturn #True
EndProcedure
Procedure.l AboutHtml(title$,msg$,width.l=400,height.l=300,parent.l=#Null)
Protected window.l,flags.l,web.l,button.l,result.l=#False,parentid.l=#Null,event.l
flags=#PB_Window_SystemMenu|#PB_Window_TitleBar|#PB_Window_Invisible
If parent
flags|#PB_Window_WindowCentered
Else
flags|#PB_Window_ScreenCentered
EndIf
If parent
parentid=WindowID(parent)
EndIf
window=OpenWindow(#PB_Any,#PB_Ignore,#PB_Ignore,width,height,title$,flags,parentid)
If window
If CreateGadgetList(WindowID(window))
web=WebGadget(#PB_Any,0,0,WindowWidth(window),WindowHeight(window),"")
If web
SetGadgetItemText(web,#PB_Web_HtmlCode,msg$)
SetGadgetData(web,window)
SetGadgetAttribute(web,#PB_Web_NavigationCallback,@AboutHtml_NavigationCallback())
HideWindow(window,#False)
Repeat
If IsWindow(window) ;We must check as it may have been closed in the callback
event=WaitWindowEvent()
Else
event=#PB_Event_CloseWindow ;If window is gone we must quit the loop
EndIf
Until event=#PB_Event_CloseWindow
result=#True
EndIf
EndIf
If IsWindow(window)
CloseWindow(window)
EndIf
EndIf
ProcedureReturn result
EndProcedure
;A simple example
AboutHtml("Test","<a href="+#DQUOTE$+"cmd:close"+#DQUOTE$+">Close Window</a>")
