Notification Messages

HTML Help can optionally send your application window notification messages. You can use these messages to respond to user activity in the HTML Help window. For example if the user presses a button you get a HHN_TRACK notification. There exist three different notification messages:

HTML Help by default does not send notification messsages. To enable this you must do two things. First you must specify the handle of a valid window which is to receive the notification messages in the hwndCaller parameter of the HtmlHelp function when you open the topic. Second you must set up a window type that enables notification messages. You do this by using the HH_SET_WINTYPE command. You must specify the following members of the THHWinType record:

After everything is set up the window specified by hwndCaller will start to receive notification messages through the standard WM_NOTIFY being sent to it's window procedure. To catch this message you can either subclass the window or declare a message handler. The latter method is a lot easier and is the one used by the Notifications demo project. Here's what such a handler would look like:

procedure TForm1.WMNotify(var Message: TWMNotify);
begin
  with Message do
  begin
    // assumes idNotify was set to WM_USER
    if NMHdr.idFrom = WM_USER then case NMHdr.Code of
      HHN_NAVCOMPLETE:
      begin
        ShowMessage('Navigated to: ' + PHHNNotify(NMHdr)^.psUrl);
      end;
      HHN_TRACK:
      begin
        ShowMessage('You pressed: ' +   IntToStr(PHHNTrack(NMHdr)^.idAction));
      end;
      HHN_WINDOW_CREATE:
      begin
        ShowMessage('Window created: ' + PHHNNotify(NMHdr)^.pszUrl);
      end;
      else
        ShowMessage('Unknown notification code');
      end;
    end;

  end;
  inherited;
end;