slight modification of code
Code: Select all
EnableExplicit
If CreateMutex_(0, 1, "MSDN.CHM") = 0 Or GetLastError_() <> 0
PostMessage_(FindWindow_(0,"MSDN"), #WM_CLOSE, 0, 0)
EndIf
Prototype HtmlHelp(a, b.s, c, d)
#HH_DISPLAY_TOC = 1
#HH_DISPLAY_TOPIC = $0
#HH_HELP_FINDER = $0
#HH_SET_WIN_TYPE = $4
#HH_GET_WIN_TYPE = $5
#HH_GET_WIN_HANDLE = $6
#HH_SYNC = $9
#HH_KEYWORD_LOOKUP = $D
#HH_DISPLAY_TEXT_POPUP = $E
#HH_HELP_CONTEXT = $F
#HH_TP_HELP_CONTEXTMENU = $10
#HH_TP_HELP_WM_HELP = $11
Structure HH_AKLINK
cbStruct.l
fReserved.l
pszKeywords.s
pszUrl.s
pszMsgText.s
pszMsgTitle.s
pszWindow.s
fIndexOnFail.l
EndStructure
Procedure HtmlHelp(HelpFile.s, Keyword.s) ;by ts-soft (https://www.purebasic.fr/english/viewtopic.php?p=355981#p355981)
Protected AKLIN.HH_AKLINK, HtmlHelp_.HtmlHelp, hWnd
Protected DLL = OpenLibrary(#PB_Any, "HHCtrl.ocx")
If DLL
HtmlHelp_ = GetFunction(DLL, "HtmlHelpW")
With AKLIN
\cbStruct = SizeOf(HH_AKLINK)
\fReserved = 0
\pszKeywords = Keyword
\fIndexOnFail = #True
EndWith
hWnd = HtmlHelp_(0, HelpFile, #HH_KEYWORD_LOOKUP, AKLIN)
;HtmlHelp_(0, HelpFile, #HH_DISPLAY_TOC, 0)
CloseLibrary(DLL)
ProcedureReturn hWnd
EndIf
EndProcedure
Define chm.s, http.s, word.s, hWnd_chm
Select CountProgramParameters()
Case 2
chm = ProgramParameter(0)
If FindString(chm, "http")
http = chm
chm = ""
EndIf
word = ProgramParameter(1)
Default
chm = GetPathPart(GetEnvironmentVariable("PB_TOOL_IDE")) + "Help\mini.chm"
word = ProgramParameter(0)
If word = ""
word = GetEnvironmentVariable("PB_TOOL_Word")
EndIf
EndSelect
word = RTrim(word, "_")
word = LTrim(word, "#")
If http <> ""
http = ReplaceString(http, "$WORD", word)
http = URLEncoder(http)
RunProgram(http)
Else
hWnd_chm = HtmlHelp(chm, word)
If hWnd_chm
;MessageRequester("Debug", chm + #CRLF$ + word, #PB_MessageRequester_Info)
While IsWindow_(hWnd_chm)
Delay(1000)
Wend
Else
MessageRequester("Help file not found", "Please copy mini.chm to a 'Help' folder in the PureBasic installation folder or specify help file location and keyword as program parameters." + #CRLF$ + #CRLF$ + chm + #CRLF$ + word, #PB_MessageRequester_Info)
EndIf
EndIf
ps. Somehow GetEnvironmentVariable("PB_TOOL_Word") always returns empty, so at the moment that variable is useless?
Anyway, compile to exe, add tool with commandline as exe's path and arguments "C:\Tools\
MSDN\mini.chm" %WORD and shortcut of your choice (ALT+F1).
Online search:
Tools/configure Tools.../New/
Commandline:%path-to-whelp.exe%
Arguments:"
https://duckduckgo.com/?q=! $WORD site:
https://docs.microsoft.com/en-us/windows/win32/" %WORD
(example)
Shortcut: ALT+F2