home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v6.zip / MMPM2TK / TK / AVCINST / AVCINST.C next >
C/C++ Source or Header  |  1993-04-01  |  29KB  |  801 lines

  1. /*static char *SCCSID = "@(#)avcinst.c  13.4 92/03/02";*/
  2. /*************************************************************************
  3.  * File Name   : AVCINST.C
  4.  *
  5.  * Description : This file contains the C source code required for the
  6.  *               AVCINST sample program.
  7.  *
  8.  * Concepts    : The program will illustrate how to install and remove an
  9.  *               Installable IO procedure.
  10.  *
  11.  * MMPM/2 API's: mmioInstallIOProc
  12.  *
  13.  * Required
  14.  *    Files    : avcinst.c         Source Code.
  15.  *               avcinst.h         Include file.
  16.  *               avcinst.dlg       Dialog definition.
  17.  *               avcinst.rc        Resources.
  18.  *               avcinst.ipf       Help text.
  19.  *               avcinst.mak       Make file.
  20.  *               avcinst.def       Linker definition file.
  21.  *               avcinst.ico       Program icon.
  22.  *
  23.  * Copyright (C) IBM 1991, 1993
  24.  *************************************************************************/
  25.  
  26. #define  INCL_WIN                        /* Required to use Win APIs.         */
  27. #define  INCL_PM                         /* Required to use PM APIs.          */
  28. #define  INCL_WINHELP                    /* Required to use IPF.              */
  29. #define  INCL_MMIO                       /* Required for MMIO information.    */
  30. #define  INCL_DOSMODULEMGR               /* Required for DosLoadModule.       */
  31. #define  INCL_SECONDARYWINDOW            /* required for secondary window     */
  32.  
  33. #include <os2.h>
  34. #include <os2me.h>
  35.  
  36. #include <mmio.h>
  37. #include <sw.h>
  38.  
  39. #include "avcinst.h"
  40.  
  41. /****************** Procedure/Function Prototypes *****************************/
  42. /*
  43.  * This definition is required to use the sample program with the IBM
  44.  * C compiler.
  45.  */
  46. #pragma linkage( MainDialogProc, system )
  47.  
  48. MRESULT EXPENTRY MainDialogProc( HWND   hwnd,
  49.                                  ULONG  msg,
  50.                                  MPARAM mp1,
  51.                                  MPARAM mp2 );
  52. USHORT           ShowAMessage( USHORT usMessageId,
  53.                                ULONG  ulMessageBoxStyle );
  54. BOOL             DoTheInstallation( HWND hwnd);
  55. VOID             InitializeDialog( VOID );
  56. VOID             TerminateDialog( VOID );
  57. VOID             InitializeHelp( VOID );
  58.  
  59. /******************** End of Procedure/Function Prototypes ********************/
  60.  
  61.  
  62. /*************************** Global Variables. ********************************/
  63. /*
  64.  * This array holds the ID's that are used to retrieve the the strings from
  65.  * the string table and placed into the global double array acStringBuffer.
  66.  * The defines that are used for the string table is used to create the
  67.  * index into the global buffer.  Since the string table starts at 1 and
  68.  * the global buffer starts at 0, the index is decremented by 1 when used.
  69.  * This means when the acStringBuffer is accessed after the strings have
  70.  * been loaded into the buffer, all indexes will be n-1, i.e.,
  71.  * IDS_DEFAULT_TARGET_FILE_NAME - 1, to get the proper string.  This is done
  72.  * simply to keep down the number of #defines.
  73.  */
  74.  
  75. USHORT ausMessageId[] = { IDS_HELP_WINDOW_TITLE,
  76.                           IDS_MESSAGE_BOX_TITLE,
  77.                           IDS_MMIO_INSTALLPROC_NAME,
  78.                           IDS_MMIO_INSTALLPROC_DLL_NAME,
  79.                           IDS_HELP_LIBRARY_FILE,
  80.                           IDS_MAIN_WINDOW_TITLE };
  81.  
  82. HELPINIT hmiHelpStructure;             /* Help initialization structure.      */
  83.  
  84. /*
  85.  * This array holds program required text that is pulled from the string
  86.  * table.
  87.  */
  88. CHAR   acStringBuffer[ NUMBER_OF_PROGRAM_STRINGS ][ STRING_SIZE ];
  89.  
  90. HWND   hwndMainDialogBox,              /* Handle to the dialog window.        */
  91.        hwndFrame,                     /* Handle to the frame window.         */
  92.        hwndHelpInstance;               /* Handle to Help window.              */
  93. HAB    hab;                            /* Handle to the Anchor Block.         */
  94. QMSG   qmsg;                           /* Structure for messages on the queue.*/
  95. HMQ    hmq;                            /* Handle to the queue.                */
  96. BOOL   IOProcIsInstalled= FALSE;       /* Indicates current state of IO Proc  */
  97. /************************** End of Gloable Variables **************************/
  98.  
  99.  
  100. /*************************************************************************
  101.  * Name        : main
  102.  *
  103.  * Description : This function calls the InitializeDialog procedure
  104.  *               to create the dialog box, runs the message loop, and
  105.  *               finally ends the program by calling the
  106.  *               TerminateDialog.
  107.  *
  108.  * Concepts    : None.
  109.  *
  110.  * MMPM/2 API's: None.
  111.  *
  112.  * Parameters  : None.
  113.  *
  114.  * Return      : TRUE is returned to the operating system.
  115.  *
  116.  *************************************************************************/
  117. INT main( VOID )
  118. {
  119.  
  120.    InitializeDialog();
  121.  
  122.    while ( WinGetMsg( hab, (PQMSG) &qmsg, (HWND) NULL, 0, 0) )
  123.       WinDispatchMsg( hab, (PQMSG) &qmsg );
  124.  
  125.    TerminateDialog();
  126.  
  127.    return( TRUE );
  128.  
  129. } /* End of main */
  130.  
  131. /*************************************************************************
  132.  * Name        : InitializeDialog
  133.  *
  134.  * Description : This function performs the necessary initializations and
  135.  *               setups that are required to show/run a dialog box as a
  136.  *               main window.  The message queue will be created, as will
  137.  *               the dialog box.  Help will also initialized.
  138.  *
  139.  *               This routine will start the window.
  140.  *
  141.  * Concepts    : None.
  142.  *
  143.  * MMPM/2 API's: None.
  144.  *
  145.  * Parameters  : None.
  146.  *
  147.  * Return      : None.
  148.  *
  149.  *************************************************************************/
  150. VOID InitializeDialog( VOID )
  151. {
  152.  
  153.    USHORT   usI;                         /* Generic counter.                                      */
  154.    CHAR     szDefaultSize[CCHMAXPATH];   /* buffer for default size menu text */
  155.  
  156.    /*
  157.     * Setup and initialize the dialog window.
  158.     */
  159.    hab = WinInitialize( (USHORT) 0 );
  160.  
  161.    /*
  162.     * Load the various strings that are required by the program.
  163.     */
  164.    for( usI = 0; usI < NUMBER_OF_PROGRAM_STRINGS; usI++)
  165.    {
  166.       WinLoadString(
  167.          hab,                            /* HAB for this dialog box.          */
  168.          (HMODULE) NULL,                 /* Get string from .exe file.        */
  169.          ausMessageId[ usI ],            /* Which string to get.              */
  170.          (SHORT) STRING_SIZE,            /* The size of the buffer.           */
  171.          (PSZ) &acStringBuffer[ usI ] ); /* Buffer to place string.           */
  172.    }
  173.  
  174.    hmq = WinCreateMsgQueue( hab, 0 );
  175.  
  176.    WinLoadString(
  177.       WinQueryAnchorBlock (HWND_DESKTOP),
  178.       (HMODULE) NULL,
  179.       IDS_DEFAULTSIZE,
  180.       sizeof(szDefaultSize),
  181.       szDefaultSize);
  182.  
  183.    hwndFrame =                  /* Returns the handle to the frame.           */
  184.       WinLoadSecondaryWindow(
  185.          HWND_DESKTOP,          /* Parent of the dialog box.                  */
  186.          HWND_DESKTOP,          /* Owner of the dialog box.                   */
  187.          (PFNWP) MainDialogProc,/* 'Window' procedure for the dialog box.     */
  188.          (HMODULE) NULL,        /* Where is the dialog.  Null is EXE file..   */
  189.          ID_MAIN_DIALOG_BOX,    /* Dialog ID.                                 */
  190.          (PVOID) NULL );        /* Creation Parameters for the dialog.        */
  191.  
  192.    /*
  193.     * Retrieve the handle to the dialog box by specifying the QS_DIALOG flag.
  194.     */
  195.    hwndMainDialogBox = WinQuerySecondaryHWND(hwndFrame, QS_DIALOG);
  196.  
  197.    /*
  198.     * Add Default Size menu item to system menu of the secondary window.
  199.     */
  200.    WinInsertDefaultSize(hwndFrame, szDefaultSize);
  201.  
  202.    /*
  203.     * Set the name of the sample program in the title bar of the dialog
  204.     * window.  This is done so that the program name will show up in
  205.     * the Task List window, via the FCF_TASKLIST flag AND will NOT
  206.     * show the .exe file name of the program.  If the FCF_TASKLIST flag
  207.     * is used the .exe file name AND the dialog title will show up
  208.     * in the title bar.  This is not wanted.
  209.     */
  210.    WinSetWindowText(
  211.       hwndFrame,
  212.       acStringBuffer[ IDS_MAIN_WINDOW_TITLE - 1 ] );
  213.  
  214.    /*
  215.     * Initialize the help structure and associate the help instance to this
  216.     * dialog via it's handle to anchor block.
  217.     */
  218.    InitializeHelp();
  219.  
  220. } /* End of InitializeDialog */
  221.  
  222.  
  223. /*************************************************************************
  224.  * Name        : TerminateDialog
  225.  *
  226.  * Description : This routine is called after the message dispatch loop
  227.  *               has ended because of a WM_QUIT message.  The code will
  228.  *               destroy the help instance, messages queue, and window.
  229.  *
  230.  * Concepts    : None.
  231.  *
  232.  * MMPM/2 API's: None.
  233.  *
  234.  * Parameters  : None.
  235.  *
  236.  * Return      : None.
  237.  *
  238.  *************************************************************************/
  239. VOID TerminateDialog( VOID )
  240. {
  241.    USHORT usCounter = 0;   /* Generic counter.                                */
  242.  
  243.    /*
  244.     * Destroy the Help Instance for this dialog window.
  245.     */
  246.    if ( hwndHelpInstance != (HWND) NULL )
  247.    {
  248.       WinDestroyHelpInstance( hwndHelpInstance );
  249.    }
  250.  
  251.    WinDestroySecondaryWindow( hwndFrame );
  252.    WinDestroyMsgQueue( hmq );
  253.    WinTerminate( hab );
  254.  
  255. }  /* End of TerminateDialog */
  256.  
  257.  
  258. /*************************************************************************
  259.  * Name        : MainDialogProc
  260.  *
  261.  * Description : This function controls the main dialog box.  It will
  262.  *               handle received messages such as pushbutton notifications,
  263.  *               help requests, minimize actions, etc.
  264.  *
  265.  *               The following messages are handled specifically by this
  266.  *               routine.
  267.  *
  268.  *                  WM_INITDLG
  269.  *                  WM_CLOSE
  270.  *                  WM_HELP
  271.  *                  WM_COMMAND
  272.  *                  WM_MINMAXFRAME
  273.  *
  274.  * Concepts    : None.
  275.  *
  276.  *
  277.  * MMPM/2 API's: None.
  278.  *
  279.  *
  280.  * Parameters  : hwnd - Handle for the Main dialog box.
  281.  *               msg  - Message received by the dialog box.
  282.  *               mp1  - Parameter 1 for the just recieved message.
  283.  *               mp2  - Parameter 2 for the just recieved message.
  284.  *
  285.  * Return      : 0 or result of default processing.
  286.  *
  287.  *************************************************************************/
  288. MRESULT EXPENTRY MainDialogProc( HWND   hwnd,
  289.                                  ULONG  msg,
  290.                                  MPARAM mp1,
  291.                                  MPARAM mp2 )
  292. {
  293.  
  294.    static BOOL fIsProgramMinimized  = FALSE;    /* Flag for minimized state.  */
  295.    static PSWP pswpWindowActionMP = (PSWP) NULL;/* Indicates Min./Max window. */
  296.    static HWND hwndSetPB;                       /* Handle to the Conver PB.   */
  297.    HPOINTER hpProgramIcon;                      /* Program Icon pointer.      */
  298.  
  299.    switch( msg )
  300.    {
  301.  
  302.       /*
  303.        * Perform the initial creation of the dialog window and any one time
  304.        * processing that is required.
  305.        */
  306.       case WM_INITDLG :
  307.  
  308.          /*
  309.           * Set the icon to be used for this dialog box.
  310.           */
  311.          hpProgramIcon =
  312.             WinLoadPointer(
  313.                HWND_DESKTOP,
  314.                (HMODULE) NULL, /* Where the resource is kept. (Exe file)      */
  315.                ID_ICON );      /* Which icon to use.                          */
  316.  
  317.          WinDefSecondaryWindowProc(
  318.             hwnd,              /* Dialog window handle.                       */
  319.             WM_SETICON,        /* Message to the dialog.  Set it's icon.      */
  320.             (MPARAM) hpProgramIcon,
  321.             (MPARAM) 0 );      /* mp2 no value.                               */
  322.  
  323.  
  324.          WinSendDlgItemMsg(hwnd, ID_INSTAL, BM_SETCHECK,
  325.                            MPFROM2SHORT (TRUE, 0), NULL);
  326.  
  327.  
  328.          hwndSetPB =
  329.             WinWindowFromID(
  330.                hwnd,                   /* Handle of this dialog window.       */
  331.                ID_OK_PB );             /* ID of the left most PM control.     */
  332.  
  333.       /*
  334.        * A close message was received as a result of the Close on the System
  335.        * Menu being selected.
  336.        */
  337.       case WM_CLOSE :
  338.          /*
  339.           * The call to the WinDefSecondaryWindowProc is required so that the dialog
  340.           * box will be closed.  This is needed since the WM_QUIT is not
  341.           * processed in the same manner for dialog boxes and windows.
  342.           */
  343.          return( WinDefSecondaryWindowProc( hwnd, msg, mp1, mp2 ) );
  344.  
  345.       /*
  346.        * The dialog window has recieved a request for help from the user,
  347.        * i.e., the Help pushbutton was pressed.  Send the HM_DISPLAY_HELP
  348.        * message to the Help Instance with the IPF resource identifier
  349.        * for the correct HM panel.  This will show the help panel for this
  350.        * sample program.
  351.        */
  352.       case WM_HELP :
  353.       {
  354.          WinSendMsg(
  355.             hwndHelpInstance,
  356.             HM_DISPLAY_HELP,
  357.             MPFROMSHORT( 1 ),
  358.             MPFROMSHORT( HM_RESOURCEID ) );
  359.          return( 0 );
  360.       }  /* End of WM_HELP. */
  361.  
  362.       /*
  363.        * This message is sent whenever a pushbutton is selected.
  364.        */
  365.       case WM_COMMAND :
  366.          /*
  367.           * To get which pushbutton was pressed the SHORT1FROMMP macro
  368.           * is used.
  369.           */
  370.          switch( SHORT1FROMMP( mp1 ) )
  371.          {
  372.             case ID_OK_PB :
  373.  
  374.                /* When the user selects the Set PB, we'll call a routine
  375.                 * to install or deinstall the IO Procedure.
  376.                 */
  377.  
  378.                if (DoTheInstallation (hwnd) == TRUE)
  379.                {
  380.                  ShowAMessage(
  381.                       IDS_INSTALLATION_IS_COMPLETE,
  382.                       MB_OK | MB_INFORMATION | MB_HELP |
  383.                       MB_MOVEABLE );
  384.  
  385.                  return ( 0 );
  386.                }
  387.                return( 0 );
  388.  
  389.             case DID_CANCEL:                        /* Handle ESC key */
  390.             case ID_CANCEL_PB :
  391.                /*
  392.                 * Send a WM_CLOSE message to this program so that it can
  393.                 * be ended.
  394.                 */
  395.                WinSendMsg(
  396.                   hwnd,
  397.                   WM_CLOSE,
  398.                   (MPARAM) NULL,
  399.                   (MPARAM) NULL );
  400.  
  401.                return( 0 );
  402.  
  403.          }  /* End of Command Switch */
  404.  
  405.          return( 0 );
  406.  
  407.       /*
  408.        * This message is received whenever a PM control is used in the
  409.        * dialog window.
  410.        */
  411.  
  412.       case WM_MINMAXFRAME :
  413.       {
  414.          /*
  415.           * In PM, some controls may have to be hidden if an icon is
  416.           * desired when the program is minimized.  If the control is not
  417.           * hidden then it or a piece of it may show up in place of the icon.
  418.           *
  419.           * Therefore we use the handle to the left most control and if the
  420.           * message indicates that the program is to be minimized then we
  421.           * will hide the control.  When the program is Restored the control
  422.           * will be shown.
  423.           */
  424.  
  425.          pswpWindowActionMP = (PSWP) LONGFROMMP( mp1 );
  426.  
  427.          if ( pswpWindowActionMP->fl & SWP_MINIMIZE )
  428.          {
  429.             fIsProgramMinimized = TRUE;
  430.  
  431.             WinShowWindow(
  432.                hwndSetPB,             /* Handle to the control.              */
  433.                FALSE );                /* Hide the control window.            */
  434.          }
  435.          else
  436.          {
  437.             fIsProgramMinimized = FALSE;
  438.  
  439.             WinShowWindow(
  440.                hwndSetPB,          /* Handle to the control.              */
  441.                TRUE );                 /* Show the control window.            */
  442.          }
  443.  
  444.          return( WinDefSecondaryWindowProc( hwnd, msg, mp1, mp2 ) );
  445.       }  /* End of MINMAXFRAME */
  446.  
  447.       default:
  448.           return( WinDefSecondaryWindowProc( hwnd, msg, mp1, mp2 ) );
  449.  
  450.    }  /* End of Switch */
  451.  
  452.    return( FALSE );
  453.  
  454. } /* End of MainDialogProc */
  455.  
  456.  
  457. /*************************************************************************
  458.  * Name        : DoTheInstallation
  459.  *
  460.  * Description : This function will query the radiobutton on the dialog
  461.  *               and determine if the user wants to install or deinstall the
  462.  *               IO Proc.  This routine will have all of the MMIO
  463.  *               specific code.
  464.  *
  465.  * Concepts    : How to use the mmioInstallIOPRoc aou ti install or deinstall
  466.  *               a custom IO Proc.
  467.  *
  468.  * MMPM/2 API's: mmioInstallIOProc
  469.  *
  470.  * Return      : True for success.
  471.  *               False for failure.
  472.  *
  473.  *************************************************************************/
  474. BOOL  DoTheInstallation( HWND hwnd)
  475. {
  476.    LPMMIOPROC lpmmioprocIoProc;           /* Pointer to the Installabe Proc.  */
  477.    PMMIOPROC  pmmioprocSpecialIOProc;     /* Pointer once Proc. is installed. */
  478.    HMODULE    hmModHandle;                /* Handle to the DLL module.        */
  479.    FOURCC     fccIOProc;                  /* 4 character id of Install. Proc. */
  480.    CHAR       acFailureNameBuffer[ FILE_NAME_SIZE ];  /* Failed DLL object.   */
  481.    LONG       lmmioAPIRc,                             /* MMIO API return codes*/
  482.               ldosAPIRc;                              /* DOS API return codes.*/
  483.  
  484.    /*
  485.     * Create the Identifier for this particular MMIO procedure.  This id
  486.     * will be used to route any further api's to the correct
  487.     * MMIO Installable procedure.
  488.     */
  489.    fccIOProc = mmioFOURCC( 'A', 'V', 'C', 'A' ) ;
  490.  
  491.    /*
  492.     * Get the DLL that contains the MMIO Installable procedure.
  493.     */
  494.    ldosAPIRc =
  495.       DosLoadModule(
  496.          &acFailureNameBuffer[ 0 ],    /* Object name if failure occurs.      */
  497.          FILE_NAME_SIZE,               /* Size of the name buffer.            */
  498.          acStringBuffer[ IDS_MMIO_INSTALLPROC_DLL_NAME - 1 ], /* DLL Name.    */
  499.          &hmModHandle );               /* Handle to the module.               */
  500.  
  501.    if ( ldosAPIRc != NO_ERROR )
  502.    {
  503.       ShowAMessage(
  504.          IDS_LOADMODULE_FAILED,                      /* ID of the message.    */
  505.          MB_OK | MB_INFORMATION |  MB_HELP |
  506.             MB_MOVEABLE );                           /* Message box style.    */
  507.  
  508.       return( FALSE );
  509.    }
  510.  
  511.    /*
  512.     * Get the address of the MMIO Installable procedure.
  513.     */
  514.    ldosAPIRc =
  515.       DosQueryProcAddr(
  516.          hmModHandle,                  /* Handle to the DLL module.           */
  517.          0L,                           /* NULL gives the entry point.         */
  518.          acStringBuffer[ IDS_MMIO_INSTALLPROC_NAME - 1 ], /* Procedure name   */
  519.          (PFN *) &lpmmioprocIoProc );  /* Pointer to the Installable proc.    */
  520.  
  521.    if ( ldosAPIRc != NO_ERROR )
  522.    {
  523.       ShowAMessage(
  524.          IDS_QUERY_PROC_ADDR_FAILED,                 /* ID of the message.    */
  525.          MB_OK | MB_INFORMATION |  MB_HELP |
  526.             MB_MOVEABLE );                           /* Message box style.    */
  527.  
  528.       return( FALSE );
  529.    }
  530.  
  531.    /*
  532.     * Check the radio button to see if the user wants to install or
  533.     * deinstall...
  534.     */
  535.    if (WinSendDlgItemMsg ( hwnd
  536.                          , ID_INSTAL
  537.                          , BM_QUERYCHECK
  538.                          , NULL, NULL))
  539.    {
  540.  
  541.       /*
  542.        * If the user wants to install the AVC IO Procedure, we have to make sure
  543.        * that it isn't already installed.  The state of the io procedure (whether
  544.        * it's installed or not) is indicated by the IOProcIsInstalled
  545.        * flag.
  546.        */
  547.  
  548.       if (IOProcIsInstalled == FALSE)
  549.       {
  550.          /*
  551.           * If the IO proc is not installed yet, then issue the
  552.           * mmioInstallIOProc api.
  553.           */
  554.  
  555.          pmmioprocSpecialIOProc =
  556.              mmioInstallIOProc(
  557.              fccIOProc,                       /* The identifier of the procedure. */
  558.              lpmmioprocIoProc,                /* Pointer to the Installable proc. */
  559.              MMIO_INSTALLPROC );              /* Flag to Install the proc.        */
  560.  
  561.          if ( pmmioprocSpecialIOProc == (PMMIOPROC) NULL )
  562.          {
  563.             /*
  564.              * If the Install failed, put up an error msg.
  565.              */
  566.             ShowAMessage(
  567.                IDS_MMIOPROC_COULD_NOT_BE_INSTALLED,        /* ID of the message.    */
  568.                MB_OK | MB_INFORMATION |  MB_HELP |
  569.                   MB_MOVEABLE );                           /* Message box style.    */
  570.  
  571.             return( FALSE );
  572.  
  573.          } /* End of IF the installion  failed. */
  574.  
  575.          IOProcIsInstalled = TRUE;      /*  The install succeded. Set the flag  */
  576.          return ( TRUE );
  577.       }
  578.       else
  579.       {
  580.  
  581.          /* The IOProcIsInstalled variable is TRUE.  This indicates that
  582.           * the user is trying to install the IO Proc without deinstalling it
  583.           * in between. This is not allowed, so display an error message
  584.           * and return.
  585.           */
  586.  
  587.          ShowAMessage(
  588.               IDS_ALREADY_INSTALLED,                /* ID of the message.    */
  589.               MB_OK | MB_INFORMATION |  MB_HELP |
  590.               MB_MOVEABLE );                        /* Message box style.    */
  591.          return( FALSE );
  592.  
  593.       }
  594.    }
  595.    else
  596.    {
  597.  
  598.    /* If the "Install IO Proc" radio button is not selected, then the
  599.     * "Deinstall IO Proc" radio button must be selected - since radio buttons
  600.     * are mutually exclusive.
  601.     * Check to make sure that the IO Proc is installed, before you let the
  602.     * user deinstall it.
  603.     */
  604.  
  605.       if (IOProcIsInstalled == TRUE)
  606.       {
  607.          /*
  608.           * Issue the mmioInstallIOProc api to deinstall the AVC IO Proc.
  609.           */
  610.  
  611.          pmmioprocSpecialIOProc =
  612.             mmioInstallIOProc(
  613.                fccIOProc,               /* The identifier of the procedure. */
  614.                lpmmioprocIoProc,        /* Pointer to the Installable proc. */
  615.                MMIO_REMOVEPROC );       /* Flag to deInstall the proc.      */
  616.  
  617.          IOProcIsInstalled = FALSE;     /* DeInstall succeded. Set the flag */
  618.          return ( TRUE );
  619.       }
  620.       else
  621.       {
  622.  
  623.          /* The IOProcIsInstalled variable is FALSE.  This indicates that
  624.           * the user is trying to deinstall the IO Proc without installing it
  625.           * inbetween.
  626.           * This is not allowed, so display an error message and return.
  627.           */
  628.  
  629.          ShowAMessage(
  630.              IDS_INSTALL_FIRST,                      /* ID of the message.    */
  631.              MB_OK | MB_INFORMATION |  MB_HELP |
  632.              MB_MOVEABLE );                          /* Message box style.    */
  633.  
  634.          return( FALSE );
  635.       }
  636.    } /* End of IF that checks which radio button is selected. */
  637.  
  638. }  /* End of DoTheInstallation. */
  639.  
  640. /*************************************************************************
  641.  * Name        : InitializeHelp
  642.  *
  643.  * Description : This procedure will set up the initial values in the
  644.  *               global help structure.  This help structure will then
  645.  *               be passed on to the Help Manager when the Help Instance
  646.  *               is created.  The handle to the Help Instance will be
  647.  *               kept for later use.
  648.  *
  649.  * Concepts    : None.
  650.  *
  651.  * MMPM/2 API's: None.
  652.  *
  653.  * Parameters  : None.
  654.  *
  655.  * Return      : None.
  656.  *
  657.  *************************************************************************/
  658. VOID InitializeHelp( VOID )
  659. {
  660.  
  661.    /*
  662.     * Get the size of the initialization structure.
  663.     */
  664.    hmiHelpStructure.cb              = sizeof( HELPINIT );
  665.  
  666.    hmiHelpStructure.ulReturnCode    = (ULONG) NULL; /* RC from initialization.*/
  667.    hmiHelpStructure.pszTutorialName = (CHAR) NULL;  /* No tutorial program.   */
  668.  
  669.    hmiHelpStructure.phtHelpTable    = (PVOID)(0xffff0000 |
  670.       ID_AVC_HELPTABLE );
  671.  
  672.    /*
  673.     * The action bar is not used, so set the following to NULL.
  674.     */
  675.    hmiHelpStructure.hmodAccelActionBarModule = (HMODULE) NULL;
  676.    hmiHelpStructure.idAccelTable             = (USHORT) NULL;
  677.    hmiHelpStructure.idActionBar              = (USHORT) NULL;
  678.  
  679.    /*
  680.     * The Help window title.
  681.     */
  682.    hmiHelpStructure.pszHelpWindowTitle  = (PSZ)
  683.       acStringBuffer[ IDS_HELP_WINDOW_TITLE - 1];
  684.  
  685.    /*
  686.     * The Help table is in the executable file.
  687.     */
  688.    hmiHelpStructure.hmodHelpTableModule = (HMODULE) NULL;
  689.  
  690.    /*
  691.     * The help panel ID is not displayed.
  692.     */
  693.    hmiHelpStructure.fShowPanelId       = (ULONG) NULL;
  694.  
  695.    /*
  696.     * The library that contains the help panels.
  697.     */
  698.    hmiHelpStructure.pszHelpLibraryName  =
  699.       acStringBuffer[ IDS_HELP_LIBRARY_FILE - 1 ];
  700.  
  701.    /*
  702.     * Create the Help Instance for IPF.
  703.     * Give IPF the Anchor Block handle and address of the IPF initialization
  704.     * structure, and check that creation of Help was a success.
  705.     */
  706.    hwndHelpInstance = WinCreateHelpInstance(
  707.                          hab,                   /* Anchor Block Handle.       */
  708.                          &hmiHelpStructure );   /* Help Structure.            */
  709.  
  710.    if ( hwndHelpInstance == (HWND) NULL )
  711.    {
  712.       ShowAMessage(
  713.          IDS_HELP_CREATION_FAILED,                     /* ID of the message.  */
  714.          MB_OK | MB_INFORMATION |
  715.             MB_MOVEABLE );                             /* Message box style.  */
  716.    }
  717.    else
  718.    {
  719.       if ( hmiHelpStructure.ulReturnCode )
  720.       {
  721.          ShowAMessage(
  722.             IDS_HELP_CREATION_FAILED,                     /* ID of the message*/
  723.             MB_OK | MB_INFORMATION |
  724.                MB_MOVEABLE );                             /* Message box style*/
  725.  
  726.          WinDestroyHelpInstance( hwndHelpInstance );
  727.       }
  728.    }  /* End of IF checking the creation of the Help Instance. */
  729.  
  730.    /*
  731.     * Associate the Help Instance of the IPF to this dialog window.
  732.     */
  733.    if ( hwndHelpInstance != (HWND) NULL )
  734.    {
  735.      WinAssociateHelpInstance(
  736.         hwndHelpInstance,     /* The handle of the Help Instance.             */
  737.         hwndFrame );          /* Associate to this frame window.             */
  738.    }
  739.  
  740. }  /* End of InitializeHelp */
  741.  
  742.  
  743. /*************************************************************************
  744.  * Name        : ShowAMessage
  745.  *
  746.  * Description : This function will show text in a message box.  The text
  747.  *               is pulled from the string table that is originally kept
  748.  *               in the resource file.  The text is retrieved by the
  749.  *               message id that is passed into this function.  This id
  750.  *               is used in the WinLoadString OS/2 API to get the correct
  751.  *               string from the table.
  752.  *
  753.  * Concepts    : None.
  754.  *
  755.  * MMPM/2 API's: None.
  756.  *
  757.  * Parameters  : pcMessageTitle    - The tile to be placed in the message
  758.  *                                   box.
  759.  *               usMessageId       - The message id that identifies which
  760.  *                                   string to retreived from the string
  761.  *                                   table.
  762.  *               ulMessageBoxStyle - The style of the message box.  Which
  763.  *                                   icons, buttons, etc., to show.
  764.  *
  765.  * Return      : The result from the message box.
  766.  *
  767.  *************************************************************************/
  768. USHORT ShowAMessage( USHORT usMessageId,
  769.                      ULONG  ulMessageBoxStyle )
  770. {
  771.  
  772.    CHAR   acStringTableBuffer[ STRING_SIZE ];   /* Buffer for Resource string.*/
  773.    USHORT usMessageBoxResult;                   /* User input from Mess. Box. */
  774.  
  775.    /*
  776.     * Get the string from the Resource defined string table and show it
  777.     * in the message box.
  778.     */
  779.    WinLoadString(
  780.       hab,                          /* HAB for this dialog box.               */
  781.       (HMODULE) NULL,               /* Get the string from the .exe file.     */
  782.       usMessageId,                  /* Which string to get.                   */
  783.       (SHORT) STRING_SIZE,          /* The size of the buffer.                */
  784.       acStringTableBuffer );        /* The buffer to place the string.        */
  785.  
  786.    usMessageBoxResult =
  787.       WinMessageBox(
  788.          HWND_DESKTOP,                 /* Parent handle of the message box.   */
  789.          hwndMainDialogBox,            /* Owner handle of the message box.    */
  790.          acStringTableBuffer,          /* String to show in the message box.  */
  791.          acStringBuffer[
  792.             IDS_MESSAGE_BOX_TITLE - 1],/* Title to show in the message box.   */
  793.          ID_MESSAGE_BOX,               /* Message Box Id.                     */
  794.          ulMessageBoxStyle );          /* The style of the message box.       */
  795.  
  796.    return( usMessageBoxResult );
  797.  
  798. }  /* End of ShowAMessage */
  799.  
  800.  
  801.