2
0

pmhelp.pas 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2002 by Yuri Prokushev ([email protected]).
  4. OS/2 Presentation Manager Information Presentation Facility,
  5. Help Manager declarations.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {Warning: This code is alfa. Future versions
  13. of this unit might not be compatible.}
  14. unit pmhelp;
  15. interface
  16. {$MODE OBJFPC}
  17. uses
  18. os2def;
  19. resourcestring
  20. msg_failedtodisplay='Failed to display help panel.';
  21. msg_failedtoload='Failed to load help manager.';
  22. //************************************************************************/
  23. //* HelpSubTable entry structure */
  24. //************************************************************************/
  25. type
  26. HelpSubTable=Word;
  27. PHelpSubTable=^HelpSubTable;
  28. //************************************************************************/
  29. //* HelpTable entry structure */
  30. //* */
  31. //* Pack the structure HELPTABLE so that it is identical in the 32-Bit */
  32. //* and 16-Bit world. We have to do this because the HelpTable can */
  33. //* reside either in memory or in the application's resources. */
  34. //************************************************************************/
  35. type
  36. {$PACKRECORDS 2}
  37. PHelpTable=^HelpTable;
  38. HelpTable=record
  39. idAppWindow: Word;
  40. phstHelpSubTable: PHelpSubTable;
  41. idExtPanel: Word;
  42. End;
  43. //************************************************************************/
  44. //* IPF Initialization Structure used on the */
  45. //* WinCreateHelpInstance() call. */
  46. //************************************************************************/
  47. type
  48. PHelpInit=^HelpInit;
  49. HelpInit=record
  50. cb: cardinal;
  51. ulReturnCode: cardinal;
  52. pszTutorialName: PChar;
  53. phtHelpTable: PHelpTable;
  54. hmodHelpTableModule: cardinal;
  55. hmodAccelActionBarModule: cardinal;
  56. idAccelTable: cardinal;
  57. idActionBar: cardinal;
  58. pszHelpWindowTitle: PChar;
  59. fShowPanelId: cardinal;
  60. pszHelpLibraryName: PChar;
  61. End;
  62. //************************************************************************/
  63. //* Search parent chain indicator for HM_SET_ACTIVE_WINDOW message. */
  64. //************************************************************************/
  65. const
  66. HWnd_Parent = 0;
  67. //************************************************************************/
  68. //* Constants used to define whether user wants to display panel using */
  69. //* panel number or panel name. */
  70. //************************************************************************/
  71. const
  72. HM_ResourceID = 0;
  73. HM_PanelName = 1;
  74. HMPanelType_Number =0;
  75. HMPanelType_Name =1;
  76. //************************************************************************/
  77. //* Constants used to define how the panel IDs are displayed on */
  78. //* help panels. */
  79. //************************************************************************/
  80. const
  81. CMIC_Hide_Panel_ID =$0000;
  82. CMIC_Show_Panel_ID =$0001;
  83. CMIC_Toggle_Panel_ID =$0002;
  84. //************************************************************************/
  85. //* IPF message base. */
  86. //************************************************************************/
  87. const
  88. HM_Msg_Base =$0220;
  89. //************************************************************************/
  90. //* Messages applications can send to the IPF. */
  91. //************************************************************************/
  92. const
  93. HM_Dismiss_Window =HM_Msg_Base+$0001;
  94. HM_Display_Help =HM_Msg_Base+$0002;
  95. HM_Ext_Help =HM_Msg_Base+$0003;
  96. HM_General_Help =HM_Ext_Help;
  97. HM_Set_Active_Window =HM_Msg_Base+$0004;
  98. HM_Load_Help_Table =HM_Msg_Base+$0005;
  99. HM_Create_Help_Table =HM_Msg_Base+$0006;
  100. HM_Set_Help_Window_Title =HM_Msg_Base+$0007;
  101. HM_Set_Show_Panel_ID =HM_Msg_Base+$0008;
  102. HM_Replace_Help_For_Help =HM_Msg_Base+$0009;
  103. HM_Replace_Using_Help =HM_Replace_Help_For_Help;
  104. HM_Help_Index =HM_Msg_Base+$000a;
  105. HM_Help_Contents =HM_Msg_Base+$000b;
  106. HM_Keys_Help =HM_Msg_Base+$000c;
  107. HM_Set_Help_Library_Name =HM_Msg_Base+$000d;
  108. HM_Set_OBJCOM_Window =HM_Msg_Base+$0018;
  109. HM_Upadte_OBJCOM_Window_Chain =HM_Msg_Base+$0019;
  110. HM_Query_DDF_Data =HM_Msg_Base+$001a;
  111. HM_Invalidate_DDF_Data =HM_Msg_Base+$001b;
  112. HM_Query =HM_Msg_Base+$001c;
  113. HM_Set_CoverPage_Size =HM_Msg_Base+$001d;
  114. //************************************************************************/
  115. //* Constants used to query the info from IPF in HM_QUERY message */
  116. //************************************************************************/
  117. //* Hi word in lParam 1 */
  118. const
  119. HMQW_COVERPAGE =$0001;
  120. HMQW_INDEX =$0002;
  121. HMQW_TOC =$0003;
  122. HMQW_SEARCH =$0004;
  123. HMQW_VIEWPAGES =$0005;
  124. HMQW_LIBRARY =$0006;
  125. HMQW_VIEWPORT =$0007;
  126. HMQW_OBJCOM_WINDOW =$0008;
  127. HMQW_INSTANCE =$0009;
  128. HMQW_ACTIVEVIEWPORT =$000a;
  129. CONTROL_SELECTED =$000b;
  130. HMQW_GROUP_VIEWPORT =$00f1;
  131. HMQW_RES_VIEWPORT =$00f2;
  132. USERDATA =$00f3;
  133. //* Lo word in lParam1 of HMQW_VIEWPORT */
  134. HMQVP_NUMBER =$0001;
  135. HMQVP_NAME =$0002;
  136. HMQVP_GROUP =$0003;
  137. //************************************************************************/
  138. //* Predefined Control IDs */
  139. //************************************************************************/
  140. const
  141. CTRL_PREVIOUS_ID =$0001;
  142. CTRL_SEARCH_ID =$0002;
  143. CTRL_PRINT_ID =$0003;
  144. CTRL_INDEX_ID =$0004;
  145. CTRL_CONTENTS_ID =$0005;
  146. CTRL_BACK_ID =$0006;
  147. CTRL_FORWARD_ID =$0007;
  148. CTRL_TUTORIAL_ID =$00FF;
  149. CTRL_USER_ID_BASE =257;
  150. //************************************************************************/
  151. //* Messages the IPF sends to the applications active window */
  152. //* as defined by the IPF. */
  153. //************************************************************************/
  154. const
  155. HM_ERROR =HM_Msg_Base+$000e;
  156. HM_HELPSUBITEM_NOT_FOUND =HM_Msg_Base+$000f;
  157. HM_QUERY_KEYS_HELP =HM_Msg_Base+$0010;
  158. HM_TUTORIAL =HM_Msg_Base+$0011;
  159. HM_EXT_HELP_UNDEFINED =HM_Msg_Base+$0012;
  160. HM_GENERAL_HELP_UNDEFINED =HM_EXT_HELP_UNDEFINED;
  161. HM_ACTIONBAR_COMMAND =HM_Msg_Base+$0013;
  162. HM_INFORM =HM_Msg_Base+$0014;
  163. HM_NOTIFY =HM_Msg_Base+$0022;
  164. HM_SET_USERDATA =HM_Msg_Base+$0023;
  165. HM_CONTROL =HM_Msg_Base+$0024;
  166. //**********************************************************************/
  167. //* notify information for HM_NOTIFY */
  168. //**********************************************************************/
  169. const
  170. OPEN_COVERPAGE =$0001;
  171. OPEN_PAGE =$0002;
  172. SWAP_PAGE =$0003;
  173. OPEN_TOC =$0004;
  174. OPEN_INDEX =$0005;
  175. OPEN_HISTORY =$0006;
  176. OPEN_SEARCH_HIT_LIST =$0007;
  177. OPEN_LIBRARY =$0008;
  178. HELP_REQUESTED =$0009;
  179. //**********************************************************************/
  180. //* HMERR_NO_FRAME_WND_IN_CHAIN - There is no frame window in the */
  181. //* window chain from which to find or set the associated help */
  182. //* instance. */
  183. //**********************************************************************/
  184. const
  185. HMERR_NO_FRAME_WND_IN_CHAIN =$00001001;
  186. //*********************************************************************/
  187. //* HMERR_INVALID_ASSOC_APP_WND - The application window handle */
  188. //* specified on the WinAssociateHelpInstance() call is not a valid */
  189. //* window handle. */
  190. //*********************************************************************/
  191. const
  192. HMERR_INVALID_ASSOC_APP_WND =$00001002;
  193. //**********************************************************************/
  194. //* HMERR_INVALID_ASSOC_HELP_INST - The help instance handle specified */
  195. //* on the WinAssociateHelpInstance() call is not a valid */
  196. //* window handle. */
  197. //**********************************************************************/
  198. const
  199. HMERR_INVALID_ASSOC_HELP_INST =$00001003;
  200. //**********************************************************************/
  201. //* HMERR_INVALID_DESTROY_HELP_INST - The window handle specified */
  202. //* as the help instance to destroy is not of the help instance class. */
  203. //**********************************************************************/
  204. const
  205. HMERR_INVALID_DESTROY_HELP_INST =$00001004;
  206. //**********************************************************************/
  207. //* HMERR_NO_HELP_INST_IN_CHAIN - The parent or owner chain of the */
  208. //* application window specified does not have a help instance */
  209. //* associated with it. */
  210. //**********************************************************************/
  211. const
  212. HMERR_NO_HELP_INST_IN_CHAIN =$00001005;
  213. //**********************************************************************/
  214. //* HMERR_INVALID_HELP_INSTANCE_HDL - The handle specified to be a */
  215. //* help instance does not have the class name of a IPF */
  216. //* help instance. */
  217. //**********************************************************************/
  218. const
  219. HMERR_INVALID_HELP_INSTANCE_HDL =$00001006;
  220. //*********************************************************************/
  221. //* HMERR_INVALID_QUERY_APP_WND - The application window specified on */
  222. //* a WinQueryHelpInstance() call is not a valid window handle. */
  223. //*********************************************************************/
  224. const
  225. HMERR_INVALID_QUERY_APP_WND =$00001007;
  226. //*********************************************************************/
  227. //* HMERR_HELP_INST_CALLED_INVALID - The handle of the help instance */
  228. //* specified on an API call to the IPF does not have the */
  229. //* class name of an IPF help instance. */
  230. //*********************************************************************/
  231. const
  232. HMERR_HELP_INST_CALLED_INVALID =$00001008;
  233. HMERR_HELPTABLE_UNDEFINE =$00001009;
  234. HMERR_HELP_INSTANCE_UNDEFINE =$0000100a;
  235. HMERR_HELPITEM_NOT_FOUND =$0000100b;
  236. HMERR_INVALID_HELPSUBITEM_SIZE =$0000100c;
  237. HMERR_HELPSUBITEM_NOT_FOUND =$0000100d;
  238. //*********************************************************************/
  239. //* HMERR_INDEX_NOT_FOUND - No index in library file. */
  240. //*********************************************************************/
  241. const
  242. HMERR_INDEX_NOT_FOUND =$00002001;
  243. //**********************************************************************/
  244. //* HMERR_CONTENT_NOT_FOUND - Library file does not have any contents. */
  245. //**********************************************************************/
  246. const
  247. HMERR_CONTENT_NOT_FOUND =$00002002;
  248. //*********************************************************************/
  249. //* HMERR_OPEN_LIB_FILE - Cannot open library file */
  250. //*********************************************************************/
  251. const
  252. HMERR_OPEN_LIB_FILE =$00002003;
  253. //*********************************************************************/
  254. //* HMERR_READ_LIB_FILE - Cannot read library file */
  255. //*********************************************************************/
  256. const
  257. HMERR_READ_LIB_FILE =$00002004;
  258. //*********************************************************************/
  259. //* HMERR_CLOSE_LIB_FILE - Cannot close library file */
  260. //*********************************************************************/
  261. const
  262. HMERR_CLOSE_LIB_FILE =$00002005;
  263. //*********************************************************************/
  264. //* HMERR_INVALID_LIB_FILE - Improper library file provided */
  265. //*********************************************************************/
  266. const
  267. HMERR_INVALID_LIB_FILE =$00002006;
  268. //************************************************************************/
  269. //* HMERR_NO_MEMORY - Unable to allocate the requested amount of memory. */
  270. //************************************************************************/
  271. const
  272. HMERR_NO_MEMORY =$00002007;
  273. //*********************************************************************/
  274. //* HMERR_ALLOCATE_SEGMENT - Unable */
  275. //* to allocate a segment of memory for memory allocation requested */
  276. //* from the IPF. */
  277. //*********************************************************************/
  278. const
  279. HMERR_ALLOCATE_SEGMENT =$00002008;
  280. //*********************************************************************/
  281. //* HMERR_FREE_MEMORY - Unable to free allocated memory */
  282. //*********************************************************************/
  283. const
  284. HMERR_FREE_MEMORY =$00002009;
  285. //*********************************************************************/
  286. //* HMERR_PANEL_NOT_FOUND - Unable */
  287. //* to find a help panel requested to help manager */
  288. //*********************************************************************/
  289. const
  290. HMERR_PANEL_NOT_FOUND =$00002010;
  291. //*********************************************************************/
  292. //* HMERR_DATABASE_NOT_OPEN - Unable to read the unopened database */
  293. //*********************************************************************/
  294. const
  295. HMERR_DATABASE_NOT_OPEN =$00002011;
  296. //*********************************************************************/
  297. //* HMERR_DDL_ERROR - Unable to load resource dll */
  298. //*********************************************************************/
  299. const
  300. HMERR_LOAD_DLL =$00002013;
  301. //********************************************************************/
  302. //* AC Viewport stucture definitions */
  303. //********************************************************************/
  304. type
  305. PACVP=^ACVP;
  306. ACVP=record
  307. cb: cardinal;
  308. hAB: HAB;
  309. hmq: HMQ;
  310. ObjectID: cardinal; // object identifier
  311. hWndParent: HWND; // IPF viewport client handle
  312. hWndOwner: HWND; // IPF viewport client handle
  313. hWndACVP: HWND; // applications frame window hwnd
  314. end;
  315. //*******************************************************************/
  316. //* Define Handle to DDF */
  317. //*******************************************************************/
  318. Type
  319. HDDF=pointer;
  320. // DdfHyperText Flags
  321. const
  322. REFERENCE_BY_ID =0;
  323. REFERENCE_BY_RES =1;
  324. // DdfBeginList formatting flags
  325. HMBT_NONE =1;
  326. HMBT_ALL =2;
  327. HMBT_FIT =3;
  328. HMLS_SINGLELINE =1;
  329. HMLS_DOUBLELINE =2;
  330. // DdfBitmap alignment flags
  331. ART_RUNIN =$10;
  332. ART_LEFT =$01;
  333. ART_RIGHT =$02;
  334. ART_CENTER =$04;
  335. // DdfSetColor Color Flag
  336. CLR_UNCHANGED =-6;
  337. //*******************************************************************/
  338. // error codes returned by DDF API functions */
  339. //*******************************************************************/
  340. const
  341. HMERR_DDF_MEMORY =$3001;
  342. HMERR_DDF_ALIGN_TYPE =$3002;
  343. HMERR_DDF_BACKCOLOR =$3003;
  344. HMERR_DDF_FORECOLOR =$3004;
  345. HMERR_DDF_FONTSTYLE =$3005;
  346. HMERR_DDF_REFTYPE =$3006;
  347. HMERR_DDF_LIST_UNCLOSED =$3007;
  348. HMERR_DDF_LIST_UNINITIALIZED =$3008;
  349. HMERR_DDF_LIST_BREAKTYPE =$3009;
  350. HMERR_DDF_LIST_SPACING =$300A;
  351. HMERR_DDF_HINSTANCE =$300B;
  352. HMERR_DDF_EXCEED_MAX_LENGTH =$300C;
  353. HMERR_DDF_EXCEED_MAX_INC =$300D;
  354. HMERR_DDF_INVALID_DDF =$300E;
  355. HMERR_DDF_FORMAT_TYPE =$300F;
  356. HMERR_DDF_INVALID_PARM =$3010;
  357. HMERR_DDF_INVALID_FONT =$3011;
  358. HMERR_DDF_SEVERE =$3012;
  359. //************************************************************************/
  360. //* Window Help API declarations. */
  361. //************************************************************************/
  362. function WinDestroyHelpInstance(hwndHelpInstance: HWND): Longbool; cdecl;
  363. function WinCreateHelpInstance(ahab: HAB; var phinitHMInitStructure: HELPINIT): HWND; cdecl;
  364. function WinAssociateHelpInstance(hwndHelpInstance, hwndApp: HWND): Longbool; cdecl;
  365. function WinQueryHelpInstance(hwndApp: HWND): HWND; cdecl;
  366. function WinLoadHelpTable(hwndHelpInstance: HWND; idHelpTable: cardinal; Module: cardinal): Longbool; cdecl;
  367. function WinCreateHelpTable(hwndHelpInstance: HWND; var phtHelpTable: HELPTABLE): Longbool; cdecl;
  368. function DdfInitialize(hwndHelpInstance: HWND; cbBuffer, ulIncrement: cardinal): HDDF; cdecl;
  369. function DdfPara(ahddf: HDDF):Longbool; cdecl;
  370. function DdfSetFormat(ahddf: HDDF; fFormatType: cardinal): Longbool; cdecl;
  371. function DdfSetTextAlign(ahddf: HDDF; fAlign: cardinal): Longbool; cdecl;
  372. function DdfSetColor(ahddf: HDDF; fBackColor, fForColor: Longint): Longbool; cdecl;
  373. function DdfInform(ahddf: HDDF; var pszText: PChar; resInformNumber: cardinal): Longbool; cdecl;
  374. function DdfSetFontStyle(ahddf: HDDF; fFontStyle: cardinal): Longbool; cdecl;
  375. function DdfHyperText(ahddf: HDDF; var pszText, pszReference: PChar; fReferenceType: cardinal): Longbool; cdecl;
  376. function DdfBeginList(ahddf: HDDF; ulWidthDT, fBreakType, fSpacing: cardinal): Longbool; cdecl;
  377. function DdfListItem(ahddf: HDDF; var pszTerm, pszDescription: PChar): Longbool; cdecl;
  378. function DdfEndList(ahddf: HDDF): Longbool; cdecl;
  379. function DdfMetafile(ahddf: HDDF; ahmf: cardinal; var prclRect: RECTL): Longbool; cdecl;
  380. function DdfText(ahddf: HDDF; var pszText: PChar): Longbool; cdecl;
  381. function DdfSetFont(ahddf: HDDF; var pszFaceName: PChar; ulWidth, ulHeight: cardinal): Longbool; cdecl;
  382. function DdfBitmap(ahddf: HDDF; hbm: HBITMAP; fAlign: cardinal): Longbool; cdecl;
  383. implementation
  384. const
  385. HELPMGRDLL='HELPMGR';
  386. function WinDestroyHelpInstance(hwndHelpInstance: HWND): Longbool; cdecl;
  387. external HELPMGRDLL index 52;
  388. function WinCreateHelpInstance(ahab: HAB; var phinitHMInitStructure: HELPINIT): HWND; cdecl;
  389. external HELPMGRDLL index 51;
  390. function WinAssociateHelpInstance(hwndHelpInstance, hwndApp: HWND): Longbool; cdecl;
  391. external HELPMGRDLL index 54;
  392. function WinQueryHelpInstance(hwndApp: HWND): HWND; cdecl;
  393. external HELPMGRDLL index 53;
  394. function WinLoadHelpTable(hwndHelpInstance: HWND; idHelpTable: cardinal; Module: cardinal): Longbool; cdecl;
  395. external HELPMGRDLL index 55;
  396. function WinCreateHelpTable(hwndHelpInstance: HWND; var phtHelpTable: HELPTABLE): Longbool; cdecl;
  397. external HELPMGRDLL index 56;
  398. function DdfInitialize(hwndHelpInstance: HWND; cbBuffer, ulIncrement: cardinal): HDDF; cdecl;
  399. external HELPMGRDLL index 74;
  400. function DdfPara (ahddf: HDDF): Longbool; cdecl;
  401. external HELPMGRDLL index 75;
  402. function DdfSetFormat(ahddf: HDDF; fFormatType: cardinal): Longbool; cdecl;
  403. external HELPMGRDLL index 76;
  404. function DdfSetTextAlign (ahddf: HDDF; fAlign: cardinal): Longbool; cdecl;
  405. external HELPMGRDLL index 77;
  406. function DdfSetColor(ahddf: HDDF; fBackColor, fForColor: Longint): Longbool; cdecl;
  407. external HELPMGRDLL index 78;
  408. function DdfInform(ahddf: HDDF; var pszText: PChar; resInformNumber: cardinal): Longbool; cdecl;
  409. external HELPMGRDLL index 79;
  410. function DdfSetFontStyle(ahddf: HDDF; fFontStyle: cardinal): Longbool; cdecl;
  411. external HELPMGRDLL index 80;
  412. function DdfHyperText(ahddf: HDDF; var pszText, pszReference: PChar; fReferenceType: cardinal): Longbool; cdecl;
  413. external HELPMGRDLL index 81;
  414. function DdfBeginList(ahddf: HDDF; ulWidthDT, fBreakType, fSpacing: cardinal): Longbool; cdecl;
  415. external HELPMGRDLL index 82;
  416. function DdfListItem(ahddf: HDDF; var pszTerm, pszDescription: PChar): Longbool; cdecl;
  417. external HELPMGRDLL index 83;
  418. function DdfEndList(ahddf: HDDF): Longbool; cdecl;
  419. external HELPMGRDLL index 84;
  420. function DdfMetafile(ahddf: HDDF; ahmf: cardinal; var prclRect: RECTL): Longbool; cdecl;
  421. external HELPMGRDLL index 86;
  422. function DdfText(ahddf: HDDF; var pszText: PChar): Longbool; cdecl;
  423. external HELPMGRDLL index 85;
  424. function DdfSetFont(ahddf: HDDF; var pszFaceName: PChar; ulWidth, ulHeight: cardinal): Longbool; cdecl;
  425. external HELPMGRDLL index 87;
  426. function DdfBitmap(ahddf: HDDF; hbm: HBITMAP; fAlign: cardinal): Longbool; cdecl;
  427. external HELPMGRDLL index 88;
  428. end.