HTMLHelp

0

W jaki sposób zaimplementować prawidłowo w delphi help stworzony w HTMLHelp Workshop?

0

tu masz źródło komponentu do tego. Czytaj uważnie:

{HHTMLHelp.pas

HAKGER HTML Help Interface copyright (c) HAKGERSoft 2000 - 2003

This unit is owned by HAKGERSoft, any modifications without HAKGERSoft permision
is prohibited!

Author:
Johnny_Bit [[email protected]]

Unit description:

This unit helps You to create Applications with HTML Help instead of Standard

================================================================================

History:

02.06.2002 : ver 1.0
-Completed

================================================================================
}

unit HHTMLHelp;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

{$I HHTMLHelpConst.inc}
type
THHTMLHelp = class(TComponent)
private
FHelp,
FHelp1:String;
fOnOldKeyDown:TKeyEvent;
protected
procedure Loaded; override;
public
Function ShowContents:Integer;
Function ShowIndex:Integer;
Procedure ShowHelp(Sender: TObject; var Key: Word; Shift: TShiftState);
function HTMLHelp(hwndCaller:HWND;uCommand:integer;dwData:DWORD):HWND;
Destructor Destroy; override;
published
Property HelpFile:String read FHelp write FHelp;
end;

procedure Register;

implementation

function HHelp(hwndCaller : HWND; pszFile: PChar; uCommand : Integer;
dwData : DWORD) : HWND; stdcall; external 'hhctrl.ocx' name 'HtmlHelpA';

function THHTMLHelp.ShowContents:Integer;
begin
Result:=HHelp(Application.Handle,PChar(FHelp1),HH_DISPLAY_TOC,0);
end;

function THHTMLHelp.ShowIndex:Integer;
begin
Result:=HHelp(Application.Handle,PChar(FHelp),HH_DISPLAY_INDEX,0);
end;

Procedure THHTMLHelp.ShowHelp(Sender: TObject; var Key: Word; Shift: TShiftState);
var data:longint;
Control:TControl;
begin
data:=0; Control:=nil;
if (Shift=[])and(Key=VK_F1) then begin
if (Owner as TForm).Activecontrol.HelpContext0 then data:=(Owner as TForm).Activecontrol.HelpContext;
if data=0 then
if (Owner as TForm).Activecontrol.Owner is TControl then begin
Control:=((Owner as TForm).Activecontrol.Owner as TControl);
if Control.HelpContext0 then data:=Control.HelpContext;
end;
if (data=0) and ((Owner as TForm).HelpContext0) then data:=(Owner as TForm).HelpContext;
if FHelp'' then
HHelp(Application.Handle,PChar(FHelp1),HH_HELP_CONTEXT,Data);
// CallHelp:=False;
Key:=0;
end;
if assigned(fOnOldKeyDown) then fOnOldKeyDown(sender,key,shift)
end;

function THHTMLHelp.HTMLHelp(hwndCaller:HWND;uCommand:integer;dwData:DWORD):HWND;
begin
result:=hhelp(hwndCaller,PChar(FHelp1),uCommand,dwData);
end;

procedure THHTMLHelp.Loaded;
begin
Inherited;
// Here the help system is switched to HTMLHelp
//HelpSystem:=
if assigned((Owner as TForm).onkeydown) then fOnOldKeyDown:=(Owner as TForm).onkeydown;
(Owner as TForm).OnKeyDown:=ShowHelp;
(Owner as TForm).KeyPreview:=true;
FHelp1:=ExtractFilePath(Application.exename)+FHelp;
end;

destructor THHTMLHelp.Destroy;
begin
// Automatically close help window if any
HHelp(0,PChar(FHelp1),HH_CLOSE_ALL,0);
inherited;
end;

procedure Register;
begin
RegisterComponents('HAKGERSoft Components', [THHTMLHelp]);
end;

end.

trochę skomplikowane ale jak się dobrze poczyta to jest wyjątkowo prosty w użyciu (wszystko po angielsku :D )

1 użytkowników online, w tym zalogowanych: 0, gości: 1