Catching the F1 key press on a window to log it, while the help file still opens

Applies to: posted in the Clarion 10 group; a window without the old HTML Help global definitions template. The thread does not name the template chain.

Problem

For logging, the poster wanted to run code when the user presses F1 to open the help file. An alert on the F1 key on the window did not work.

Solution

  1. One reply remapped F1 with ALIAS to an unlikely key: TrapF1Key EQUATE(1023), then after opening the window ALIAS(F1Key, TrapF1Key) and ALERT(TrapF1Key), and IF KEYCODE() = TrapF1Key in the alert-key handling. The code ran, but the help file no longer opened.
  2. Calling the HELP statement, HELP([helpfile] [,window-id]), from that code opens the help again. The poster noted the context-sensitive HelpID could not be passed from a template, so it would be hand-coded per window.
  3. A reply for the alert route: on EVENT:PreAlertKey do CASE KEYCODE(), OF F1Key, CYCLE.
  4. Subclassing the window (a code file was attached) worked for the poster. With a help file set, the F1 press arrived as WM_HELP (equate 53h) and not as WM_KEYUP, so he tested for WM_HELP.
  5. Another reply pointed to the help engine interface in LibSrc CWHelp.INT, with a help logger shown at a conference; the poster planned to study it.

Caveats

  • The CYCLE reply and the interface route were not reported on.
  • The interface is described in the thread as undocumented.
  • The attached code is not in the archive text.

Today (2026)

Not re-tested. The WM_HELP observation is the part most worth checking on a current build.

Sources: Koen T. (Dec 2018, the question), Jeff B., Olivier C., Jeff S., Carl (Jan 2019) in sv.clarion.clarion10.