Page 1 of 1

Open HTMLHELP (.chm) page in PureBasic's IE WebGadget

Posted: Sun Apr 14, 2013 3:35 am
by Danilo

Code: Select all

;
; Open HTMLHELP (.chm) page in PureBasic's IE WebGadget
;
; Info: http://helpware.net/htmlhelp/linktochm.htm
;

;topic.s = "::/help/openhelp.html"
topic.s = "::/reference/reference.html"
;topic.s = "::/2DDrawing/index.html"

url.s = "mk:@MSITStore:" + ReplaceString(#PB_Compiler_Home,"\","/") + "PureBasic.chm" + topic

; alternative method
;url.s = "ms-its:" + ReplaceString(#PB_Compiler_Home,"\","/") + "PureBasic.chm" + topic


If OpenWindow(0, 0, 0, 800, 600, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
    WebGadget(0, 0, 25, 800, 575, url)
    ButtonGadget(1,  0,0,50,25,"<<")
    ButtonGadget(2, 50,0,50,25,">>")
    ButtonGadget(3,100,0,50,25,"Home")
    
    Repeat
        Select WaitWindowEvent()
            Case #PB_Event_CloseWindow
                End
            Case #PB_Event_Gadget
                Select EventGadget()
                    Case 1 : SetGadgetState(0,#PB_Web_Back)
                    Case 2 : SetGadgetState(0,#PB_Web_Forward)
                    Case 3 : SetGadgetText(0,"mk:@MSITStore:" + ReplaceString(#PB_Compiler_Home,"\","/") + "PureBasic.chm" + "::/reference/reference.html")
                EndSelect
        EndSelect
    ForEver
    
EndIf
Can be useful to include help directly in your program, using IE webgadget (instead opening HtmlHelp Viewer).
Requires full path to your own .chm, with UNIX slashes ('/').


Using PanelGadget to open each .CHM page on new tab (if not already opened):

Code: Select all

;
; Open HTMLHELP (.chm) page in PureBasic's IE WebGadget
;
; Info: http://helpware.net/htmlhelp/linktochm.htm
;

;topic.s = "::/help/openhelp.html"
topic.s = "::/reference/reference.html"
;topic.s = "::/2DDrawing/index.html"

url.s = "mk:@MSITStore:" + ReplaceString(#PB_Compiler_Home,"\","/") + "PureBasic.chm" + topic

; alternative method
;url.s = "ms-its:" + ReplaceString(#PB_Compiler_Home,"\","/") + "PureBasic.chm" + topic

Procedure NavigationCallback(Gadget, url$)
    OpenGadgetList(0)
    If GetFilePart(Url$)="index.html"
        tab$ = RemoveString(url$,"mk:@MSITStore:" + ReplaceString(#PB_Compiler_Home,"\","/") + "PureBasic.chm::/")
        tab$ = Left(tab$,Len(tab$)-Len(GetFilePart(tab$))-1)
        tab$ = "Library: "+tab$
    Else
        tab$ = GetFilePart(Url$)
    EndIf
    tab$ = RemoveString(tab$,".html")
    
    For i = 0 To CountGadgetItems(0)
        If RemoveString(GetGadgetItemText(0,i),".html")=tab$
            SetGadgetState(0,i)
            ProcedureReturn #False
        EndIf
    Next i
    AddGadgetItem(0,-1,tab$)
    While WindowEvent():Wend
    web = WebGadget(#PB_Any, 0, 0, GetGadgetAttribute(0,#PB_Panel_ItemWidth), GetGadgetAttribute(0,#PB_Panel_ItemHeight), url$)
      While WindowEvent():Wend
      SetGadgetAttribute(web, #PB_Web_NavigationCallback, @NavigationCallback())
      SetGadgetState(0,CountGadgetItems(0)-1)
    CloseGadgetList()
    ProcedureReturn #False
EndProcedure 

ExamineDesktops()

If OpenWindow(0, 0, 0, DesktopWidth(0)*0.8, DesktopHeight(0)*0.8, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered );| #PB_Window_Maximize)
    ButtonGadget(2,WindowWidth(0)-20,0,20,20,"X")
    PanelGadget(0,0,20,WindowWidth(0),WindowHeight(0)-20)
    
    While WindowEvent():Wend
    
    AddGadgetItem(0,-1,RemoveString(GetFilePart(url),".html"))
      While WindowEvent():Wend
      WebGadget(1, 0, 0, GetGadgetAttribute(0,#PB_Panel_ItemWidth), GetGadgetAttribute(0,#PB_Panel_ItemHeight), url)
    CloseGadgetList()
    
    While WindowEvent():Wend
    
    SetGadgetAttribute(1, #PB_Web_NavigationCallback, @NavigationCallback())

    Repeat
        Select WaitWindowEvent()
            Case #PB_Event_CloseWindow
                End
            Case #PB_Event_Gadget
                If EventGadget() = 2 And EventType() = #PB_EventType_LeftClick
                    item = GetGadgetState(0)
                    If item <> 0
                        RemoveGadgetItem(0,GetGadgetState(0))
                        SetGadgetState(0,item-1)
                    EndIf
                EndIf
        EndSelect
    ForEver
    
EndIf

Re: Open HTMLHELP (.chm) page in PureBasic's IE WebGadget

Posted: Sun Apr 14, 2013 9:15 am
by Little John
Very cool. 8)
Many thanks for sharing.

Re: Open HTMLHELP (.chm) page in PureBasic's IE WebGadget

Posted: Sun Apr 14, 2013 1:28 pm
by yrreti
Thanks very much for sharing this Danilo
It works really nice, and gives you a really nice view of the help file index and clicked on sections.
I like the tabbed history too, but noticed that it would be nice to be able to clear a tab, or have a
button to clear all tabs if needed for a fresh start. Like you said. This could be very useful in other
programs too.
Thanks for sharing this.

yrreti

Re: Open HTMLHELP (.chm) page in PureBasic's IE WebGadget

Posted: Sun Apr 14, 2013 7:27 pm
by Kwai chang caine
it is surprising :shock:
Thanks to sharing 8)

Re: Open HTMLHELP (.chm) page in PureBasic's IE WebGadget

Posted: Sun Apr 14, 2013 7:30 pm
by Danilo
yrreti wrote:I like the tabbed history too, but noticed that it would be nice to be able to clear a tab, or have a button to clear all tabs if needed for a fresh start.
Added small "X" button for closing current panel tab (except first one). Better use STARGĂ…TE's "TabBarGadget - Tabs like in a browser" for better look and close button on tabs.

Re: Open HTMLHELP (.chm) page in PureBasic's IE WebGadget

Posted: Sun Apr 14, 2013 9:49 pm
by yrreti
Hi Danilo
Just a quick thank you for the quick mode, and other reference to look at.

yrreti