HTML 帮助关键字查找

发布于 2024-07-14 08:42:37 字数 375 浏览 12 评论 0原文

我无法弄清楚如何进行关键字查找 ( HH_KEYWORD_LOOKUP)以在 HTML 帮助中工作。 如果我有一个显示如下的索引:

Machine
    Add
    Edit
    Selection

如何指定显示机器选择的关键字搜索? “机器;选择”调出机器关键字; “选择”和“机器选择”根本不起作用; “机器,选择”也不会,即使如果用户手动选择适当的主题,HTML 帮助查看器的“索引”选项卡中也会显示该内容。

I'm having trouble figuring out how to get keyword lookups (HH_KEYWORD_LOOKUP) to work in HTML Help. If I have an index that displays like this:

Machine
    Add
    Edit
    Selection

How do I specify a keyword search that brings up Machine Selection? "Machine; Selection" brings up the Machine keyword; "Selection" and "Machine Selection" don't work at all; neither does "Machine, Selection", even though that's what's displayed in the Index tab of the HTML Help Viewer if the user manually selects the appropriate topic.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

黎夕旧梦 2024-07-21 08:42:37

我想我读到(在我的许多谷歌搜索中)HH_KEYWORD_LOOKUP 在 HTML 帮助中被破坏了,叹息。 于是我想出了这个解决方案来进行搜索。 它将打开 chm 文件并在搜索框中输入关键字,然后按 ENTER 键手动进行搜索。

procedure PostKey(aKey: Word; const aShift: TShiftState; aSpeciaKey: Boolean);
type
  TShiftKeyInfo = record
    shift: Byte;
    vkey: Byte;
  end;
  byteset = set of 0..7;
const
  shiftkeys: array [1..3] of TShiftKeyInfo =
    ((shift: Ord(ssCtrl); vkey: VK_CONTROL),
    (shift: Ord(ssShift); vkey: VK_SHIFT),
    (shift: Ord(ssAlt); vkey: VK_MENU));
var
  flag: DWORD;
  bShift: ByteSet absolute aShift;
  i: Integer;
begin
  for i := 1 to 3 do
  begin
    if shiftkeys[i].shift in bShift then
      keybd_event(shiftkeys[i].vkey, MapVirtualKey(shiftkeys[i].vkey, 0), 0, 0);
  end; { For }
  if aSpeciaKey then
    flag := KEYEVENTF_EXTENDEDKEY
  else
    flag := 0;
  keybd_event(aKey, MapvirtualKey(aKey, 0), flag, 0);
  flag := flag or KEYEVENTF_KEYUP;
  keybd_event(aKey, MapvirtualKey(aKey, 0), flag, 0);
  for i := 3 downto 1 do
  begin
    if shiftkeys[i].shift in bShift then
      keybd_event(shiftkeys[i].vkey, MapVirtualKey(shiftkeys[i].vkey, 0),
        KEYEVENTF_KEYUP, 0);
  end; { For }
end;

procedure CHMSearch(aCHMFilename, aSearch: string);
var
  cfn: string;
  qry: THHFtsQuery;
  hnd: HWND;

  procedure DoSearch(aMsg: string);
  var
    i,n: Integer;
    c: Char;
    shift: TShiftState;
  begin
    if hnd = 0 then Exit;
    Windows.SetFocus(hnd);
    n := Length(aMsg);
    if n > 0 then
    begin
      for i := 1 to n do
      begin
        c := aMsg[i];
        shift := [];
        case c of
          'a'..'z': shift := [];
          'A'..'Z': shift := [ssShift];
          '_': // underscore key
          begin
            keybd_event(VK_SHIFT, 0, 0, 0);
            keybd_event(VK_OEM_MINUS, 0, 0, 0);
            keybd_event(VK_OEM_MINUS, 0, KEYEVENTF_KEYUP, 0);
            keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
            continue;
          end;
          '
: // $ key
          begin
            PostKey(Ord('4'), [ssShift], False);
            continue;
          end;

        end;
        PostKey(Ord(UpCase(c)), shift, False);
      end;
      PostKey(VK_RETURN, [], False);
      PostKey(VK_RETURN, [], False);
    end;
  end;

begin
  cfn := ChangeFileExt(aCHMFilename, '.chm');
  FillChar(qry, SizeOf(qry), 0);
  qry.cbStruct := SizeOf(THHFtsQuery);
  qry.fExecute := TRUE;
  HH.HtmlHelpA(GetDesktopWindow, PAnsiChar(AnsiString(cfn)), HH_DISPLAY_TOC, 0);
  hnd := HH.HtmlHelpA(GetDesktopWindow, PAnsiChar(AnsiString(cfn)), HH_DISPLAY_SEARCH,
    Cardinal(@qry));
  DoSearch(aSearch);
end;

I think I read (in my many google searches) that HH_KEYWORD_LOOKUP is broken in HTML help, sigh. So Ie came up with this solution to do a search. It will bring up the chm file and enter the keyword into the search box and press the ENTER key to manually do the search.

procedure PostKey(aKey: Word; const aShift: TShiftState; aSpeciaKey: Boolean);
type
  TShiftKeyInfo = record
    shift: Byte;
    vkey: Byte;
  end;
  byteset = set of 0..7;
const
  shiftkeys: array [1..3] of TShiftKeyInfo =
    ((shift: Ord(ssCtrl); vkey: VK_CONTROL),
    (shift: Ord(ssShift); vkey: VK_SHIFT),
    (shift: Ord(ssAlt); vkey: VK_MENU));
var
  flag: DWORD;
  bShift: ByteSet absolute aShift;
  i: Integer;
begin
  for i := 1 to 3 do
  begin
    if shiftkeys[i].shift in bShift then
      keybd_event(shiftkeys[i].vkey, MapVirtualKey(shiftkeys[i].vkey, 0), 0, 0);
  end; { For }
  if aSpeciaKey then
    flag := KEYEVENTF_EXTENDEDKEY
  else
    flag := 0;
  keybd_event(aKey, MapvirtualKey(aKey, 0), flag, 0);
  flag := flag or KEYEVENTF_KEYUP;
  keybd_event(aKey, MapvirtualKey(aKey, 0), flag, 0);
  for i := 3 downto 1 do
  begin
    if shiftkeys[i].shift in bShift then
      keybd_event(shiftkeys[i].vkey, MapVirtualKey(shiftkeys[i].vkey, 0),
        KEYEVENTF_KEYUP, 0);
  end; { For }
end;

procedure CHMSearch(aCHMFilename, aSearch: string);
var
  cfn: string;
  qry: THHFtsQuery;
  hnd: HWND;

  procedure DoSearch(aMsg: string);
  var
    i,n: Integer;
    c: Char;
    shift: TShiftState;
  begin
    if hnd = 0 then Exit;
    Windows.SetFocus(hnd);
    n := Length(aMsg);
    if n > 0 then
    begin
      for i := 1 to n do
      begin
        c := aMsg[i];
        shift := [];
        case c of
          'a'..'z': shift := [];
          'A'..'Z': shift := [ssShift];
          '_': // underscore key
          begin
            keybd_event(VK_SHIFT, 0, 0, 0);
            keybd_event(VK_OEM_MINUS, 0, 0, 0);
            keybd_event(VK_OEM_MINUS, 0, KEYEVENTF_KEYUP, 0);
            keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
            continue;
          end;
          '
: // $ key
          begin
            PostKey(Ord('4'), [ssShift], False);
            continue;
          end;

        end;
        PostKey(Ord(UpCase(c)), shift, False);
      end;
      PostKey(VK_RETURN, [], False);
      PostKey(VK_RETURN, [], False);
    end;
  end;

begin
  cfn := ChangeFileExt(aCHMFilename, '.chm');
  FillChar(qry, SizeOf(qry), 0);
  qry.cbStruct := SizeOf(THHFtsQuery);
  qry.fExecute := TRUE;
  HH.HtmlHelpA(GetDesktopWindow, PAnsiChar(AnsiString(cfn)), HH_DISPLAY_TOC, 0);
  hnd := HH.HtmlHelpA(GetDesktopWindow, PAnsiChar(AnsiString(cfn)), HH_DISPLAY_SEARCH,
    Cardinal(@qry));
  DoSearch(aSearch);
end;
血之狂魔 2024-07-21 08:42:37

啊哈!!!

经过一个小时的打字和尝试,我发现一级关键字和二级关键字之间需要两个空格,最后需要一个“Enter”键才能显示第二级关键字链接的主题!!!!

记住,正好两个空格! 一三个不行。 诀窍是,在输入第二个空格和第二个关键字时,关键字列表中的其他一些关键字会突出显示,这会让您认为您已经犯了错误,并且不会继续完成第二个关键字的输入! 这是微软工程师的恶作剧吗?

然而,尽管它可以手动工作,但软件 API 似乎并不能立即与两个空间一起工作。 如果我在按下 F1 键时在 C# 中调用以下 API(我必须使用“空格”来表示此处的空格,因为如果我使用实际空格,该网站会将两个空格修剪为一个):

System.Windows.Forms.Help.ShowHelp(这个,“file:///C:/apps/MyHelpContentNew/QACT.chm”,System.Windows.Forms.HelpNavigator.KeywordIndex,“key2'space''space'x_subkey_of_key2”);

它不显示从 x_subkey_of_key2 链接的主题。 但它几乎就在那里,帮助窗口显示了在搜索文本框中输入的正确的两个级别的关键字,只缺少一个“Car-Return”!

然后我尝试添加这样的回车:

System.Windows.Forms.Help.ShowHelp(this, "file:///C:/apps/MyHelpContentNew/QACT.chm", System.Windows.Forms.HelpNavigator. KeywordIndex, "key2'空格''空格'x_subkey_of_key2\n");

它也不起作用。 所以我想我需要通过编程将还车钥匙发送到帮助窗口。 如果我实施它,就会发布。

Ahaa!!!

After one hours' typing and trying, I figured out that TWO SPACES are needed between the first level keyword and second level keyword, and an "Enter" key is needed at last to show the topic linked from the second keyword!!!!

Remember, exactly two spaces! one or three does not work. The trick is, while typing the second space and second keyword, some other keyword get highlighted in the list of keywords, which can make you think you have already made a mistake and would not continue to finish typing the second keyword! Is this a hoax by Microsoft engineer?

However, although manually it works, seems the software API does not work immediately with the TWO spaces. If I call the following API in C# upon F1 key pressed (I have to use "space" to represent a space here because this website trims two space to one if I use real space):

System.Windows.Forms.Help.ShowHelp(this, "file:///C:/apps/MyHelpContentNew/QACT.chm", System.Windows.Forms.HelpNavigator.KeywordIndex, "key2'space''space'x_subkey_of_key2");

it does not show the topic linked from x_subkey_of_key2. But it's almost there, the Help Window shows up with correct two levels' keywords put in the search TextBox, only missing a "Car-Return"!

Then I tried to add the car-return like this:

System.Windows.Forms.Help.ShowHelp(this, "file:///C:/apps/MyHelpContentNew/QACT.chm", System.Windows.Forms.HelpNavigator.KeywordIndex, "key2'space''space'x_subkey_of_key2\n");

It doesn't work either. So I guess I need send a car-return key to the Help Window programmingly. Will post if I once I implement it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文