May 31, 2011 - This version is submitted for Challenge judging.
' LB Help Search entry' Author: jaba (JackBurman)' 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' v2.0.1 -"- in progress...added current displayed file name to status bar' work on custom window height resizer (not using)' v2.1.0NB May 19, 2011 Redesigned to fit 800x600 display. Resizable.'' 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 wContainer, hContainer
Open"atl"ForDLLAs#atl
CallDLL#atl,"AtlAxWinInit", Ret Aslongnomainwin[setupGUIWdo]WindowWidth=800WindowHeight=560UpperLeftX=DisplayWidth-WindowWidthUpperLeftY=2'***bannergraphicbox#s.banner 1,1,610,25button#s.content "Open Default Browser",[openBrowser], UL,610,0,146,25'***help button'is there a bmp file for help?if fileExists(DefaultDir$,"Help_brown.bmp")thenbmpbutton#s.hlp "Help_brown.bmp",[help], UR,4,0
hBtn =1elsebutton#s.hlp "?",[help], UR,14,0
hBtn =0endif'***Quick Viewergraphicbox#s.heading 0,25,115,25button#s.toc "LB 4.04 Contents",[tocButton], UL,0,50,115,25'points to libe3mnn.htmbutton#s.commands "Command Reference",[commandsButton], UL,0,76,115,25'points to libe2co3.htmbutton#s.reserve "Reserved Words",[reservedButton], UL,0,102,115,25'points to libe6ldg.htmbutton#s.txt "Text Commands",[textButton], UL,0,128,115,25'points to libe778l.htmbutton#s.graph "Graphics Commands",[graphicButton], UL,0,154,115,25'points to libe233p.htmgraphicbox#s.resource 0,185,610,320'container for browser control
wContainer =610
hContainer =320'***notesTextboxColor$="buttonface"graphicbox#s.notes 117,25,492,25stylebits#s.middle, _WS_VSCROLL OR _ES_MULTILINE, _ES_AUTOHSCROLL,0,0textbox#s.middle 117,50,493,130'***searchTextboxColor$="buttonface"graphicbox#s.explorer 610,25,172,25textbox#s.term 610,50,132,25stylebits#s.default, _BS_DEFPUSHBUTTON,0,0,0button#s.default "Find",[findPages], UL,742,50,40,25ListboxColor$="buttonface"listbox#s.pages, found$(),[displaySelectedPage],610,76,172,85checkbox#s.qvChkbx,"Check to open in Quick Viewer",[setChk],[resetChk],614,165,180,18'***indexListboxColor$="buttonface"stylebits#s.index, _WS_HSCROLL,0,0,0listbox#s.index, index$(),[pickBox],610,185,172,320'***status barstatictext#s.status,"Right-click browser window for BACK/FORWARD.",10,(WindowHeight-50),210,15' statictext #s.htmlName, "", 250, (WindowHeight-45), 210, 15 '10, 678, 210, 15[openGUIWdo]open WdoTitle$ forwindowas#s
#s "trapclose [quit]"#s.index "singleclickselect"#s.pages "singleclickselect"#s.qvChkbx "set":chkSet =1#s "resizehandler [resized]"#s "font ms_sans_serif 9"#s.status "!font arial 7"' #s.htmlName$ "!font arial 7"'color the banner#s.banner "down; fill buttonface"#s.banner "place 0 15; color 88 66 55; 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 / Index "#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.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 "!setfocus"dim info$(10,10)files HelpDir$,"*.htm", info$()
numFiles =val(info$(0,0))'load index arraydim index$(numFiles)scanfor i =1to numFiles
open HelpDir$ + info$(i,0)forinputas#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 it's use."wait[resized]
wWid =WindowWidth
wHig =WindowHeight
upperVert =int(wWid-184)'upper middle vertical edge#s.banner "locate 1 1 "; upperVert-1;" "; 25#s.content "!locate "; upperVert;" 0";" 154";" "; 25' #s.hlp "locate "; wWid;" "; 0#s.explorer "locate "; upperVert;" 25";" 178";" "; 25#s.term "!locate "; upperVert;" 50";" 138";" "; 25#s.default "!locate "; upperVert+138;" 50";" 40";" "; 25#s.notes "locate 117 25 "; upperVert-119;" "; 25#s.middle "!locate 117 50 "; upperVert-117;" "; 130#s.pages "locate "; upperVert;" 76";" 178"; " "; 85#s.qvChkbx "locate "; upperVert;" 165";" 178";" "; 18#s.index "locate "; upperVert;" 185";" 178"; " "; wHig-210#s.resource "locate 0 185 "; upperVert;" "; wHig-210
wContainer = upperVert
hContainer = wHig -212#s.status "!locate 10 "; wHig-20;" 210";" "; 15if hFlag thencalldll#user32,"MoveWindow",_
hFlag Asulong,_
0Aslong,_
0Aslong,_
wContainer Aslong,_
hContainer Aslong,_
1Aslong,_
result Asvoidendif#s "refresh"wait[setChk]#s.qvChkbx "set"
chkSet =1wait[resetChk]#s.qvChkbx "reset"
chkSet =0wait[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$ =""thenredim found$(1)#s.pages "reload"waitendifdim found$(numFiles)for i =1to numFiles
open HelpDir$ + info$(i,0)forinputas#file
txt$ =INPUT$(#file,lof(#file))ifinstr(txt$, term$)>0then
found$(i)= GetTitle$(txt$); chr$(0); info$(i,0)#s.pages "reload"endifclose#file
nextwait[openBrowser]'open user's default browserrun"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 =0then'open in user's default browser or new tabrun"rundll32.exe url.dll,FileProtocolHandler "; chr$(34); HelpDir$; FileName$; chr$(34)elsecall createBrowseControl HelpDir$, FileName$, hFlag
endifwait[pickBox]#s.index "selection? qvp$"
qvp$ =word$(qvp$,2,chr$(0))call createBrowseControl HelpDir$, qvp$, hFlag
wait[help]WindowWidth=400WindowHeight=290statictext#h.hlp "",10,10,390,280open"How to use"forwindowas#h
#h "trapclose [closeHlp]"
hlpWdoOpen =1gosub[printHlp]wait[closeHlp]close#h
hlpWdoOpen =0wait[quit]close#s
close#atl
if hlpWdoOpen =1thenclose#h :hlpWdoOpen =0end'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXSUBS AND FUNCTIONS'credit: Alyce's entry.'extract title from html textfunction 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)endfunction'borrowed from Stefan Pendl'added 5/9/11function GetModuleFileName$()
nSize = _MAX_PATH +1
lpFilename$ =space$(nSize); CHR$(0)calldll#kernel32,"GetModuleFileNameA",_
hModule asuLong,_
lpFilename$ asptr,_
nSize asuLong,_
result asuLongif result >0then GetModuleFileName$ =trim$(lpFilename$)endfunctionfunction GetFolder$(Path$)
pos =1
GetFolder$ = Path$
while pos >0
pos =instr(Path$,"\", pos)if pos >0then
GetFolder$ =left$(Path$, pos)
pos = pos +1endifwendendfunctionfunction fileExists(path$, filename$)files path$, filename$, info$()
fileExists =val(info$(0,0))endfunctionsub createBrowseControl D$, F$,byref hATL
if hATL thenCallDLL#user32,"DestroyWindow", _
hATL Asulong, _
result Aslong
hATL =0endif
hWndContainer =hWnd(#s.resource)'graphicbox handlecallDLL#user32,"GetWindowLongA", _
hWndContainer asulong, _
_GWL_HINSTANCE aslong, _
hInst asulong
ResName$ = D$ + F$ 'file to display
cw = wContainer
ch = hContainer
style = _WS_CHILD or _WS_VISIBLE or _WS_VSCROLL
CallDLL#user32,"CreateWindowExA", _
_WS_EX_STATICEDGE Aslong, _ 'extended type"AtlAxWin"Asptr, _ 'class name
ResName$ Asptr, _ 'resource file name & path
style Aslong, _ 'window style1Aslong, _ 'left x pos1Aslong, _ 'top y pos
cw Aslong, _ 'width
ch Aslong, _ 'height
hWndContainer Asulong, _ 'handle of container100Aslong, _ 'handle to menu or child window ID
hInst Asulong, _ 'parent instance handle0Aslong, _ 'window creation data
hATL Asulong'handle of active template library control' #s.htmlName "Help file: "; F$endsub[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.1.0NB";chr$(13);_
" May 19, 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
Link to bitmap for help button.
May 31, 2011 - This version is submitted for Challenge judging.