2006. március 26., vasárnap

How to display a help file on top of a form with style fsStayOnTop


Problem/Question/Abstract:

I have a form with its formstyle set to fsStayOnTop. If I display the help for this form, the help windows is opened behind my form. Even if I click on the help window it stays behind. How can I display the help windows in front of any form?

Answer:

You can do this by sending a macro to WinHelp.


procedure TForm1.Button1Click(Sender: TObject);
begin
  with Application do
  begin
    Helpfile := 'C:\Programme\Borland\Delphi5\Help\TOOLS\HCW.HLP';
    HelpCommand(HELP_CONTENTS, 0);
    HelpCommand(HELP_COMMAND, Integer(PChar('Generate(' + IntToStr(WM_COMMAND)
      + ', 1471, 0)')));
  end;
end;


This macro call fakes a menu action for the "keep on top" menu item. Use 1472 to deactivate the on top state. Help macros are documented in the helpfile I used above. The HelpOnTop macro gives the menu IDs to use for Generate in this case. HelponTop itself may be useful if you simply want to change the current on-top default for the window (it is a toggle).

Nincsenek megjegyzések:

Megjegyzés küldése