Guidance
指路人
g.yi.org
software / rapidq / Examples / Tools - IDE, Designer, Builder / FreeQ IDE src / inc ide / help.inc

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  

     FUNCTION Show_HTMLHelp(inhwnd AS LONG,inHelpfile AS STRING) AS LONG
      Show_HTMLHelp = HtmlHelp(inhwnd, inHelpfile, HH_DISPLAY_TOC, 0)
     END FUNCTION

     FUNCTION Show_HTMLHelp_ConTextID(inhwnd AS LONG,inHelpfile AS STRING,inContext AS LONG) AS LONG
      Show_HTMLHelp_ConTextID = HtmlHelp(inhwnd, inHelpfile, HH_HELP_CONTEXT, inContext)
     END FUNCTION

     FUNCTION Show_HTMLHelp_Index(inhwnd AS LONG, inHelpfile AS STRING, inKeyword AS STRING) AS LONG
      DEFSTR TheFullURL = inHelpfile + "::/" + inKeyword + ".html"
      Show_HTMLHelp_Index = htmlHelpString(inhwnd, inHelpfile, HH_DISPLAY_TOPIC, 0)

      DEFSTR s = inKeyword
      DEFSTR Lnk = inKeyword + ".html"
      DIM hlpLink AS HH_AKLINK
      hlpLink.cbStruct =     SIZEOF(hlpLink)
      hlpLink.fReserved =    False
      hlpLink.pszKeywords =  VARPTR(s)
      hlpLink.pszUrl =       VARPTR(Lnk)
      hlpLink.pszMsgText =   0
      hlpLink.pszMsgTitle =  0
      hlpLink.pszWindow =    0
      hlpLink.fIndexOnFail = True
      HtmlHelp(GetDesktopWindow(), inHelpfile, HH_KEYWORD_LOOKUP, UDTPTR(hlpLink))
     END FUNCTION


' *****  code contribution by David Burkley *****
     FUNCTION Show_HTMLHelp_Search(inhwnd AS LONG, inHelpfile AS STRING, inKeyword AS STRING) AS LONG
      DIM HHQuery AS HH_FTS_QUERY
      MEMSET(UDTPTR(HHQuery), 0, SIZEOF(HHQuery))     'null out static
      HHQuery.cbStruct        = SIZEOF(HHQuery)
      HHQuery.fUniCodeStrings = False
      HHQuery.iProximity      = -1
      HHQuery.fStemmedSearch  = False
      HHQuery.fTitleOnly      = False
      HHQuery.fExecute        = True
      HHQuery.pszWindow       = 0

    ' Start of Copy and Paste (Section 3, How to programatically make use of the Search tab)
    ' Define variables for the Search tab component Handles
      DEFLNG hHH, hHHChild, hHHButton, hHHEdit
    ' Define a variable for the word to be searched for (for demo purposes... I'm pre-defining it)
      DEFSTR Token = inKeyword + CHR$(0)

    ' Even though the ".fExecute" does not work...
    ' I still filled in the 2 empty UDT variables
    ' (JUST as a safety precaution)
      HHQuery.pszSearchQuery  = VARPTR(Token)
      HHQuery.pszWindow       = GetDesktopWindow()
    ' Call HtmlHelp to display the Search tab
    ' and get the Handle of the displayed CHM window
      hHH = HtmlHelp(GetDesktopWindow(), inHelpfile, HH_DISPLAY_SEARCH, HHQuery)

      IF hHH THEN
        'Get the Handle of the "second" HH Child (parameter #3 indicates this)
        'The "first" HH Child Handle is the handle to the container that holds the displayed HTML page
       hHHChild = GetChildHandle(hHH , "HH Child" , 2)
        'If the Handle exists... proceed
       IF hHHChild THEN
            'From this point on... getting the "proper" Search tab component Handles
            '(that need to be manipulated) will depend on "how" the CHM was created.
            'I could be wrong about this but... I believe clicking the "Change project options" button
            '(in HTML Help Workshop) and changing the "Compatibility" to "1.1 or later" (under "Compiler" tab)
            'may be the key to creating a CHM that works with the following code.
            'If the Search tab has more components than...
            'a Label, an Edit, a Button, a 2nd Label, a Listbox, a 2nd Button...
            'the following code needs to be heavily modified to find the "proper"
            'components that need to be manipulated.
            '
            'Get the Handle of the "first" Button (aka "List Topics" button)
        hHHButton = GetChildHandle(hHHChild , "Button" , 1)
            'Get the Handle of the "first" (and only) Edit box
        hHHEdit = GetChildHandle(hHHChild , "Edit" , 1)
            'If the Handles exists... proceed
        IF hHHEdit AND hHHButton THEN
                'Set the text of the Edit box with the word to be searched for
                '(footnote: you could, if you wanted to, set the text to... "button AND caption", or "button NOT caption", etc.)
         SetWindowText(hHHEdit , Token)
                'Here you need to simulate a key press to "activate" the "List Topics" button
                '(if you don't activate it... simulating a button click won't work)
         SendMessage(hHHEdit , WM_KEYUP , 0 , 0)
                'And finally... simulate a button click on the "List Topics" button
         SendMessage(hHHButton , BM_CLICK , 0 , 0)
        END IF
       END IF
      END IF

      RESULT = hHH
     END FUNCTION



     SUB Close_HTMLHelp()
      HtmlHelp 0, CHR$(0), HH_CLOSE_ALL, 0
     END SUB



     SUB Show_File(inHelpfile AS STRING)
      DIM tmpFilePath AS STRING
      DIM tmpFileName AS STRING
      ShellExecute GetDesktopWindow(), "", StripFileName(inHelpFile), "", StripPath(inHelpFile), SW_NORMAL
     END SUB



     SUB HelpOnTopicClick
      DEFSTR TheHelpFname = IDE.CompilerHelpFile
      IF IDE.ModuleType(MFE_Tab.TabIndex) > 0 THEN TheHelpFname = IDE.FBCompilerHelpFile

      IF re.SelText <> "" THEN
       Show_HTMLHelp_Index(GetDesktopWindow(), TheHelpFname, re.SelText)
      ELSE
       DIM guida AS STRING
       guida = IDE_GetKeywordFromText(re.WordAtCursor(), ")(" + Quot$)      'don't filter _ or . for Screen.xxx etc.
       Show_HTMLHelp_Index(GetDesktopWindow(), TheHelpFname, guida)
      END IF
     END SUB


     SUB HelpSearchCHMOnTopicClick
      DEFSTR TheHelpFname = IDE.CompilerHelpFile
      IF IDE.ModuleType(MFE_Tab.TabIndex) > 0 THEN TheHelpFname = IDE.FBCompilerHelpFile

      IF re.SelText <> "" THEN
       Show_HTMLHelp_Search(GetDesktopWindow(), TheHelpFname, re.SelText)
      ELSE
       DIM guida AS STRING
       guida = IDE_GetKeywordFromText(re.WordAtCursor(), ")(" + Quot$)      'don't filter _ or . for Screen.xxx etc.
       Show_HTMLHelp_Search(GetDesktopWindow(), TheHelpFname, guida)
      END IF
     END SUB


     SUB mnuHelpClick
      MainHelpClick(ContentHelpMenu.Handle)
     END SUB


     SUB mnuHelp2Click
      MainHelpClick(Content2Menu.Handle)
     END SUB


     SUB mnuHelpWinClick
      MainHelpClick(WinHelpMenu.Handle)
     END SUB



     SUB MainHelpClick(theHnd AS INTEGER)

      DEFSTR TheHelpFname = IDE.CompilerHelpFile
      IF IDE.ModuleType(MFE_Tab.TabIndex) > 0 THEN TheHelpFname = IDE.FBCompilerHelpFile

      SELECT CASE theHnd
      CASE ContentHelpMenu.Handle         'help (basic)
       RUN "rundll32.exe url.dll,FileProtocolHandler " + TheHelpFname

      CASE Content2Menu.Handle        'examples
       RUN "rundll32.exe url.dll,FileProtocolHandler " + STRIPPATH(TheHelpFname) + "\examples.hlp"

      CASE ContentTopicHelpMenu.Handle        'help on topic
       HelpOnTopicClick

      CASE WinHelpMenu.Handle         '"Windows API help"
       RUN "rundll32.exe url.dll, FileProtocolHandler " + Quot$ + STRIPPATH(IDE.CompilerHelpFile) + "\win32_2.hlp" + Quot$

      CASE REpopupHelpWord.Handle         'right click context help
       Show_HTMLHelp_Index(GetDesktopWindow(), TheHelpFname, (REpopupHelpWord.CAPTION - "Help with "))

      CASE ELSE
       SHOWMESSAGE "internal help error"
      END SELECT
     END SUB



     SUB IDE_SearchWeb4Word(inText AS STRING)
      DEFSTR s = IDE.SearchEngine + inText
      ShellExecute(0, "open", s, "", "", 1)
      s = ""
     END SUB

掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Wed 2024-5-8  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2010-12-07 21:18:03