IDETool to get Win32 help

Share your advanced PureBasic knowledge/code with the community.
User avatar
Caronte3D
Addict
Addict
Posts: 1355
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

IDETool to get Win32 help

Post by Caronte3D »

Long time ago I was get an IDEtool from someone on this forum, I have search for, but don't find it anymore.
Anyway I wrote this IDEtool to get Win32 help.
You need the old win32.chm file, you can download it from:
https://sourceforge.net/projects/win32-help-chm/files/
Then uncompress and put the win32.chm file in the PureBasic folder.

Compile this code below and save the exe somewhere with the name: WinApiHelpTool
Then create an IDETool:
CommandLine: Choose the saved WinApiHelpTool.exe
Arguments: %WORD
Shortcut: CTRL + F1

That's all, now when you need help about a WinApi word, simply click the word and push CTRL+F1

Code: Select all

EnableExplicit

Procedure FindControlByClass(hwndParent, classNameTarget.s)
  Protected hwndChild = GetWindow_(hwndParent, #GW_CHILD)
  
  While hwndChild
    Protected className.s = Space(256)
    GetClassName_(hwndChild, @className, 255)
    
    If className = classNameTarget
      ProcedureReturn hwndChild
    Else
      Protected result = FindControlByClass(hwndChild, classNameTarget)
      If result : ProcedureReturn result : EndIf
    EndIf
    
    hwndChild = GetWindow_(hwndChild, #GW_HWNDNEXT)
  Wend
  
  ProcedureReturn 0
EndProcedure

Procedure OpenCHMWithSearch(chmFile.s, searchTerm.s)
  Protected hhPath.s = "hh.exe"
  Protected pid = RunProgram(hhPath, chmFile, "")
  CloseConsole()
  
  If pid    
    Protected hwndCHM = 0
    Protected i
    For i = 0 To 100
      hwndCHM = FindWindow_("HH Parent", 0)
      If hwndCHM : Break : EndIf
      Delay(150)
    Next
    
    If hwndCHM
      SetForegroundWindow_(hwndCHM)
      Delay(150)

      ; Search for TabControl
      Protected hwndTab = FindControlByClass(hwndCHM, "SysTabControl32")
      
      If hwndTab        
        ; Select Tab-1
        SendMessage_(hwndTab, #TCM_SETCURSEL, 1, 0)
        
        ; Simulate Tab change event
        Protected notify.NMHDR
        notify\hwndFrom = hwndTab
        notify\idFrom = GetDlgCtrlID_(hwndTab)
        notify\code = #TCN_SELCHANGE
        SendMessage_(hwndCHM, #WM_NOTIFY, notify\idFrom, @notify)
        
        Delay(150)
        
        
          ; Iterate tabs to show the StringGadget
          keybd_event_(#VK_CONTROL, 0, 0, 0)
          keybd_event_(#VK_TAB, 0, 0, 0)
          keybd_event_(#VK_TAB, 0, #KEYEVENTF_KEYUP, 0)
          keybd_event_(#VK_TAB, 0, 0, 0)
          keybd_event_(#VK_TAB, 0, #KEYEVENTF_KEYUP, 0)
          keybd_event_(#VK_TAB, 0, 0, 0)
          keybd_event_(#VK_TAB, 0, #KEYEVENTF_KEYUP, 0)
          keybd_event_(#VK_TAB, 0, 0, 0)
          keybd_event_(#VK_TAB, 0, #KEYEVENTF_KEYUP, 0)
          keybd_event_(#VK_CONTROL, 0, #KEYEVENTF_KEYUP, 0)
        
        
        ; Find StringGadget inside actual TabPanel
        Protected hwndEdit = FindControlByClass(hwndCHM, "Edit")
        If hwndEdit
          Debug "Campo de texto encontrado: " + Str(hwndEdit)
          SetFocus_(hwndEdit)
          
          SetClipboardText(searchTerm)
          Delay(150)
          
          ; Simulate Ctrl + V
          keybd_event_(#VK_CONTROL, 0, 0, 0)
          keybd_event_(#VK_V, 0, 0, 0)
          keybd_event_(#VK_V, 0, #KEYEVENTF_KEYUP, 0)
          keybd_event_(#VK_CONTROL, 0, #KEYEVENTF_KEYUP, 0)
          
          Delay(150)
          
          ; Simulate ENTER
          keybd_event_(#VK_RETURN, 0, 0, 0)
          Delay(50)
          keybd_event_(#VK_RETURN, 0, #KEYEVENTF_KEYUP, 0)
        Else
          MessageRequester("Error", "StringGadget not found.")
        EndIf
      Else
        MessageRequester("Error", "TabPanel not found.")
      EndIf
    Else
      MessageRequester("Error", "Can't find the visor CHM window.")
    EndIf
  Else
    MessageRequester("Error", "Can't execute hh.exe.")
  EndIf
EndProcedure




Define chmPath.s = #PB_Compiler_Home+"\win32.chm"
Define termino.s = ProgramParameter()

If termino=""
  termino="Legal Information"
Else
  If Right(termino,1)="_"
    termino= Left(termino, Len(termino)-1)
  Else
    End
  EndIf
EndIf

OpenCHMWithSearch(chmPath, termino)
Test example:
Image
Last edited by Caronte3D on Mon Jun 16, 2025 9:42 am, edited 4 times in total.
Quin
Addict
Addict
Posts: 1122
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: IDETool to get Win32 help

Post by Quin »

Nice one! Thanks for sharing 8)
BarryG
Addict
Addict
Posts: 4122
Joined: Thu Apr 18, 2019 8:17 am

Re: IDETool to get Win32 help

Post by BarryG »

You don't need a tool to do this. Just put "Win32.hlp" in the "Help" folder and pressing F1 on an API command will open it in that doc. ;)
User avatar
HeX0R
Addict
Addict
Posts: 1187
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: IDETool to get Win32 help

Post by HeX0R »

Oh oh, an error in the matrix :mrgreen:
User avatar
Caronte3D
Addict
Addict
Posts: 1355
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: IDETool to get Win32 help

Post by Caronte3D »

BarryG wrote: Sun Jun 15, 2025 10:09 pm You don't need a tool to do this. Just put "Win32.hlp" in the "Help" folder and pressing F1 on an API command will open it in that doc. ;)
Ouch! :? I don't know about it :|
EDIT: Where is the help folder?
EDIT2: Ok, seems we need to create the help folder, also we need to install WinHlp32.exe in Windows to overwrite the dummy one, but I don't like it (thanks anyway).
BarryG
Addict
Addict
Posts: 4122
Joined: Thu Apr 18, 2019 8:17 am

Re: IDETool to get Win32 help

Post by BarryG »

Caronte3D wrote: Sun Jun 15, 2025 10:31 pmwe need to install WinHlp32.exe in Windows to overwrite the dummy one, but I don't like it (thanks anyway).
FWIW, I never had to install "WinHlp32.exe" on my Win 10 and 11 PCs to make it work with the IDE.
User avatar
Caronte3D
Addict
Addict
Posts: 1355
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: IDETool to get Win32 help

Post by Caronte3D »

BarryG wrote: Mon Jun 16, 2025 10:49 am
Caronte3D wrote: Sun Jun 15, 2025 10:31 pmwe need to install WinHlp32.exe in Windows to overwrite the dummy one, but I don't like it (thanks anyway).
FWIW, I never had to install "WinHlp32.exe" on my Win 10 and 11 PCs to make it work with the IDE.
On my case, F1 open the web browser with this page:
https://support.microsoft.com/es-es/top ... 149da3973b
Post Reply