Skip to Content

Post Alt-N to HTML help file from PB

I'm launching the HTML Help file for my PB 12.5 app by running it (not using ShowHelp, because that forces the Help to stay on top of the app).

When I run the help file with no arguments, it comes to whichever tab (e.g. Contents or Index) the user last had it in. But I'd like to make sure it goes to the Index tab, which I think is most useful to my users.

So, what I'd like to do is in my PowerScript code, after running the .CHM file, find the window it's in, and send an Alt-N to it, which should change it to the Index tab. (It does if I type that directly!) I've gotten as far as finding the window, but nothing I have tried in sending the Alt-N works. I've tried a Send(WM_SYSKEYDOWN, Asc("N"), 0, 536870912) (that 4th arg is, I believe, turning bit 29 on, which the MS docs for WM_SYSKEYDOWN says indicates Alt is down). I've also tried using WM_KEYDOWN and WM_KEYUP, first sending a down of Alt, then N, then up of N, then Alt. That does nothing.

I've also used Spy++ to find the actual control that character presumably needs to go to, which is a SysTabControl32 class under a HH Child class which is under the main window. I can find that in my PB code (with FindWindowEx, going down 2 levels) and tried the different ways I had of sending the Alt+N to that sub-window. It still does nothing.

Any ideas?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Oct 17, 2016 at 03:47 PM

    OK, I never found a way to do that, but instead, I am calling the Windows API function HtmlHelp() directly. One of its available commands is to open the Help file displaying the Index specifically, so that solves the problem I was trying to solve.

    For your information (because this isn't entirely clear from the Microsoft documentation) if you pass a handle to the PB window you are calling that from to that HtmlHelp() function, it behaves just like PB's ShowHelp(). Namely, if the Help window overlaps the PB window, although you can switch between the windows and both are active, the Help always stays on top - you have to move it aside if it's occluding the PB window at all.

    To prevent that behaviour (which I find undesirable) I always pass 0 to HtmlHelp() as the window handle. However, that has a side effect, which is that successive calls to the same help file, if you didn't close a previous Help window, open additional Help windows. (That doesn't happen if you pass in a non-0 window handle.) To work around that behaviour, which I also find undesirable, I check whether there's a Help window open with the API function FindWindow(), finding based on the title of my Help file, and close it with a HtmlHelp() command for closing Help windows.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 19, 2016 at 07:47 PM

    If you want to open the help file on a specific topic you can do this:

    ls_command = ls_HelpFile + "::/" + as_TopicHtml

    ll_handle = HtmlHelp(0, ls_command, HH_DISPLAY_TOPIC, 0)

    In this example, as_TopicHtml is the name of the HTML file within the help designer. Also, the returned handle should be what you can use to close it (instead of using FindWindow).

    Add comment
    10|10000 characters needed characters exceeded