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