home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / os2cl016.zip / pmhelp.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-05  |  2.2 KB  |  80 lines

  1. /* 
  2.  
  3.  
  4.     pmhelp.cpp (emx+gcc) 
  5.  
  6.     1995 Giovanni Iachello
  7.     This is freeware software. You can use or modify it as you wish,
  8.     provided that the part of code that I wrote remains freeware.
  9.     Freeware means that the source code must be available on request 
  10.     to anyone.
  11.     You must also include this notice in all files derived from this
  12.     file.
  13.  
  14.  
  15. */
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19.  
  20. #include "pmwin.h"
  21. #include "pmhelp.h"
  22. #include "pmstdres.h"
  23.  
  24. /////////////////////////////////////////////////////////////////////////////
  25.  
  26. PMHelpWin::PMHelpWin(PSZ title,PSZ library,USHORT id,HAB hab) : PMWin(hab)
  27. {
  28.     hiInit.cb = sizeof (HELPINIT);
  29.     hiInit.ulReturnCode = 0;
  30.     hiInit.pszTutorialName = NULL;
  31.     hiInit.phtHelpTable = ( PHELPTABLE ) MAKEULONG (id, 0xffff);
  32.     hiInit.hmodHelpTableModule = NULLHANDLE;
  33.     hiInit.hmodAccelActionBarModule = NULLHANDLE;
  34.     hiInit.idAccelTable = 0;
  35.     hiInit.idActionBar = 0;
  36.     hiInit.pszHelpWindowTitle = title;
  37.     hiInit.fShowPanelId = CMIC_HIDE_PANEL_ID;
  38.     hiInit.pszHelpLibraryName = library;
  39. }
  40.  
  41. PMHelpWin::PMHelpWin(PSZ title,PSZ library,PHELPTABLE pht,HAB hab) : PMWin(hab)
  42. {
  43.     hiInit.cb = sizeof (HELPINIT);
  44.     hiInit.ulReturnCode = 0;
  45.     hiInit.pszTutorialName = NULL;
  46.     hiInit.phtHelpTable = pht;
  47.     hiInit.hmodHelpTableModule = NULLHANDLE;
  48.     hiInit.hmodAccelActionBarModule = NULLHANDLE;
  49.     hiInit.idAccelTable = 0;
  50.     hiInit.idActionBar = 0;
  51.     hiInit.pszHelpWindowTitle = title;
  52.     hiInit.fShowPanelId = CMIC_HIDE_PANEL_ID;
  53.     hiInit.pszHelpLibraryName = library;
  54. }
  55.  
  56. BOOL PMHelpWin::createWin()
  57. {
  58.     hwnd= WinCreateHelpInstance( ab, &hiInit );
  59.     if (!hwnd) { // if we could not create the help instance display a message
  60.         char buf[460];
  61.         sprintf(buf,"Could not start help system. (Probably the help file \"%s\" is not in the current directory.)\nTo continue, press OK, but help will not be available.\nTo quit the application press Cancel.\n",hiInit.pszHelpLibraryName);
  62.         if (WinMessageBox(HWND_DESKTOP,HWND_DESKTOP,buf,"Error!",0,MB_OKCANCEL|MB_ICONHAND|MB_APPLMODAL)!=MBID_OK) exit(-1);
  63.         return FALSE;
  64.     }
  65.     return TRUE;
  66. }
  67.  
  68. BOOL PMHelpWin::destroyWin()
  69. {
  70.     return WinDestroyHelpInstance(hwnd);
  71. }
  72.  
  73. PMHelpWin::~PMHelpWin()
  74. {
  75.     destroyWin();
  76. }
  77.  
  78.  
  79.  
  80.