分享

打开帮助文档CHM文件并且显示关键词(软件F1键功能)

 夜的影子 2018-01-31

打开帮助文档CHM文件并且显示关键词

常见代码编辑的F1键功能

  1. Function OpenHtmlHelp(hWndForm As HWnd,nFile As String,nKey As String  ) As HWnd '
  2.   
  3.   Dim hh As Function (ByVal hwndCaller As HWnd , ByVal pszFile As LPCSTR , ByVal uCommand As UINT , ByVal dwData As DWORD_PTR) As HWnd
  4.   Dim As Any Ptr library = Dylibload( "hhctrl.ocx" )
  5.   hh = Dylibsymbol( library, "HtmlHelpA" )
  6.   Dim  szPath      As  String 
  7.   Dim  szText      As  String  
  8.   Dim  hlk(7) As ULong
  9.   szPath=nFile & Chr(0) 'Help 文件名,带文件夹
  10.   szText=nKey & Chr(0) '要查寻的关键词
  11.   '  hlk.cbStruct = Sizeof(hlk)
  12.   '  hlk.pszKeywords = @szText
  13.   '  hlk.fIndexOnFail = True
  14.   hlk(0)=Sizeof(hlk)
  15.   hlk(2)=Strptr(szText)
  16.   hlk(7)=1
  17.   hh( hWndForm, Strptr(szPath), 0, Null)'HH_DISPLAY_TOPIC
  18.   Function=hh( hWndForm, Strptr(szPath), &H000D, @hlk(0))'HH_KEYWORD_LOOKUP
  19.   Dylibfree( library )
  20.   ' // Size = 32 bytes
  21.   'Type HH_AKLINK
  22.   '   cbStruct     As Long        ' int       cbStruct;     // sizeof this structure
  23.   '   fReserved    As Long        ' BOOL      fReserved;    // must be FALSE (really!)
  24.   '   pszKeywords  As ZString Ptr  ' LPCTSTR   pszKeywords;  // semi-colon separated keywords
  25.   '   pszUrl       As ZString Ptr  ' LPCTSTR   pszUrl;       // URL to jump to if no keywords found (may be NULL)
  26.   '   pszMsgText   As ZString Ptr  ' LPCTSTR   pszMsgText;   // Message text to display in MessageBox if pszUrl is NULL and no keyword match
  27.   '   pszMsgTitle  As ZString Ptr  ' LPCTSTR   pszMsgTitle;  // Message text to display in MessageBox if pszUrl is NULL and no keyword match
  28.   '   pszWindow    As ZString Ptr  ' LPCTSTR   pszWindow;    // Window to display URL in
  29.   '   fIndexOnFail As Long        ' BOOL      fIndexOnFail; // Displays index if keyword lookup fails.
  30.   'End Type
  31. End Function

用法举例:OpenHtmlHelp "X:\Help\Win32SDK.CHM","abc"

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多