Link to home
Start Free TrialLog in
Avatar of WebWolf1
WebWolf1

asked on

View help file (.chm) inside delphi application

Hello,

I have a help file (.CHM) and I want to display it inside my delphi application.
Is there any ActiveX or component that will allow me to embed read the CHM file inside a delphi form?

Target platforms: XP and Vista.
ASKER CERTIFIED SOLUTION
Avatar of Eddie Shipman
Eddie Shipman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bongos
Bongos

I use SPHtmlHelp.pas which you can download from Torry http://www.torry.net/pages.php?s=94.
This also includes a translation of the header file HTMLHelp.h
Seems to work pretty well for me in Delphi 6
This actually works better...


unit Unit1;
 
// Launch App and Re-Parent in a Panel
// 25th June 2004 - J French
 
// Add Two Buttons and One Large Panel
 
interface
 
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, Unit2, HHCTRLLib_TLB;
 
type
  TForm1 = class(TForm)
    Button1: TButton;
    Panel1: TPanel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure HideTitleBar(hwnd: THandle);
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
const
  HH_DISPLAY_TOC   = $0001;
  HH_DISPLAY_TOPIC = $0000;
  HH_CLOSE_ALL     = $0012;
  HH_DISPLAY_INDEX = $0002;
  HH_HELP_CONTEXT  = $000F;
  HH_DISPLAY_SEARCH= $0003;
  HH_DISPLAY_TEXT_POPUP = $000E;
 
 
function HtmlHelp(hwndCaller: HWND; pszFile: PChar; uCommand: UINT;
    dwData: PDWORD): HWND; stdcall; external 'hhctrl.ocx' Name 'HtmlHelpA';
 
 
procedure TForm1.HideTitleBar(hwnd: THandle);
var
 Save: LongInt;
begin
  Save := GetWindowLong(hwnd, GWL_STYLE);
  if (Save and WS_CAPTION) = WS_CAPTION then
  begin
    SetWindowLong(hwnd, GWL_STYLE, Save and
         (not(WS_CAPTION)) or WS_BORDER);
    Windows.MoveWindow(hwnd, 0, 0,
                       Panel1.ClientWidth,
                       Panel1.ClientHeight -getSystemMetrics(SM_CYCAPTION), True);
     Refresh;
  end;
end;
 
procedure TForm1.Button1Click(Sender: TObject);
var
   wnd: HWND;
   my_context_id:integer;
begin
   HtmlHelp(handle,pchar('c:\windows\help\access.chm'),HH_DISPLAY_TOC,nil);
   wnd := Findwindow('HH Parent', nil );
   HideTitleBar(wnd);
    if wnd <> 0 then
   begin
    beep;
    windows.setparent( wnd, panel1.handle ); 
    ShowWindow(wnd, SW_MAXIMIZE);  //maxime you external app
    SetForegroundWindow( wnd );
   end
end;
 
end.

Open in new window

@EddieShipman Expert Comment 2008-12-17 at 13:09:31  ID: 23192444

In your comment you reference Unit2, but you haven't included it. Could you please clarify?
Don't think it had anything to do with the code.
I've tried it and it works. However, before the external window attaches to the Panel, it is visible for a short time (like a flash) outside the application.

Is it possible to make the attachment process instantaneous, so the external window would not be shown before it is attached to the panel?
This question and solution is from 2008. I haven't even touched Delphi since 2010 so I can't really help but I think you can hide the panel before it is loaded and then show it after.
Also, personally, I don't think it right for you to be hijacking this already answered question vs. asking your own.