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

Share your advanced PureBasic knowledge/code with the community.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

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

Post 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
Last edited by Danilo on Sun Apr 14, 2013 7:23 pm, edited 1 time in total.
Little John
Addict
Addict
Posts: 4791
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

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

Post by Little John »

Very cool. 8)
Many thanks for sharing.
yrreti
Enthusiast
Enthusiast
Posts: 546
Joined: Tue Oct 31, 2006 4:34 am

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

Post 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
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

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

Post by Kwai chang caine »

it is surprising :shock:
Thanks to sharing 8)
ImageThe happiness is a road...
Not a destination
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

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

Post 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.
yrreti
Enthusiast
Enthusiast
Posts: 546
Joined: Tue Oct 31, 2006 4:34 am

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

Post by yrreti »

Hi Danilo
Just a quick thank you for the quick mode, and other reference to look at.

yrreti
Post Reply