2
0

pmhelp.pas 22 KB

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