在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
在程序里加帮助文件,是常用的方法,我一直使用以下这个单元,不过 DELPHI2007好像对HTML帮助文件的支持有所改善。但没试过,因为自己整理使用的这个单元一直很好用。所以常得有用(对使用DELPH的朋友)。所以贴出来了。 主要有以下几个函数, //取帮助文件名 function HelpFileName: String; //根据 ContextId 调用帮助 function ShowHelpContext(ContextId: DWord): Integer; //根据检索字符调用帮助 function ShowHelpTopic(Topic: String): Integer; //显示主帮助窗口 function ShowHelpWindow: Integer; //显示主帮助窗口的索引栏 function ShowHelpIndex: Integer; //显示主帮助窗口的搜索栏 function ShowHelpSearch: Integer; //设置主帮助文件名 procedure SetHelpFileName(FileName: String); 例如在主程序的菜单-->帮助 中的 OnClick 事件里添加以下代码: procedure miHelpClick(Sender: TObject); 或者在相关的控件里的帮助事件中加入 ShowHelpContext(10992); //10992 是该控件的帮助ID, 可以为任意自己定义的ID. 或 ShowHelpTopic('使用说明'); //'使用说明'是该控件的帮助索引, 可以为任意自己定义的字符. 代码源文件如下:
{******************************************************************************* XOtecExpress Visual Component Library [陆岛工作室] Copyright (c) 2008 XOtec Studio. [PengJunli] By: PengJunLi Build: 2008-05 E-mail: [email protected] [email protected] QQ:442801172 *******************************************************************************} unit xtHTMLHelp; interface (*$HPPEMIT ''*) (*$HPPEMIT '#include "htmlhelp.h"'*) (*$HPPEMIT ''*) (*$HPPEMIT 'typedef struct tagHH_LAST_ERROR'*) (*$HPPEMIT '{'*) (*$HPPEMIT ' int cbStruct ;'*) (*$HPPEMIT ' HRESULT hr ;'*) (*$HPPEMIT ' BSTR description ;'*) (*$HPPEMIT '} HH_LAST_ERROR ;'*) (*$HPPEMIT ''*) uses Classes, Windows, Sysutils, Forms, Dialogs; {$DEFINE HTMLHELP12} type {$IFDEF HTMLHELP12} {$IFNDEF _WIN64} DWORD_PTR = DWORD; {$ENDIF} {$ENDIF} PCSTR = LPCSTR; // Commands to pass to HtmlHelp() const HH_DISPLAY_TOPIC = $0000; {$EXTERNALSYM HH_DISPLAY_TOPIC} HH_HELP_FINDER = $0000; // WinHelp equivalent {$EXTERNALSYM HH_HELP_FINDER} HH_DISPLAY_TOC = $0001; // not currently implemented {$EXTERNALSYM HH_DISPLAY_TOC} HH_DISPLAY_INDEX = $0002; // not currently implemented {$EXTERNALSYM HH_DISPLAY_INDEX} HH_DISPLAY_SEARCH = $0003; // not currently implemented {$EXTERNALSYM HH_DISPLAY_SEARCH} HH_SET_WIN_TYPE = $0004; {$EXTERNALSYM HH_SET_WIN_TYPE} HH_GET_WIN_TYPE = $0005; {$EXTERNALSYM HH_GET_WIN_TYPE} HH_GET_WIN_HANDLE = $0006; {$EXTERNALSYM HH_GET_WIN_HANDLE} HH_ENUM_INFO_TYPE = $0007; // Get Info type name, call repeatedly to enumerate, -1 at end {$EXTERNALSYM HH_ENUM_INFO_TYPE} HH_SET_INFO_TYPE = $0008; // Add Info type to filter. {$EXTERNALSYM HH_SET_INFO_TYPE} HH_SYNC = $0009; {$EXTERNALSYM HH_SYNC} {$IFDEF HTMLHELP11} HH_ADD_NAV_UI = $000A; // not currently implemented {$EXTERNALSYM HH_ADD_NAV_UI} HH_ADD_BUTTON = $000B; // not currently implemented {$EXTERNALSYM HH_ADD_BUTTON} HH_GETBROWSER_APP = $000C; // not currently implemented {$EXTERNALSYM HH_GETBROWSER_APP} {$ENDIF} {$IFDEF HTMLHELP12} HH_RESERVED1 = $000A; {$EXTERNALSYM HH_RESERVED1} HH_RESERVED2 = $000B; {$EXTERNALSYM HH_RESERVED2} HH_RESERVED3 = $000C; {$EXTERNALSYM HH_RESERVED3} {$ENDIF} HH_KEYWORD_LOOKUP = $000D; {$EXTERNALSYM HH_KEYWORD_LOOKUP} HH_DISPLAY_TEXT_POPUP = $000E; // display string resource id or text in a popup window {$EXTERNALSYM HH_DISPLAY_TEXT_POPUP} HH_HELP_CONTEXT = $000F; // display mapped numeric value in dwData {$EXTERNALSYM HH_HELP_CONTEXT} HH_TP_HELP_CONTEXTMENU = $0010; // text popup help, same as WinHelp HELP_CONTEXTMENU {$EXTERNALSYM HH_TP_HELP_CONTEXTMENU} HH_TP_HELP_WM_HELP = $0011; // text popup help, same as WinHelp HELP_WM_HELP {$EXTERNALSYM HH_TP_HELP_WM_HELP} HH_CLOSE_ALL = $0012; // close all windows opened directly or indirectly by the caller {$EXTERNALSYM HH_CLOSE_ALL} HH_ALINK_LOOKUP = $0013; // ALink version of HH_KEYWORD_LOOKUP {$EXTERNALSYM HH_ALINK_LOOKUP} HH_GET_LAST_ERROR = $0014; // not currently implemented, See HHERROR.h {$EXTERNALSYM HH_GET_LAST_ERROR} HH_ENUM_CATEGORY = $0015; // Get category name, call repeatedly to enumerate, -1 at end {$EXTERNALSYM HH_ENUM_CATEGORY} HH_ENUM_CATEGORY_IT = $0016; // Get category info type members, call repeatedly to enumerate, -1 at end {$EXTERNALSYM HH_ENUM_CATEGORY_IT} HH_RESET_IT_FILTER = $0017; // Clear the info type filter of all info types. {$EXTERNALSYM HH_RESET_IT_FILTER} HH_SET_INCLUSIVE_FILTER = $0018; // set inclusive filtering method for untyped topics to be included in display {$EXTERNALSYM HH_SET_INCLUSIVE_FILTER} HH_SET_EXCLUSIVE_FILTER = $0019; // set exclusive filtering method for untyped topics to be excluded from display {$EXTERNALSYM HH_SET_EXCLUSIVE_FILTER} {$IFDEF HTMLHELP11} HH_SET_GUID = $001A; // For Microsoft Installer -- dwData is a pointer to the GUID string {$EXTERNALSYM HH_SET_GUID} {$ENDIF} {$IFDEF HTMLHELP12} HH_INITIALIZE = $001C; // Initializes the help system. {$EXTERNALSYM HH_INITIALIZE} HH_UNINITIALIZE = $001D; // Uninitializes the help system. {$EXTERNALSYM HH_UNINITIALIZE} HH_PRETRANSLATEMESSAGE = $00FD; // Pumps messages. (NULL, NULL, MSG*). {$EXTERNALSYM HH_PRETRANSLATEMESSAGE} HH_SET_GLOBAL_PROPERTY = $00FC; // Set a global property. (NULL, NULL, HH_GPROP) {$EXTERNALSYM HH_SET_GLOBAL_PROPERTY} {$ENDIF} {$IFDEF HTMLHELP11} HH_INTERNAL = $00FF; // Used internally. {$EXTERNALSYM HH_INTERNAL} {$ENDIF} {$IFDEF HTMLHELP12} HHWIN_PROP_TAB_AUTOHIDESHOW = (1 shl 0); // Automatically hide/show tri-pane window {$EXTERNALSYM HHWIN_PROP_TAB_AUTOHIDESHOW} {$ENDIF} HHWIN_PROP_ONTOP = (1 shl 1); // Top-most window (not currently implemented) {$EXTERNALSYM HHWIN_PROP_ONTOP} HHWIN_PROP_NOTITLEBAR = (1 shl 2); // no title bar {$EXTERNALSYM HHWIN_PROP_NOTITLEBAR} HHWIN_PROP_NODEF_STYLES = (1 shl 3); // no default window styles (only HH_WINTYPE.dwStyles) {$EXTERNALSYM HHWIN_PROP_NODEF_STYLES} HHWIN_PROP_NODEF_EXSTYLES = (1 shl 4); // no default extended window styles (only HH_WINTYPE.dwExStyles) {$EXTERNALSYM HHWIN_PROP_NODEF_EXSTYLES} HHWIN_PROP_TRI_PANE = (1 shl 5); // use a tri-pane window {$EXTERNALSYM HHWIN_PROP_TRI_PANE} HHWIN_PROP_NOTB_TEXT = (1 shl 6); // no text on toolbar buttons {$EXTERNALSYM HHWIN_PROP_NOTB_TEXT} HHWIN_PROP_POST_QUIT = (1 shl 7); // post WM_QUIT message when window closes {$EXTERNALSYM HHWIN_PROP_POST_QUIT} HHWIN_PROP_AUTO_SYNC = (1 shl 8); // automatically ssync contents and index {$EXTERNALSYM HHWIN_PROP_AUTO_SYNC} HHWIN_PROP_TRACKING = (1 shl 9); // send tracking notification messages {$EXTERNALSYM HHWIN_PROP_TRACKING} HHWIN_PROP_TAB_SEARCH = (1 shl 10); // include search tab in navigation pane {$EXTERNALSYM HHWIN_PROP_TAB_SEARCH} HHWIN_PROP_TAB_HISTORY = (1 shl 11); // include history tab in navigation pane {$EXTERNALSYM HHWIN_PROP_TAB_HISTORY} {$IFDEF HTMLHELP11} HHWIN_PROP_TAB_BOOKMARKS = (1 shl 12); // include bookmark tab in navigation pane {$EXTERNALSYM HHWIN_PROP_TAB_BOOKMARKS} {$ENDIF} {$IFDEF HTMLHELP12} HHWIN_PROP_TAB_FAVORITES = (1 shl 12); // include favorites tab in navigation pane {$EXTERNALSYM HHWIN_PROP_TAB_FAVORITES} {$ENDIF} HHWIN_PROP_CHANGE_TITLE = (1 shl 13); // Put current HTML title in title bar {$EXTERNALSYM HHWIN_PROP_CHANGE_TITLE} HHWIN_PROP_NAV_ONLY_WIN = (1 shl 14); // Only display the navigation window {$EXTERNALSYM HHWIN_PROP_NAV_ONLY_WIN} HHWIN_PROP_NO_TOOLBAR = (1 shl 15); // Don't display a toolbar {$EXTERNALSYM HHWIN_PROP_NO_TOOLBAR} HHWIN_PROP_MENU = (1 shl 16); // Menu {$EXTERNALSYM HHWIN_PROP_MENU} HHWIN_PROP_TAB_ADVSEARCH = (1 shl 17); // Advanced FTS UI. {$EXTERNALSYM HHWIN_PROP_TAB_ADVSEARCH} HHWIN_PROP_USER_POS = (1 shl 18); // After initial creation, user controls window size/Position {$EXTERNALSYM HHWIN_PROP_USER_POS} {$IFDEF HTMLHELP12} HHWIN_PROP_TAB_CUSTOM1 = (1 shl 19); // Use custom tab #1 {$EXTERNALSYM HHWIN_PROP_TAB_CUSTOM1} HHWIN_PROP_TAB_CUSTOM2 = (1 shl 20); // Use custom tab #2 {$EXTERNALSYM HHWIN_PROP_TAB_CUSTOM2} HHWIN_PROP_TAB_CUSTOM3 = (1 shl 21); // Use custom tab #3 {$EXTERNALSYM HHWIN_PROP_TAB_CUSTOM3} HHWIN_PROP_TAB_CUSTOM4 = (1 shl 22); // Use custom tab #4 {$EXTERNALSYM HHWIN_PROP_TAB_CUSTOM4} HHWIN_PROP_TAB_CUSTOM5 = (1 shl 23); // Use custom tab #5 {$EXTERNALSYM HHWIN_PROP_TAB_CUSTOM5} HHWIN_PROP_TAB_CUSTOM6 = (1 shl 24); // Use custom tab #6 {$EXTERNALSYM HHWIN_PROP_TAB_CUSTOM6} HHWIN_PROP_TAB_CUSTOM7 = (1 shl 25); // Use custom tab #7 {$EXTERNALSYM HHWIN_PROP_TAB_CUSTOM7} HHWIN_PROP_TAB_CUSTOM8 = (1 shl 26); // Use custom tab #8 {$EXTERNALSYM HHWIN_PROP_TAB_CUSTOM8} HHWIN_PROP_TAB_CUSTOM9 = (1 shl 27); // Use custom tab #9 {$EXTERNALSYM HHWIN_PROP_TAB_CUSTOM9} HHWIN_TB_MARGIN = (1 shl 28); // the window type has a margin {$EXTERNALSYM HHWIN_TB_MARGIN} {$ENDIF} HHWIN_PARAM_PROPERTIES = (1 shl 1); // valid fsWinProperties {$EXTERNALSYM HHWIN_PARAM_PROPERTIES} HHWIN_PARAM_STYLES = (1 shl 2); // valid dwStyles {$EXTERNALSYM HHWIN_PARAM_STYLES} HHWIN_PARAM_EXSTYLES = (1 shl 3); // valid dwExStyles {$EXTERNALSYM HHWIN_PARAM_EXSTYLES} HHWIN_PARAM_RECT = (1 shl 4); // valid rcWindowPos {$EXTERNALSYM HHWIN_PARAM_RECT} HHWIN_PARAM_NAV_WIDTH = (1 shl 5); // valid iNavWidth {$EXTERNALSYM HHWIN_PARAM_NAV_WIDTH} HHWIN_PARAM_SHOWSTATE = (1 shl 6); // valid nShowState {$EXTERNALSYM HHWIN_PARAM_SHOWSTATE} HHWIN_PARAM_INFOTYPES = (1 shl 7); // valid apInfoTypes {$EXTERNALSYM HHWIN_PARAM_INFOTYPES} HHWIN_PARAM_TB_FLAGS = (1 shl 8); // valid fsToolBarFlags {$EXTERNALSYM HHWIN_PARAM_TB_FLAGS} HHWIN_PARAM_EXPANSION = (1 shl 9); // valid fNotExpanded {$EXTERNALSYM HHWIN_PARAM_EXPANSION} HHWIN_PARAM_TABPOS = (1 shl 10); // valid tabpos {$EXTERNALSYM HHWIN_PARAM_TABPOS} HHWIN_PARAM_TABORDER = (1 shl 11); // valid taborder {$EXTERNALSYM HHWIN_PARAM_TABORDER} HHWIN_PARAM_HISTORY_COUNT = (1 shl 12); // valid cHistory {$EXTERNALSYM HHWIN_PARAM_HISTORY_COUNT} HHWIN_PARAM_CUR_TAB = (1 shl 13); // |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论