pmhelp.pas 22 KB

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