Question

I'm working on an application with hundreds of forms and a corresponding help file with over 2,000 topics. I have one particular form which I am assigning a Context ID, but when I press "F1", the help file opens on its default page (Which means the ID passed to it wasn't found). I need to find out what ID is being passed to the help file to further debug why it's not bringing up its proper topic. How do I find this number?

Was it helpful?

Solution

I discovered the solution as I was writing this question, so I am answering this question Q&A style...

The Application component has an event OnHelp which is triggered when the help file is to be opened. Assign a handler function to this event and then read the Data parameter to get this context ID.

procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnHelp:= AppHelp;
end;

function TForm1.AppHelp(Command: Word; Data: THelpEventData; var CallHelp: Boolean): Boolean;
begin
  ShowMessage(IntToStr(Data));
end;

On a further side note, you can change the CallHelp parameter to False to make your application cancel the call to the help file, just before it opens.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top