pmhelp.pas 22 KB

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