CHM file does not display correctly when Delphi VCL style is active

My Delphi app includes a help file that the user can call from anywhere in the app (well ... that is, for all the parts I've written so far ...)

It also includes the ability to switch the user from a regular style to another VCL style from the list.

If no style is applied, the help file is usually displayed as follows:

The help file can be read

But once the VCL style is active, the help file no longer displays correctly, for example:

help file corrupted by VCL

It has to do with how I declare HelpFile on the main creation of the form like this (path is a global variable pointing to the main exe folder):

Application.HelpFile := path+'Help\D.R.A.M.A. 2.0 Help.chm';

      

or is it a known issue that cannot be resolved?

SIDE NOTE: help is called in helpContext if important and HtmlHelpViewer is added to the uses clause.

+4


source to share


1 answer


This answer was taken from https://forums.embarcadero.com/thread.jspa?threadID=227785 and I confirmed that it works pretty well.

Drag the TApplicationEvents component onto the main application form.

Implement this component's OnHelp event as follows:

function TfmMain.ApplicationEvents1Help(Command: Word; Data: NativeInt; var CallHelp: Boolean): Boolean;
begin
  CloseHelpWnd;

  Result := ShellExecute(0,'open','hh.exe',
                         PWideChar('-mapid '+IntToStr(Data)
                                   +' ms-its:'+Application.HelpFile),
                         nil,SW_SHOW) = 32;

  CallHelp := false;
end;

      

In the main form, implement the CloseHelpWnd method as follows:

procedure TfmMain.CloseHelpWnd;
var
  HlpWind: HWND;
const
  HelpTitle = 'Your help file title';
begin
  HlpWind := FindWindow('HH Parent',HelpTitle);
  if HlpWind <> 0 then PostMessage(HlpWind,WM_Close,0,0);
end;

      



You would replace " Help File Name " with the title of the Help file. This is the title of the window when you open the help file directly.

In the FormDestroy event for the main form, include a call

CloseHelpWnd;

      

So far we have not seen any problems with the above method, and since we are running the help file in a separate process, it is not affected by the VCL style issues evident in Delphi 10.2 Tokyo.

NOTE . This does not have to be the main form of the application, but it must be a form that is created before the help system is needed and remains created while the application is running. In our case, we did it in the form of shared resources, and then all the programs that we rebuilt with the new form solved the problem with.

NOTE . You still need to set the Application.HelpFile property as normal, but you don't need to include the HtmlHelpViewer module in your Uses clause.

0


source







All Articles