This is the ultra version of LB Help Search. It incorporates features to assist using the help files.

A bitmap is used for the help button, but program will substitute a text button if the bitmap is not found in the default directory. You can d/l the bmp file if I did the link thingy correctly.


Note: See below for a version in progress for Netbook screen sizes. This is incomplete and is meant to check if it functions properly with a GUI window of 600px.

    ' LB Help Search entry
    ' Author: jaba
    ' Date: May 5, 2011
    '
    ' History:
    ' v1.0      May 6, 2011     Submitted
    ' v1.01     May 6, 2011     Added browser control
    ' v1.02     May 9, 2011     Added GetModuleFileName$() routine
    ' v1.03     May 12, 2011    Additional pages added to quick viewer
    '                           Some names made more purpose-descriptive
    '
    ' v1.03b    May 13, 2011    Final Lite version
    ' v1.03d    May 14, 2011    in progress...added 200px to width for index listbox (not using)
    ' v1.03e    May 14, 2011    Alpha version with index listbox (not using)
    ' v1.03f    May 15, 2011    rebuilt banner; added Help
    '                           Submitted May 16, 2011
    ' v2.0      May 16, 2011    Submitted Assistant version (this version)
    '
    '   things to do:
    '   add MRU list in combobox for Find textbox
    '   add Favorites
    '   decide best use for middle window
    '   options
    '
    ' -- be sure to update ABOUT before Final submission --
    '
    ' This code is free for personal use.
    ' To protect the rights of others whose code is included, please note following:
    ' You may not republish this code in its current form.
    ' You may modify this code for your personal use.
    ' You may publish a modified version of this code under these conditions:
    '    1. You have made major changes to the code.
    '    2. You give credit to the original authors
    '
    ' Based on a framework provided by Alyce on LB forum.
    '
    ' Some parts taken from entries by others, including
    ' Alyce, Janet, Stefan, and Gordon.
    '
    ' Thanks to them and others.
    '
    ' This version uses a built-in ATL.DLL browser control
    ' in addition to the user's default browser.
    '
    '
    ' Thanks to Stefan Pendl for API function method to obtain location of
    ' LB installation directory. This method is more reliable with systems
    ' running Vista/Win7 than is the StartupDir$ or DefaultDir$ method.
    InstallDir$       = GetFolder$(GetModuleFileName$())
    HelpDir$          = InstallDir$ + "lb4help\LibertyBASIC_4_web\HTML\"
    HelpFileIndex$    = InstallDir$; "lb4help\"
    ContentsFileName$ = "LibertyBASIC_4.html"
 
    WdoTitle$ = "LB HTML SEARCH ASSISTANT"
        'List of Quick View pages:
        'Table of Contents  = "libe3mnn.htm"    'amber_menu.htm
        'Command Reference  = "libe2co3.htm"
        'Reserved Word List = "libe6ldg.htm"
        'Text commands      = "libe778l.htm"
        'Graphic commands   = "libe233p.htm"
 
    Open "atl" For DLL As #atl
 
    CallDLL #atl, "AtlAxWinInit", Ret As long
 
nomainwin
[setupGUIWdo]
    WindowWidth  = 925
    WindowHeight = 730
    UpperLeftX   = DisplayWidth - WindowWidth
    UpperLeftY   = 40
 
'***banner
    graphicbox #s.banner 1, 1, 735, 30
    button  #s.content "Open Default Browser", [openBrowser], UL, 734, 1, 154, 30
 
    '***help button
    'is there a bmp file for help?
    if fileExists(DefaultDir$, "Help_brown.bmp") then
        bmpbutton #s.hlp "Help_brown.bmp", [help], UL, 888, 1
    else
        button #s.hlp "?", [help], UL, 550, 10
    end if
 
'***search
    TextboxColor$ = "buttonface"
    graphicbox #s.explorer 0, 30, 200, 25
'    combobox #s.term mru$(), [mruList], 1, 55, 160, 25 '<---may try to use this
    textbox #s.term 1, 55, 160, 25
    button  #s.default "Find", [findPages], UL, 160, 55, 40, 25
    ListboxColor$ = "buttonface"
    listbox #s.pages, found$(), [displaySelectedPage], 1, 80, 200, 160
    checkbox #s.qvChkbx, "Check to open in Quick Viewer", [setChk], [resetChk], 10, 243, 190, 18
 
'***notes
    TextboxColor$ = "buttonface"
    graphicbox #s.notes 200, 30, 534, 25
    stylebits #s.middle, _WS_VSCROLL OR _ES_MULTILINE, _ES_AUTOHSCROLL, 0, 0
    textbox #s.middle 201, 55, 534, 210
 
'***index
    graphicbox #s.indx 735, 30, 180, 25
    ListboxColor$ = "buttonface"
    stylebits #s.index, _WS_HSCROLL, 0, 0, 0
    listbox   #s.index, index$(), [pickBox], 735, 55, 179, 605
 
'***quick viewer
    graphicbox #s.heading 0, 266, 200, 25
'    button #s.quick "Quick Start Guide", [quickButton], UL, 200, 266, 100, 25          'points to libe3mnn.htm
    button #s.toc "LB 4.04 Contents", [tocButton], UL, 200, 266, 100, 25                'points to libe3mnn.htm
    button #s.commands "Command Reference", [commandsButton], UL, 300, 266, 115, 25     'points to libe2co3.htm
    button #s.reserve "Reserved Words", [reservedButton], UL, 415, 266, 100, 25         'points to libe6ldg.htm
    button #s.text "Text Commands", [textButton], UL, 515, 266, 100, 25                 'points to libe778l.htm
    button #s.graph "Graphics Commands", [graphicButton], UL, 615, 266, 115, 25         'points to libe233p.htm
    graphicbox #s.resource 1, 290, 734, 370    'container for browser control
 
'***status bar
    statictext #s.status, "Right-click browser window for BACK/FORWARD.", 10, 662, 210, 20
    'comment out if color bar not wanted
    gosub [defineColorBar]
 
 
[openGUIWdo]
    open WdoTitle$ for dialog_nf as #s
    #s "trapclose [quit]"
    #s.index "singleclickselect"
    #s.pages "singleclickselect"
    #s.qvChkbx "set" :chkSet = 1
 
    #s           "font ms_sans_serif 9"
    #s.content   "!font ms_sans_serif 9"' bold"
    #s.heading   "font arial 9 bold"
    #s.explorer  "font arial 9 bold"
    #s.notes     "font arial 9 bold"
    #s.indx      "font arial 9 bold"
    #s.status    "!font arial 7"
    #s.qvChkbx   "font arial 7"
 
    gosub [colorBar]
 
    'color the banner
    #s.banner "fill buttonface"
    #s.banner "down; place 0 20; color black; backcolor buttonface"
    #s.banner "\   LB Help Search Challenge"
    #s.banner "flush"
 
    #s.explorer "fill 88 66 55; color white; backcolor 88 66 55; down; place 0 15"
    #s.explorer "\  Search results"
    #s.explorer "flush"
 
    #s.notes "fill 88 66 55; color white; backcolor 88 66 55; down; place 0 15"
    #s.notes "\  Clipboard / Notes"
    #s.notes "flush"
 
    #s.indx "fill 88 66 55; color white; backcolor 88 66 55; down; place 0 15"
    #s.indx "\  Index"
    #s.indx "flush"
 
    #s.heading "fill 88 66 55; color white; backcolor 88 66 55; down; place 0 15"
    #s.heading "\  Quick Viewer"
    #s.heading "flush"
 
 
    'display table of contents in browse control
    QuickViewPage$ = "libe3mnn.htm"
    call createBrowseControl HelpFileIndex$, ContentsFileName$, hFlag
 
'    #s.term " Type search term... "
    #s.term "!setfocus"
    #s.term "!selectall"
 
 
    dim info$(10,10)
    files HelpDir$, "*.htm", info$()
 
    numFiles = val(info$(0,0))
 
    'load index array
    dim index$(numFiles)
    scan
    for i = 1 to numFiles
        open HelpDir$ + info$(i,0) for input as #file
            txt$ = INPUT$(#file, lof(#file))
            index$(i) = GetTitle$(txt$); chr$(0); info$(i,0)
        close #file
    next i
 
    sort index$(), 1, numFiles
    #s.index "reload"
 
 
    gosub [hint]    '<--- Comment out when no longer needed.
 
    #s.middle "* * * HINTS * * *";chr$(13);chr$(10);_
            "A handy way to browse the results pages...";chr$(13);chr$(10);_
            "Enter search term. Check the box to open in Quick Viewer.  ";_
            "Use the arrow keys to advance to the first or next page ";_
            "in the listbox. Each highlighted page will display in the ";_
            "Quick Viewer.";chr$(13);chr$(10);_
            "With the checkbox cleared, doing the same thing will open ";_
            "in a new tab in your browser.  A ctrl-w will usually close the tab.";chr$(13);chr$(10);_
            "";chr$(13);chr$(10);chr$(13);chr$(10);_
            "This textbox space is a work in progress. Still working on ";_
            "ideas for its use."
    wait
 
[mruList]
    wait
 
[dummy]
    wait
 
[setChk]
    #s.qvChkbx "set"
    chkSet = 1
    wait
 
[resetChk]
    #s.qvChkbx "reset"
    chkSet = 0
    wait
 
[tocButton]
    QuickViewPage$ = "libe3mnn.htm"
    call createBrowseControl HelpFileIndex$, ContentsFileName$, hFlag
    wait
 
[commandsButton]
    QuickViewPage$ = "libe2co3.htm"
    call createBrowseControl HelpDir$, QuickViewPage$, hFlag
    wait
 
[reservedButton]
    QuickViewPage$ = "libe6ldg.htm"
    call createBrowseControl HelpDir$, QuickViewPage$, hFlag
    wait
 
[textButton]
    QuickViewPage$ = "libe778l.htm"
    call createBrowseControl HelpDir$, QuickViewPage$, hFlag
    wait
 
[graphicButton]
    QuickViewPage$ = "libe233p.htm"
    call createBrowseControl HelpDir$, QuickViewPage$, hFlag
    wait
 
[findPages]
    #s.term "!contents? term$"
    if term$ = "" then
        redim found$(1)
        #s.pages "reload"
        wait
    end if
 
    dim found$(numFiles)
 
    for i = 1 to numFiles
 
        open HelpDir$ + info$(i,0) for input as #file
            txt$ = INPUT$(#file, lof(#file))
 
            if instr(txt$, term$) >0 then
                found$(i) = GetTitle$(txt$); chr$(0); info$(i,0)
                #s.pages "reload"
            end if
        close #file
 
    next
    wait
 
[openBrowser]
    'open user's default browser
    run "rundll32.exe url.dll,FileProtocolHandler "; chr$(34); HelpFileIndex$ + ContentsFileName$; chr$(34)
    wait
 
[displaySelectedPage]
    #s.pages "selection? FileName$"
    FileName$ = word$(FileName$, 2, chr$(0))
 
    if chkSet = 0 then
    'open in user's default browser or new tab
        run "rundll32.exe url.dll,FileProtocolHandler "; chr$(34); HelpDir$; FileName$; chr$(34)
    else
        call createBrowseControl HelpDir$, FileName$, hFlag
    end if
    wait
 
[pickBox]
    #s.index "selection? qvp$"
    qvp$ = word$(qvp$, 2, chr$(0))
    call createBrowseControl HelpDir$, qvp$, hFlag
    wait
 
[help]
    WindowWidth = 400
    WindowHeight = 290
    statictext #h.hlp "", 10, 10, 390, 280
    open "How to use" for window as #h
    #h "trapclose [noMoreh]"
    hlpWdoOpen = 1
    gosub [printHlp]
    wait
    [noMoreh]
    close #h
    hlpWdoOpen = 0
    wait
 
[quit]
    close #s
    close #atl
    if hlpWdoOpen = 1 then close #h :hlpWdoOpen = 0
    end
 
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXSUBS AND FUNCTIONS
 
'credit: Alyce's entry.
'extract title from html text
function GetTitle$(s$)
    marker1=instr(upper$(s$), "<A NAME=")
    marker1=instr(upper$(s$), "<B>",marker1)+3
    marker2=instr(upper$(s$), "</B>", marker1)
    lenTitle=marker2-marker1
    GetTitle$=mid$(s$,marker1,lenTitle)
    end function
 
'borrowed from Stefan Pendl
'added 5/9/11
function GetModuleFileName$()
    nSize = _MAX_PATH + 1
    lpFilename$ = space$(nSize); CHR$(0)
    calldll #kernel32, "GetModuleFileNameA",_
        hModule     as uLong,_
        lpFilename$ as ptr,_
        nSize       as uLong,_
        result      as uLong
    if result > 0 then GetModuleFileName$ = trim$(lpFilename$)
end function
 
function GetFolder$(Path$)
    pos = 1
    GetFolder$ = Path$
    while pos > 0
        pos = instr(Path$, "\", pos)
         if pos > 0 then
            GetFolder$ = left$(Path$, pos)
            pos = pos + 1
        end if
    wend
end function
 
 
sub createBrowseControl D$, F$, byref hATL
    if hATL then
        CallDLL #user32, "DestroyWindow", _
            hATL   As ulong, _
            result As long
            hATL   = 0
    end if
 
    hWndContainer = hWnd(#s.resource)   'graphicbox handle
 
    callDLL #user32, "GetWindowLongA", _
        hWndContainer  as ulong, _
        _GWL_HINSTANCE as long, _
                 hInst as ulong
 
    ResName$ = D$ + F$                  'file to display
 
    style = _WS_CHILD or _WS_VISIBLE or _WS_VSCROLL
 
    CallDLL #user32, "CreateWindowExA", _
    _WS_EX_STATICEDGE As long, _        'extended type
           "AtlAxWin" As ptr, _         'class name
             ResName$ As ptr, _         'resource file name & path
                style As long, _        'window style
                    1 As long, _        'left x pos
                    1 As long, _        'top y pos
                  729 As long, _        'width
                  366 As long, _        'height
        hWndContainer As ulong, _       'handle of container
                  100 As long, _        'handle to menu or child window ID
                hInst As ulong, _       'parent instance handle
                    0 As long, _        'window creation data
                 hATL As ulong          'handle of active template library control
 
end sub
 
[printHlp]
    ' Help window contents
    hlp$ =  "Find button -";chr$(13);_
            "  Type search term into textbox. Results are shown in listbox below.";chr$(13);_
            "  Single-click a result to display the page in your default browser.";chr$(13);_
            "  Check the box to display results in the Quick Viewer window.";chr$(13);chr$(13);_
            "Open Default Browser button -";chr$(13);_
            "  Click button to open your default browser to Table of Contents.";chr$(13);chr$(13);_
            "Index -";chr$(13);_
            "  Single-click an Indexed item in listbox to view it in the Quick Viewer.";chr$(13);chr$(13);_
            "Quick Viewer -";chr$(13);_
            "  Select from the 5 buttons to view a pre-selected help topic.";chr$(13);chr$(13);_
            "                   ABOUT LB HELP SEARCH ASSISTANT";chr$(13);_
            "                                        Version 2.0";chr$(13);_
            "                                      May 15, 2011";chr$(13);_
            "                                          By: jaba"
    print #h.hlp, hlp$
    return
 
[hint]
    notice "A handy way to browse the results pages...";chr$(13);_
            "Enter search term. Check the box to open in Quick Viewer.";chr$(13);_
            "Use the arrow keys to advance to the first or next page";chr$(13);_
            "in the listbox. Each highlighted page will display in the";chr$(13);_
            "Quick Viewer.";chr$(13);chr$(13);_
            "With the checkbox cleared, doing the same thing will open";chr$(13);_
            "in a new tab in your browser. A ctrl-w will usually close the tab."
    return
 
function fileExists(path$, filename$)
    files path$, filename$, info$()
    fileExists = val(info$(0, 0))
end function
 
[defineColorBar]
    graphicbox #s.c1 230, 677, 42, 15
        statictext #s.l1 "yellow", 230, 662, 40, 15
    graphicbox #s.c2 272, 677, 42, 15
        statictext #s.l2 "brown", 272, 662, 40, 15
    graphicbox #s.c3 314, 677, 42, 15
        statictext #s.l3 "red", 314, 662, 40, 15
    graphicbox #s.c4 356, 677, 42, 15
        statictext #s.l4 "darkred", 356, 662, 40, 15
    graphicbox #s.c5 398, 677, 42, 15
        statictext #s.l5 "pink", 398, 662, 40, 15
    graphicbox #s.c6 440, 677, 42, 15
        statictext #s.l6 "darkpink", 440, 662, 40, 15
    graphicbox #s.c7 482, 677, 42, 15
        statictext #s.l7 "blue", 482, 662, 40, 15
    graphicbox #s.c8 524, 677, 42, 15
        statictext #s.l8 "darkblue", 524, 662, 40, 15
    graphicbox #s.c9 566, 677, 42, 15
        statictext #s.l9 "green", 566, 662, 40, 15
    graphicbox #s.c10 608, 677, 42, 15
        statictext #s.l10 "darkgreen", 608, 662, 40, 15
    graphicbox #s.c11 650, 677, 42, 15
        statictext #s.l11 "cyan", 650, 662, 40, 15
    graphicbox #s.c12 692, 677, 42, 15
        statictext #s.l12 "darkcyan", 692, 662, 40, 15
    graphicbox #s.c13 734, 677, 42, 15
        statictext #s.l13 "white", 734, 662, 40, 15
    graphicbox #s.c14 776, 677, 42, 15
        statictext #s.l14 "black", 776, 662, 40, 15
    graphicbox #s.c15 818, 677, 42, 15
        statictext #s.l15 "lightgray", 818, 662, 40, 15
    graphicbox #s.c16 860, 677, 42, 15
        statictext #s.l16 "darkgray", 860, 662, 40, 15
return
 
[colorBar]
    #s.l1 "!font arial 7"
    #s.l2 "!font arial 7"
    #s.l3 "!font arial 7"
    #s.l4 "!font arial 7"
    #s.l5 "!font arial 7"
    #s.l6 "!font arial 7"
    #s.l7 "!font arial 7"
    #s.l8 "!font arial 7"
    #s.l9 "!font arial 7"
    #s.l10 "!font arial 7"
    #s.l11 "!font arial 7"
    #s.l12 "!font arial 7"
    #s.l13 "!font arial 7"
    #s.l14 "!font arial 7"
    #s.l15 "!font arial 7"
    #s.l16 "!font arial 7"
 
    #s.c1 "fill yellow; flush"
    #s.c2 "fill brown; flush"
    #s.c3 "fill red; flush"
    #s.c4 "fill darkred; flush"
    #s.c5 "fill pink; flush"
    #s.c6 "fill darkpink; flush"
    #s.c7 "fill blue; flush"
    #s.c8 "fill darkblue; flush"
    #s.c9 "fill green; flush"
    #s.c10 "fill darkgreen; flush"
    #s.c11 "fill cyan; flush"
    #s.c12 "fill darkcyan; flush"
    #s.c13 "fill white; flush"
    #s.c14 "fill black; flush"
    #s.c15 "fill lightgray; flush"
    #s.c16 "fill darkgray; flush"
return
 
Netbook size version: v2.0.1
    ' LB Help Search entry
    ' Author: jaba
    ' Date: May 5, 2011
    '
    ' History:
    ' v1.0      May 6, 2011     Submitted
    ' v1.01     May 6, 2011     Added browser control
    ' v1.02     May 9, 2011     Added GetModuleFileName$() routine
    ' v1.03     May 12, 2011    Additional pages added to quick viewer
    '                           Some names made more purpose-descriptive
    '
    ' v1.03b    May 13, 2011    Final Lite version
    ' v1.03d    May 14, 2011    in progress...added 200px to width for index listbox (not using)
    ' v1.03e    May 14, 2011    Alpha version with index listbox (not using)
    ' v1.03f    May 15, 2011    rebuilt banner; added Help
    '                           Submitted May 16, 2011
    ' v2.0      May 16, 2011    Submitted Assistant version (this version)
    ' v2.0.1       -"-          in progress...added current displayed file name to status bar
    '                           work on custom window height resizer
    '
    '   things to do:
    '   add MRU list in combobox for Find textbox
    '   add Favorites
    '   decide best use for middle window
    '   options
    '
    ' -- be sure to update ABOUT before Final submission --
    '
    ' This code is free for personal use.
    ' To protect the rights of others whose code is included, please note following:
    ' You may not republish this code in its current form.
    ' You may modify this code for your personal use.
    ' You may publish a modified version of this code under these conditions:
    '    1. You have made major changes to the code.
    '    2. You give credit to the original authors
    '
    ' Based on a framework provided by Alyce on LB forum.
    '
    ' Some parts taken from entries by others, including
    ' Alyce, Janet, Stefan, and Gordon.
    '
    ' Thanks to them and others.
    '
    ' This version uses a built-in ATL.DLL browser control
    ' in addition to the user's default browser.
    '
    '
    ' Thanks to Stefan Pendl for API function method to obtain location of
    ' LB installation directory. This method is more reliable with systems
    ' running Vista/Win7 than is the StartupDir$ or DefaultDir$ method.
    InstallDir$       = GetFolder$(GetModuleFileName$())
    HelpDir$          = InstallDir$ + "lb4help\LibertyBASIC_4_web\HTML\"
    HelpFileIndex$    = InstallDir$; "lb4help\"
    ContentsFileName$ = "LibertyBASIC_4.html"
 
    WdoTitle$ = "LB HTML SEARCH ASSISTANT"
        'List of Quick View pages:
        'Table of Contents  = "libe3mnn.htm"    'amber_menu.htm
        'Command Reference  = "libe2co3.htm"
        'Reserved Word List = "libe6ldg.htm"
        'Text commands      = "libe778l.htm"
        'Graphic commands   = "libe233p.htm"
 
    global adj
 
    Open "atl" For DLL As #atl
 
    CallDLL #atl, "AtlAxWinInit", Ret As long
 
nomainwin
[setupGUIWdo]
    adj = 0 '130
    if DisplayHeight < 800 then adj = 130
    WindowWidth  = 925
    WindowHeight = 730  '600
    UpperLeftX   = DisplayWidth - WindowWidth
    UpperLeftY   = 2'40
 
'***banner
    graphicbox #s.banner 1, 1, 735, 30
    button  #s.content "Open Default Browser", [openBrowser], UL, 734, 1, 154, 30
 
    '***help button
    'is there a bmp file for help?
    if fileExists(DefaultDir$, "Help_brown.bmp") then
        bmpbutton #s.hlp "Help_brown.bmp", [help], UL, 888, 1
    else
        button #s.hlp "?", [help], UL, 550, 10
    end if
 
'***search
    TextboxColor$ = "buttonface"
    graphicbox #s.explorer 0, 30, 200, 25
'    combobox #s.term mru$(), [mruList], 1, 55, 160, 25 '<---may try to use this
    textbox #s.term 1, 55, 160, 25
    button  #s.default "Find", [findPages], UL, 160, 55, 40, 25
    ListboxColor$ = "buttonface"
    listbox #s.pages, found$(), [displaySelectedPage], 1, 80, 200, 160
    checkbox #s.qvChkbx, "Check to open in Quick Viewer", [setChk], [resetChk], 10, 243, 190, 18
 
'***notes
    TextboxColor$ = "buttonface"
    graphicbox #s.notes 200, 30, 534, 25
    stylebits #s.middle, _WS_VSCROLL OR _ES_MULTILINE, _ES_AUTOHSCROLL, 0, 0
    textbox #s.middle 201, 55, 534, 210
 
'***index
    graphicbox #s.indx 735, 30, 180, 25
    ListboxColor$ = "buttonface"
    stylebits #s.index, _WS_HSCROLL, 0, 0, 0
    listbox   #s.index, index$(), [pickBox], 735, 55, 179, 605 - adj
 
'***quick viewer
    graphicbox #s.heading 0, 266, 200, 25
'    button #s.quick "Quick Start Guide", [quickButton], UL, 200, 266, 100, 25          'points to libe3mnn.htm
    button #s.toc "LB 4.04 Contents", [tocButton], UL, 200, 266, 100, 25                'points to libe3mnn.htm
    button #s.commands "Command Reference", [commandsButton], UL, 300, 266, 115, 25     'points to libe2co3.htm
    button #s.reserve "Reserved Words", [reservedButton], UL, 415, 266, 100, 25         'points to libe6ldg.htm
    button #s.text "Text Commands", [textButton], UL, 515, 266, 100, 25                 'points to libe778l.htm
    button #s.graph "Graphics Commands", [graphicButton], UL, 615, 266, 115, 25         'points to libe233p.htm
    graphicbox #s.resource 1, 290, 734, 370 - adj    'container for browser control
 
'***status bar
    statictext #s.status, "Right-click browser window for BACK/FORWARD.", 10, (WindowHeight - 67), 210, 15 '10, 663, 210, 15
    statictext #s.htmlName, "", 10, (WindowHeight-52), 210, 15    '10, 678, 210, 15
    'comment out if color bar not wanted
'    gosub [defineColorBar]
 
 
[openGUIWdo]
    open WdoTitle$ for dialog_nf as #s
    #s "trapclose [quit]"
    #s.index "singleclickselect"
    #s.pages "singleclickselect"
    #s.qvChkbx "set" :chkSet = 1
 
    #s           "font ms_sans_serif 9"
    #s.content   "!font ms_sans_serif 9"' bold"
    #s.heading   "font arial 9 bold"
    #s.explorer  "font arial 9 bold"
    #s.notes     "font arial 9 bold"
    #s.indx      "font arial 9 bold"
    #s.status    "!font arial 7"
    #s.htmlName$ "!font arial 7"
    #s.qvChkbx   "font arial 7"
 
'    gosub [colorBar]
 
    'color the banner
    #s.banner "fill buttonface"
    #s.banner "down; place 0 20; color black; backcolor buttonface"
    #s.banner "\   LB Help Search Challenge"
    #s.banner "flush"
 
    #s.explorer "fill 88 66 55; color white; backcolor 88 66 55; down; place 0 15"
    #s.explorer "\  Search results"
    #s.explorer "flush"
 
    #s.notes "fill 88 66 55; color white; backcolor 88 66 55; down; place 0 15"
    #s.notes "\  Clipboard / Notes"
    #s.notes "flush"
 
    #s.indx "fill 88 66 55; color white; backcolor 88 66 55; down; place 0 15"
    #s.indx "\  Index"
    #s.indx "flush"
 
    #s.heading "fill 88 66 55; color white; backcolor 88 66 55; down; place 0 15"
    #s.heading "\  Quick Viewer"
    #s.heading "flush"
 
 
    'display table of contents in browse control
    QuickViewPage$ = "libe3mnn.htm"
    call createBrowseControl HelpFileIndex$, ContentsFileName$, hFlag
 
'    #s.term " Type search term... "
    #s.term "!setfocus"
    #s.term "!selectall"
 
 
    dim info$(10,10)
    files HelpDir$, "*.htm", info$()
 
    numFiles = val(info$(0,0))
 
    'load index array
    dim index$(numFiles)
    scan
    for i = 1 to numFiles
        open HelpDir$ + info$(i,0) for input as #file
            txt$ = INPUT$(#file, lof(#file))
            index$(i) = GetTitle$(txt$); chr$(0); info$(i,0)
        close #file
    next i
 
    sort index$(), 1, numFiles
    #s.index "reload"
 
 
'    gosub [hint]    '<--- Comment out when no longer needed.
 
    #s.middle "* * * HINTS * * *";chr$(13);chr$(10);_
            "A handy way to browse the results pages...";chr$(13);chr$(10);_
            "Enter search term. Check the box to open in Quick Viewer.  ";_
            "Use the arrow keys to advance to the first or next page ";_
            "in the listbox. Each highlighted page will display in the ";_
            "Quick Viewer.";chr$(13);chr$(10);_
            "With the checkbox cleared, doing the same thing will open ";_
            "in a new tab in your browser.  A ctrl-w will usually close the tab.";chr$(13);chr$(10);_
            "";chr$(13);chr$(10);chr$(13);chr$(10);_
            "This textbox space is a work in progress. Still working on ";_
            "ideas for its use."
    wait
 
[mruList]
    wait
 
[dummy]
    wait
 
[setChk]
    #s.qvChkbx "set"
    chkSet = 1
    wait
 
[resetChk]
    #s.qvChkbx "reset"
    chkSet = 0
    wait
 
[tocButton]
    QuickViewPage$ = "libe3mnn.htm"
    call createBrowseControl HelpFileIndex$, ContentsFileName$, hFlag
    wait
 
[commandsButton]
    QuickViewPage$ = "libe2co3.htm"
    call createBrowseControl HelpDir$, QuickViewPage$, hFlag
    wait
 
[reservedButton]
    QuickViewPage$ = "libe6ldg.htm"
    call createBrowseControl HelpDir$, QuickViewPage$, hFlag
    wait
 
[textButton]
    QuickViewPage$ = "libe778l.htm"
    call createBrowseControl HelpDir$, QuickViewPage$, hFlag
    wait
 
[graphicButton]
    QuickViewPage$ = "libe233p.htm"
    call createBrowseControl HelpDir$, QuickViewPage$, hFlag
    wait
 
[findPages]
    #s.term "!contents? term$"
    if term$ = "" then
        redim found$(1)
        #s.pages "reload"
        wait
    end if
 
    dim found$(numFiles)
 
    for i = 1 to numFiles
 
        open HelpDir$ + info$(i,0) for input as #file
            txt$ = INPUT$(#file, lof(#file))
 
            if instr(txt$, term$) >0 then
                found$(i) = GetTitle$(txt$); chr$(0); info$(i,0)
                #s.pages "reload"
            end if
        close #file
 
    next
    wait
 
[openBrowser]
    'open user's default browser
    run "rundll32.exe url.dll,FileProtocolHandler "; chr$(34); HelpFileIndex$ + ContentsFileName$; chr$(34)
    wait
 
[displaySelectedPage]
    #s.pages "selection? FileName$"
    FileName$ = word$(FileName$, 2, chr$(0))
 
    if chkSet = 0 then
    'open in user's default browser or new tab
        run "rundll32.exe url.dll,FileProtocolHandler "; chr$(34); HelpDir$; FileName$; chr$(34)
    else
        call createBrowseControl HelpDir$, FileName$, hFlag
    end if
    wait
 
[pickBox]
    #s.index "selection? qvp$"
    qvp$ = word$(qvp$, 2, chr$(0))
    call createBrowseControl HelpDir$, qvp$, hFlag
    wait
 
[help]
    WindowWidth = 400
    WindowHeight = 290
    statictext #h.hlp "", 10, 10, 390, 280
    open "How to use" for window as #h
    #h "trapclose [noMoreh]"
    hlpWdoOpen = 1
    gosub [printHlp]
    wait
    [noMoreh]
    close #h
    hlpWdoOpen = 0
    wait
 
[quit]
    close #s
    close #atl
    if hlpWdoOpen = 1 then close #h :hlpWdoOpen = 0
    end
 
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXSUBS AND FUNCTIONS
 
'credit: Alyce's entry.
'extract title from html text
function GetTitle$(s$)
    marker1=instr(upper$(s$), "<A NAME=")
    marker1=instr(upper$(s$), "<B>",marker1)+3
    marker2=instr(upper$(s$), "</B>", marker1)
    lenTitle=marker2-marker1
    GetTitle$=mid$(s$,marker1,lenTitle)
    end function
 
'borrowed from Stefan Pendl
'added 5/9/11
function GetModuleFileName$()
    nSize = _MAX_PATH + 1
    lpFilename$ = space$(nSize); CHR$(0)
    calldll #kernel32, "GetModuleFileNameA",_
        hModule     as uLong,_
        lpFilename$ as ptr,_
        nSize       as uLong,_
        result      as uLong
    if result > 0 then GetModuleFileName$ = trim$(lpFilename$)
end function
 
function GetFolder$(Path$)
    pos = 1
    GetFolder$ = Path$
    while pos > 0
        pos = instr(Path$, "\", pos)
         if pos > 0 then
            GetFolder$ = left$(Path$, pos)
            pos = pos + 1
        end if
    wend
end function
 
 
sub createBrowseControl D$, F$, byref hATL
    if hATL then
        CallDLL #user32, "DestroyWindow", _
            hATL   As ulong, _
            result As long
            hATL   = 0
    end if
 
    hWndContainer = hWnd(#s.resource)   'graphicbox handle
 
    callDLL #user32, "GetWindowLongA", _
        hWndContainer  as ulong, _
        _GWL_HINSTANCE as long, _
                 hInst as ulong
 
    ResName$ = D$ + F$                  'file to display
    ch = 366 - adj
    style = _WS_CHILD or _WS_VISIBLE or _WS_VSCROLL
 
    CallDLL #user32, "CreateWindowExA", _
    _WS_EX_STATICEDGE As long, _        'extended type
           "AtlAxWin" As ptr, _         'class name
             ResName$ As ptr, _         'resource file name & path
                style As long, _        'window style
                    1 As long, _        'left x pos
                    1 As long, _        'top y pos
                  729 As long, _        'width
                   ch As long, _        'height
        hWndContainer As ulong, _       'handle of container
                  100 As long, _        'handle to menu or child window ID
                hInst As ulong, _       'parent instance handle
                    0 As long, _        'window creation data
                 hATL As ulong          'handle of active template library control
 
    #s.htmlName "Help file: "; F$
end sub
 
[printHlp]
    ' Help window contents
    hlp$ =  "Find button -";chr$(13);_
            "  Type search term into textbox. Results are shown in listbox below.";chr$(13);_
            "  Single-click a result to display the page in your default browser.";chr$(13);_
            "  Check the box to display results in the Quick Viewer window.";chr$(13);chr$(13);_
            "Open Default Browser button -";chr$(13);_
            "  Click button to open your default browser to Table of Contents.";chr$(13);chr$(13);_
            "Index -";chr$(13);_
            "  Single-click an Indexed item in listbox to view it in the Quick Viewer.";chr$(13);chr$(13);_
            "Quick Viewer -";chr$(13);_
            "  Select from the 5 buttons to view a pre-selected help topic.";chr$(13);chr$(13);_
            "                   ABOUT LB HELP SEARCH ASSISTANT";chr$(13);_
            "                                        Version 2.0";chr$(13);_
            "                                      May 15, 2011";chr$(13);_
            "                                          By: jaba"
    print #h.hlp, hlp$
    return
 
[hint]
    notice "A handy way to browse the results pages...";chr$(13);_
            "Enter search term. Check the box to open in Quick Viewer.";chr$(13);_
            "Use the arrow keys to advance to the first or next page";chr$(13);_
            "in the listbox. Each highlighted page will display in the";chr$(13);_
            "Quick Viewer.";chr$(13);chr$(13);_
            "With the checkbox cleared, doing the same thing will open";chr$(13);_
            "in a new tab in your browser. A ctrl-w will usually close the tab."
    return
 
function fileExists(path$, filename$)
    files path$, filename$, info$()
    fileExists = val(info$(0, 0))
end function
 
[defineColorBar]
    graphicbox #s.c1 230, 677, 42, 15
        statictext #s.l1 "yellow", 230, 662, 40, 15
    graphicbox #s.c2 272, 677, 42, 15
        statictext #s.l2 "brown", 272, 662, 40, 15
    graphicbox #s.c3 314, 677, 42, 15
        statictext #s.l3 "red", 314, 662, 40, 15
    graphicbox #s.c4 356, 677, 42, 15
        statictext #s.l4 "darkred", 356, 662, 40, 15
    graphicbox #s.c5 398, 677, 42, 15
        statictext #s.l5 "pink", 398, 662, 40, 15
    graphicbox #s.c6 440, 677, 42, 15
        statictext #s.l6 "darkpink", 440, 662, 40, 15
    graphicbox #s.c7 482, 677, 42, 15
        statictext #s.l7 "blue", 482, 662, 40, 15
    graphicbox #s.c8 524, 677, 42, 15
        statictext #s.l8 "darkblue", 524, 662, 40, 15
    graphicbox #s.c9 566, 677, 42, 15
        statictext #s.l9 "green", 566, 662, 40, 15
    graphicbox #s.c10 608, 677, 42, 15
        statictext #s.l10 "darkgreen", 608, 662, 40, 15
    graphicbox #s.c11 650, 677, 42, 15
        statictext #s.l11 "cyan", 650, 662, 40, 15
    graphicbox #s.c12 692, 677, 42, 15
        statictext #s.l12 "darkcyan", 692, 662, 40, 15
    graphicbox #s.c13 734, 677, 42, 15
        statictext #s.l13 "white", 734, 662, 40, 15
    graphicbox #s.c14 776, 677, 42, 15
        statictext #s.l14 "black", 776, 662, 40, 15
    graphicbox #s.c15 818, 677, 42, 15
        statictext #s.l15 "lightgray", 818, 662, 40, 15
    graphicbox #s.c16 860, 677, 42, 15
        statictext #s.l16 "darkgray", 860, 662, 40, 15
return
 
[colorBar]
    #s.l1 "!font arial 7"
    #s.l2 "!font arial 7"
    #s.l3 "!font arial 7"
    #s.l4 "!font arial 7"
    #s.l5 "!font arial 7"
    #s.l6 "!font arial 7"
    #s.l7 "!font arial 7"
    #s.l8 "!font arial 7"
    #s.l9 "!font arial 7"
    #s.l10 "!font arial 7"
    #s.l11 "!font arial 7"
    #s.l12 "!font arial 7"
    #s.l13 "!font arial 7"
    #s.l14 "!font arial 7"
    #s.l15 "!font arial 7"
    #s.l16 "!font arial 7"
 
    #s.c1 "fill yellow; flush"
    #s.c2 "fill brown; flush"
    #s.c3 "fill red; flush"
    #s.c4 "fill darkred; flush"
    #s.c5 "fill pink; flush"
    #s.c6 "fill darkpink; flush"
    #s.c7 "fill blue; flush"
    #s.c8 "fill darkblue; flush"
    #s.c9 "fill green; flush"
    #s.c10 "fill darkgreen; flush"
    #s.c11 "fill cyan; flush"
    #s.c12 "fill darkcyan; flush"
    #s.c13 "fill white; flush"
    #s.c14 "fill black; flush"
    #s.c15 "fill lightgray; flush"
    #s.c16 "fill darkgray; flush"
return