📄 hh.pas
字号:
HHWIN_NAVTYPE_SEARCH = 2;
HHWIN_NAVTYPE_FAVORITES = 3;
HHWIN_NAVTYPE_HISTORY = 4; // not implemented
HHWIN_NAVTYPE_AUTHOR = 5;
HHWIN_NAVTYPE_CUSTOM_FIRST = 11;
const
IT_INCLUSIVE = 0;
IT_EXCLUSIVE = 1;
IT_HIDDEN = 2;
type
PHHEnumIT = ^THHEnumIT;
tagHH_ENUM_IT = packed record //tagHH_ENUM_IT, HH_ENUM_IT, *PHH_ENUM_IT
cbStruct: Integer; // size of this structure
iType: Integer; // the type of the information type ie. Inclusive, Exclusive, or Hidden
pszCatName: PAnsiChar; // Set to the name of the Category to enumerate the info types in a category; else NULL
pszITName: PAnsiChar; // volitile pointer to the name of the infotype. Allocated by call. Caller responsible for freeing
pszITDescription: PAnsiChar; // volitile pointer to the description of the infotype.
end;
THHEnumIT = tagHH_ENUM_IT;
type
PHHEnumCat = ^THHEnumCat;
tagHH_ENUM_CAT = packed record //tagHH_ENUM_CAT, HH_ENUM_CAT, *PHH_ENUM_CAT
cbStruct: Integer; // size of this structure
pszCatName: PAnsiChar; // volitile pointer to the category name
pszCatDescription: PAnsiChar; // volitile pointer to the category description
end;
THHEnumCat = tagHH_ENUM_CAT;
type
PHHSetInfoType = ^THHSetInfoType;
tagHH_SET_INFOTYPE = packed record //tagHH_SET_INFOTYPE, HH_SET_INFOTYPE, *PHH_SET_INFOTYPE
cbStruct: Integer; // the size of this structure
pszCatName: PAnsiChar; // the name of the category, if any, the InfoType is a member of.
pszInfoTypeName: PAnsiChar; // the name of the info type to add to the filter
end;
THHSetInfoType = tagHH_SET_INFOTYPE;
type
HH_INFOTYPE = DWORD;
THHInfoType = HH_INFOTYPE;
PHHInfoType = ^THHInfoType; //PHH_INFOTYPE
const
HHWIN_NAVTAB_TOP = 0;
HHWIN_NAVTAB_LEFT = 1;
HHWIN_NAVTAB_BOTTOM = 2;
const
HH_MAX_TABS = 19; // maximum number of tabs
const
HH_TAB_CONTENTS = 0;
HH_TAB_INDEX = 1;
HH_TAB_SEARCH = 2;
HH_TAB_FAVORITES = 3;
HH_TAB_HISTORY = 4;
HH_TAB_AUTHOR = 5;
HH_TAB_CUSTOM_FIRST = 11;
HH_TAB_CUSTOM_LAST = HH_MAX_TABS;
HH_MAX_TABS_CUSTOM = (HH_TAB_CUSTOM_LAST - HH_TAB_CUSTOM_FIRST + 1);
{ HH_DISPLAY_SEARCH Command Related Structures and Constants }
const
HH_FTS_DEFAULT_PROXIMITY = (-1);
type
{** Used by command HH_DISPLAY_SEARCH}
PHHFtsQuery = ^THHFtsQuery;
tagHH_FTS_QUERY = packed record //tagHH_FTS_QUERY, HH_FTS_QUERY
cbStruct: integer; // Sizeof structure in bytes.
fUniCodeStrings: BOOL; // TRUE if all strings are unicode.
pszSearchQuery: PChar; // String containing the search query.
iProximity: LongInt; // Word proximity.
fStemmedSearch: Bool; // TRUE for StemmedSearch only.
fTitleOnly: Bool; // TRUE for Title search only.
fExecute: Bool; // TRUE to initiate the search.
pszWindow: PChar; // Window to display in
end;
THHFtsQuery = tagHH_FTS_QUERY;
{ HH_WINTYPE Structure }
type
{** Used by commands HH_GET_WIN_TYPE, HH_SET_WIN_TYPE}
PHHWinType = ^THHWinType;
tagHH_WINTYPE = packed record //tagHH_WINTYPE, HH_WINTYPE, *PHH_WINTYPE;
cbStruct: Integer; // IN: size of this structure including all Information Types
fUniCodeStrings: BOOL; // IN/OUT: TRUE if all strings are in UNICODE
pszType: PChar; // IN/OUT: Name of a type of window
fsValidMembers: DWORD; // IN: Bit flag of valid members (HHWIN_PARAM_)
fsWinProperties: DWORD; // IN/OUT: Properties/attributes of the window (HHWIN_)
pszCaption: PChar; // IN/OUT: Window title
dwStyles: DWORD; // IN/OUT: Window styles
dwExStyles: DWORD; // IN/OUT: Extended Window styles
rcWindowPos: TRect; // IN: Starting position, OUT: current position
nShowState: Integer; // IN: show state (e.g., SW_SHOW)
hwndHelp: HWND; // OUT: window handle
hwndCaller: HWND; // OUT: who called this window
paInfoTypes: PHHInfoType; // IN: Pointer to an array of Information Types
{ The following members are only valid if HHWIN_PROP_TRI_PANE is set }
hwndToolBar: HWND; // OUT: toolbar window in tri-pane window
hwndNavigation: HWND; // OUT: navigation window in tri-pane window
hwndHTML: HWND; // OUT: window displaying HTML in tri-pane window
iNavWidth: Integer; // IN/OUT: width of navigation window
rcHTML: TRect; // OUT: HTML window coordinates
pszToc: PChar; // IN: Location of the table of contents file
pszIndex: PChar; // IN: Location of the index file
pszFile: PChar; // IN: Default location of the html file
pszHome: PChar; // IN/OUT: html file to display when Home button is clicked
fsToolBarFlags: DWORD; // IN: flags controling the appearance of the toolbar (HHWIN_BUTTON_)
fNotExpanded: BOOL; // IN: TRUE/FALSE to contract or expand, OUT: current state
curNavType: Integer; // IN/OUT: UI to display in the navigational pane
tabpos: Integer; // IN/OUT: HHWIN_NAVTAB_TOP, HHWIN_NAVTAB_LEFT, or HHWIN_NAVTAB_BOTTOM
idNotify: Integer; // IN: ID to use for WM_NOTIFY messages
tabOrder: packed array[0..HH_MAX_TABS] of Byte; // IN/OUT: tab order: Contents, Index, Search, History, Favorites, Reserved 1-5, Custom tabs
cHistory: Integer; // IN/OUT: number of history items to keep (default is 30)
pszJump1: PChar; // Text for HHWIN_BUTTON_JUMP1
pszJump2: PChar; // Text for HHWIN_BUTTON_JUMP2
pszUrlJump1: PChar; // URL for HHWIN_BUTTON_JUMP1
pszUrlJump2: PChar; // URL for HHWIN_BUTTON_JUMP2
rcMinSize: TRect; // Minimum size for window (ignored in version 1)
cbInfoTypes: Integer; // size of paInfoTypes;
pszCustomTabs: PChar; // multiple zero-terminated strings
end;
HH_WINTYPE = tagHH_WINTYPE;
THHWinType = tagHH_WINTYPE;
const
HHACT_TAB_CONTENTS = 0;
HHACT_TAB_INDEX = 1;
HHACT_TAB_SEARCH = 2;
HHACT_TAB_HISTORY = 3;
HHACT_TAB_FAVORITES = 4;
HHACT_EXPAND = 5;
HHACT_CONTRACT = 6;
HHACT_BACK = 7;
HHACT_FORWARD = 8;
HHACT_STOP = 9;
HHACT_REFRESH = 10;
HHACT_HOME = 11;
HHACT_SYNC = 12;
HHACT_OPTIONS = 13;
HHACT_PRINT = 14;
HHACT_HIGHLIGHT = 15;
HHACT_CUSTOMIZE = 16;
HHACT_JUMP1 = 17;
HHACT_JUMP2 = 18;
HHACT_ZOOM = 19;
HHACT_TOC_NEXT = 20;
HHACT_TOC_PREV = 21;
HHACT_NOTES = 22;
HHACT_LAST_ENUM = 23;
type
{*** Notify event info for HHN_TRACK }
PHHNTrack = ^THHNTrack;
tagHHNTRACK = packed record //tagHHNTRACK, HHNTRACK;
hdr: TNMHdr;
pszCurUrl: PChar; // Multi-byte, null-terminated string
idAction: Integer; // HHACT_ value
phhWinType: PHHWinType; // Current window type structure
end;
HHNTRACK = tagHHNTRACK;
THHNTrack = tagHHNTRACK;
///////////////////////////////////////////////////////////////////////////////
//
// Global Control Properties.
//
const
HH_GPROPID_SINGLETHREAD = 1; // VARIANT_BOOL: True for single thread
HH_GPROPID_TOOLBAR_MARGIN = 2; // long: Provides a left/right margin around the toolbar.
HH_GPROPID_UI_LANGUAGE = 3; // long: LangId of the UI.
HH_GPROPID_CURRENT_SUBSET = 4; // BSTR: Current subset.
HH_GPROPID_CONTENT_LANGUAGE = 5; // long: LandId for desired content.
type
tagHH_GPROPID = HH_GPROPID_SINGLETHREAD..HH_GPROPID_CONTENT_LANGUAGE; //tagHH_GPROPID, HH_GPROPID
HH_GPROPID = tagHH_GPROPID;
THHGPropID = HH_GPROPID;
///////////////////////////////////////////////////////////////////////////////
//
// Global Property structure
//
type
PHHGlobalProperty = ^THHGlobalProperty;
tagHH_GLOBAL_PROPERTY = record //tagHH_GLOBAL_PROPERTY, HH_GLOBAL_PROPERTY
id: THHGPropID;
Dummy: Integer; // Added to enforce 8-byte packing
var_: VARIANT;
end;
HH_GLOBAL_PROPERTY = tagHH_GLOBAL_PROPERTY;
THHGlobalProperty = tagHH_GLOBAL_PROPERTY;
implementation
{Return Windows System Dir - with no trailing slash}
function GetWinSysDir: String;
var path: array[0..260] of Char;
begin
GetSystemDirectory(path, SizeOf(path));
result := path;
if result[length(result)] = '\' then
SetLength(result, length(result)-1);
end;
const hhPathRegKey = 'CLSID\{adb880a6-d8ff-11cf-9377-00aa003b7a11}\InprocServer32';
{ Returns full path to hhctrl.ocx.
Returns empty string if file or registry entry not found.
Note: hhctrl.ocx may not be in the path. Consider the case where
the ocx has been downloaded to the windows ocx cache via the net.
So.. best to get the path from the registry.
Note: Delphi 2 and 3 do not support reg.OpenKeyReadOnly()
and to access the registry as RW mode under NT (as non admin user) will cause
an access violation. Best to simply return the ocx path to system folder.
In 99.9% of cases this will be correct.
}
function GetPathToHHCtrlOCX: string;
{$IFDEF D4PLUS} // -- Delphi >=4 ------------
var Reg: TRegistry;
{$ENDIF}
begin
{$IFDEF D4PLUS} // -- Delphi >=4 ------------
result := ''; //default return
Reg := TRegistry.Create;
Reg.RootKey := HKEY_CLASSES_ROOT;
if Reg.OpenKeyReadOnly(hhPathRegKey) then //safer call under NT
begin
result := Reg.ReadString(''); //default value
Reg.CloseKey;
if (result <> '') and (not FileExists(result)) then //final check - file must exist
result := '';
end;
Reg.Free;
{$ELSE} // -- Delphi <4 ------------
Result := GetWinSysDir + '\hhctrl.ocx';
{$ENDIF}
end;
{setup HTML Help API function interface
sets HHCtrlHandle = 0 if API function not available }
procedure LoadHtmlHelp;
var OcxPath: string;
begin
if HHCtrlHandle = 0 then
begin
OcxPath := GetPathToHHCtrlOCX;
if (OcxPath <> '') and FileExists(OcxPath) then
begin
HHCtrlHandle := LoadLibrary(PChar(OcxPath));
if HHCtrlHandle <> 0 then
begin
@HtmlHelpA := GetProcAddress(HHCtrlHandle, 'HtmlHelpA');
@HtmlHelpW := GetProcAddress(HHCtrlHandle, 'HtmlHelpW');
@HtmlHelp := GetProcAddress(HHCtrlHandle, 'HtmlHelpA');
end;
end;
end;
end;
procedure UnloadHtmlHelp;
begin
if HHCtrlHandle <> 0 then
begin
FreeLibrary(HHCtrlHandle);
@HtmlHelpA := nil;
@HtmlHelpW := nil;
@HtmlHelp := nil;
HHCtrlHandle := 0;
end;
end;
initialization
if AutoLoadAPI then
LoadHtmlHelp;
finalization
UnloadHtmlHelp;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -