home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / amiiprog.zip / MCISTRNG.C < prev    next >
C/C++ Source or Header  |  1992-05-27  |  89KB  |  2,386 lines

  1. /**************************************************************************
  2.  * File Name   : MCISTRNG.C
  3.  *
  4.  * Description : This file contains the C source code required for the
  5.  *               MCISTRNG sample program.  The user enters MCI String
  6.  *               commands from a combination box and presses the Send
  7.  *               pushbutton.  The command is sent to the MCD and the string
  8.  *               is placed in the combination box's list box.
  9.  *
  10.  *               The MCD will take the MCI String Command and process it into
  11.  *               the correct MCI Commands.  Depending on the MCI String
  12.  *               Command the MCD will sent MCI Notification messages back to
  13.  *               the application.  These messages will be filtered as per the
  14.  *               user's instructions so that only certain messages will be
  15.  *               shown.
  16.  *
  17.  * Concepts    : This sample program will show how the MCI String interface
  18.  *               is used.  Basically, the use of the interface involves
  19.  *               sending MCI String Commands to the MCD, and handling the
  20.  *               MCI Notification messages that are recieved by the Call
  21.  *               Back window.
  22.  *
  23.  * MMPM/2 API's: List of all MMPM/2 API's that are used in
  24.  *               this module
  25.  *
  26.  *                mciSendString
  27.  *                mciGetErrorString
  28.  *
  29.  * Required
  30.  *    Files    : mcistrng.c         Source Code.
  31.  *               mcistrng.h         Include file.
  32.  *               mcistrng.dlg       Dialog definition.
  33.  *               mcistrng.rc        Resources.
  34.  *               mcistr1.ipf        Help text for the Main Dialog.
  35.  *               mcistr2.ipf        Help text for the Display Messages Dialog.
  36.  *               mcistr3.ipf        Help text for the Include Dialog.
  37.  *               makefile           Make file.
  38.  *               mcistrng.def       Linker definition file.
  39.  *               mcistrng.ico       MCI String Icon.
  40.  *
  41.  * Copyright (C) IBM October 1991
  42.  ******************************************************************************/
  43.  
  44. #define  INCL_WIN                        /* Required to use Win APIs.         */
  45. #define  INCL_PM                         /* Required to use PM APIs.          */
  46. #define  INCL_GPIPRIMATIVES              /* Required to use GPI OS/2 APIs.    */
  47. #define  INCL_DOSDATETIME                /* Required for get date time info.  */
  48. #define  INCL_DOSPROCESS                 /* Required for OS/2 process APIs.   */
  49. #define  INCL_WINHELP                    /* Required to use IPF.              */
  50. #define  INCL_SECONDARYWINDOW            /* required for secondary window     */
  51.  
  52. #include <os2.h>
  53. #include <os2me.h>
  54. #include <stdio.h>
  55. #include <stdlib.h>
  56. #include <string.h>
  57.  
  58. #include <sw.h>
  59.  
  60. #include "mcistrng.h"
  61.  
  62.  
  63. /*********************** Procedure/Function Prototypes ************************/
  64. /*
  65.  * This definition is required to use the sample program with the IBM
  66.  * C compiler.
  67.  */
  68. #pragma linkage( MainDialogProc, system )
  69. #pragma linkage( IncludeDialogProc, system )
  70. #pragma linkage( DisplayDialogProc, system )
  71. #pragma linkage( DisplayListBoxProc, system )
  72.  
  73.  
  74. MRESULT EXPENTRY MainDialogProc( HWND   hwnd,
  75.                                  ULONG  msg,
  76.                                  MPARAM mp1,
  77.                                  MPARAM mp2 );
  78. MRESULT EXPENTRY IncludeDialogProc( HWND   hwnd,
  79.                                     ULONG  msg,
  80.                                     MPARAM mp1,
  81.                                     MPARAM mp2 );
  82. MRESULT EXPENTRY DisplayDialogProc( HWND   hwnd,
  83.                                     ULONG  msg,
  84.                                     MPARAM mp1,
  85.                                     MPARAM mp2 );
  86. MRESULT EXPENTRY DisplayListBoxProc( HWND   hwnd,
  87.                                      ULONG  msg,
  88.                                      MPARAM mp1,
  89.                                      MPARAM mp2 );
  90.  
  91. BOOL             GetStringFromComboBox( HWND hwndStringComboBox,
  92.                                         PSZ  pszMCIString );
  93. BOOL             IsMCIStringValid( PSZ pszMCIString );
  94.  
  95. USHORT           ShowAMessage( HWND   hwndOwnerWindow,
  96.                                CHAR   *pcMessageTitle,
  97.                                USHORT usMessageId,
  98.                                ULONG  ulMessageBoxStyle );
  99. VOID             InitializeHelp( HELPINIT       *phmiHelpStructure,
  100.                                  WHICH_DIALOG_T wdtDialog );
  101. VOID             SendStringToMCD( HWND hwndComboBox );
  102. VOID             InitializeDialog( VOID );
  103. VOID             TerminateDialog( VOID );
  104. VOID             SetSystemMenu( HWND hwndDialogWindow );
  105. VOID             SendScrollBarMessage( HWND  hwndDialogBox,
  106.                                        SHORT sScrollBarMessage );
  107.  
  108. /******************** End of Procedure/Function Prototypes ********************/
  109.  
  110.  
  111. /**************************** Global Variables. *******************************/
  112.  
  113. /*
  114.  * This array holds the ID's that are used to retrieve the the strings from
  115.  * the string table and placed into the global double array acStringBuffer.
  116.  * The defines that are used for the string table is used to create the index
  117.  * into the global buffer.  Since the string table starts at 1 and the global
  118.  * buffer starts at 0, the index is decremented by 1 when used.  This means
  119.  * when the acStringBuffer is accessed after the strings have been loaded into
  120.  * the buffer, all indexes will be n-1, i.e., IDS_MAIN_HELP_WINDOW_TITLE - 1,
  121.  * to get the proper string.  This is done simply to keep down the number of
  122.  * #defines.
  123.  */
  124. USHORT ausMessageId[] = { IDS_MAIN_WINDOW_TITLE,
  125.                           IDS_MAIN_HELP_WINDOW_TITLE,
  126.                           IDS_INCLUDE_HELP_WINDOW_TITLE,
  127.                           IDS_DISPLAY_HELP_WINDOW_TITLE,
  128.                           IDS_NORMAL_ERROR_MESSAGE_BOX_TEXT,
  129.                           IDS_MAIN_HELP_LIBRARY_FILE,
  130.                           IDS_DISPLAY_HELP_LIBRARY_FILE,
  131.                           IDS_INCLUDE_HELP_LIBRARY_FILE,
  132.                           IDS_DEFAULTSIZE,
  133.                           IDS_RETURN_STRING,
  134.                           IDS_UNKNOWN};
  135.  
  136.  
  137. HELPINIT hmiMainHelpStructure,         /* Help initialization structures.     */
  138.          hmiIncludeHelpStructure,
  139.          hmiDisplayHelpStructure;
  140.  
  141. /*
  142.  * This variable will hold the address of the window procedure that controls
  143.  * the List Box that is in the Display Messages dialog.  This is required
  144.  * since we subclass the List Box to handle certain user actions.
  145.  */
  146. PFNWP pfnwpDisplayListBoxProc;
  147.  
  148. /*
  149.  * This array has the ID values for each of the check boxes used in the
  150.  * Include Dialog Box.  These values are used to get the check box window
  151.  * handles.
  152.  */
  153. USHORT ausCheckBoxIDs[] = { ID_NOTIFY_CB,
  154.                             ID_PASSDEVICE_CB,
  155.                             ID_POSITION_CHANGE_PB,
  156.                             ID_EVENT_CB,
  157.                             ID_CUEPOINT_CB,
  158.                             ID_PLAYLIST_CB
  159.                           };
  160.  
  161. /*
  162.  * This array holds the 'check' state of the check boxes.  TRUE indicates
  163.  * that the check box is 'checked off'.
  164.  */
  165. BOOL afCheckBoxState[] = { TRUE,    /* MM_MCINOTIFY is set.                   */
  166.                            TRUE,    /* MM_MCIPASSDEVICE is set.               */
  167.                            TRUE,    /* MM_MCIPOSITIONCHANGE is set.           */
  168.                            TRUE,    /* MM_MCIEVENT is set.                    */
  169.                            TRUE,    /* MM_MCICUEPOINT is set.                 */
  170.                            TRUE     /* MM_MCIPLAYLISTMESSAGE is set.          */
  171.                          };
  172.  
  173. BOOL  fDisplayMessageWindowIsUp = FALSE;  /* flag for display message window  */
  174. /*
  175.  * Holds the string result that is returned by the sending of a MCI String
  176.  * Command.
  177.  */
  178. CHAR   acMCIReturnString[ MCI_RETURN_STRING_LENTGH ];
  179.  
  180. /*
  181.  * This array holds program required text that is pulled from the string
  182.  * table.
  183.  */
  184. CHAR   acStringBuffer[ NUMBER_OF_PROGRAM_STRINGS ][ STRING_SIZE ];
  185.  
  186. HWND   hwndMainDialogBox,              /* Handle to the Main Dialog window.   */
  187.        hwndIncludeDialogBox,           /* Handle to the Include Dialog box.   */
  188.        hwndDisplayDialogBox,           /* Handle to the Display Dialog box.   */
  189.        hwndMainHelpInstance,           /* Handle to the Main Help window.     */
  190.        hwndIncludeHelpInstance,        /* Handle to the Include Help window.  */
  191.        hwndDisplayHelpInstance,        /* Handle to the Display Help window.  */
  192.        hwndDisplayListBox,             /* Handle to the Display List Box.     */
  193.        hwndFrame,                      /* Handle to the frame window.         */
  194.        hwndSendPB,                     /* Send PB handle.                     */
  195.        hwndComboBox;                   /* Combo Box handle.                   */
  196.  
  197. HAB    hab;          /* Handle to the Anchor Block for the program.           */
  198. QMSG   qmsg;         /* Structure to hold a message on the message queue.     */
  199. HMQ    hmq;          /* Handle to the message queue.                          */
  200.  
  201. /*
  202.  * This structure holds text representations for the string commands.  It's
  203.  * used during processing of the MM_MCINOTIFY message in the DisplayDialogProc.
  204.  *
  205.  * These strings are not in the resource file because they should not be
  206.  * translated.  They are string commands, and string commands are not
  207.  * translated.  These strings correspond to command message identifiers
  208.  * listed in mmsystem.h.
  209.  */
  210.  
  211. char  *szMessage[55] = {
  212.       "",
  213.       "OPEN",
  214.       "CLOSE",
  215.       "ESCAPE",
  216.       "PLAY",
  217.       "SEEK",
  218.       "STOP",
  219.       "PAUSE",
  220.       "INFO",
  221.       "CAPABILITY",
  222.       "STATUS",
  223.       "SPIN",
  224.       "SET",
  225.       "STEP",
  226.       "RECORD",
  227.       "SYSINFO",
  228.       "SAVE",
  229.       "CUE",
  230.       "UPDATE",
  231.       "CUEPOINT",
  232.       "POS_ADVISE",
  233.       "SYNC_OFFSET",
  234.       "LOAD",
  235.       "ACQUIRE",
  236.       "RELEASE",
  237.       "MASTERAUDIO",
  238.       "GETTOC",
  239.       "DEVICESETTINGS",
  240.       "CONNECTOR",
  241.       "RESUME",
  242.       "NOT_DEFINED",
  243.       "CONNECTORINFO",
  244.       "DEFAULT_CONNECTION",
  245.       "CONNECTION",
  246.       "NOT_DEFINED",
  247.       "NOT_DEFINED",
  248.       "NOT_DEFINED",
  249.       "NOT_DEFINED",
  250.       "NOT_DEFINED",
  251.       "NOT_DEFINED",
  252.       "CAPTURE",
  253.       "FREEZE",
  254.       "GETIMAGEBUFFER",
  255.       "GETIMAGEPALETTE",
  256.       "PUT",
  257.       "REALIZE",
  258.       "REWIND",
  259.       "RESTORE",
  260.       "SETIMAGEBUFFER",
  261.       "SETIMAGEPALETTE",
  262.       "UNFREEZE",
  263.       "WHERE",
  264.       "WINDOW"};
  265.  
  266. /************************** End of Globle Variables ***************************/
  267.  
  268.  
  269. /******************************************************************************
  270.  * Name        : main
  271.  *
  272.  * Description : This function calls the InitializeDialog procedure to create
  273.  *               the dialog box, starts up the message loop, and finally calls
  274.  *               TerminateDialog when the program is to end.
  275.  *
  276.  * Concepts    : None.
  277.  *
  278.  * MMPM/2 API's: None.
  279.  *
  280.  * Parameters  : None.
  281.  *
  282.  * Return      : TRUE is returned to the operating system.
  283.  *
  284.  *************************************************************************/
  285. INT main( VOID )
  286. {
  287.  
  288.    InitializeDialog();
  289.  
  290.    while ( WinGetMsg( hab, (PQMSG) &qmsg, (HWND) NULL, 0, 0) )
  291.       WinDispatchMsg( hab, (PQMSG) &qmsg );
  292.  
  293.    TerminateDialog();
  294.  
  295.    return( TRUE );
  296.  
  297. } /* End of main */
  298.  
  299.  
  300. /******************************************************************************
  301.  * Name        : InitializeDialog
  302.  *
  303.  * Description : This function performs the necessary initializations and
  304.  *               setups that are required to show/run a dialog box as a
  305.  *               main window.  The message queue will be created, as will
  306.  *               the dialog box.  Finally the message passing loop will be
  307.  *               started to give messages to the dialog box.
  308.  *
  309.  * Concepts    : None.
  310.  *
  311.  * MMPM/2 API's: None.
  312.  *
  313.  * Parameters  : None.
  314.  *
  315.  * Return      : None.
  316.  *
  317.  ******************************************************************************/
  318. VOID InitializeDialog( VOID )
  319. {
  320.  
  321.    USHORT   usI;                         /* Generic Counter.                  */
  322.    CHAR     szDefaultSize[CCHMAXPATH];   /* buffer for default size menu text */
  323.  
  324.    /*
  325.     * Setup and initialize the dialog window.
  326.     */
  327.    hab = WinInitialize( (USHORT) 0 );
  328.  
  329.    /*
  330.     * Load the various strings that are required by the program.
  331.     */
  332.    for( usI=0; usI<NUMBER_OF_PROGRAM_STRINGS; usI++)
  333.    {
  334.       WinLoadString(
  335.          hab,                            /* HAB for this dialog box.          */
  336.          (HMODULE) NULL,                 /* Get string from .exe file.        */
  337.          ausMessageId[ usI ],            /* Which string to get.              */
  338.          (SHORT) STRING_SIZE,            /* The size of the buffer.           */
  339.          (PSZ) &acStringBuffer[ usI ] ); /* Buffer to place string.           */
  340.    }
  341.  
  342.    hmq = WinCreateMsgQueue( hab, 0 );
  343.  
  344.    WinLoadString(
  345.       WinQueryAnchorBlock (HWND_DESKTOP),
  346.       (HMODULE) NULL,
  347.       IDS_DEFAULTSIZE,
  348.       sizeof(szDefaultSize),
  349.       szDefaultSize);
  350.  
  351.    hwndFrame =                  /* Returns the handle to the frame.           */
  352.       WinLoadSecondaryWindow(
  353.          HWND_DESKTOP,          /* Parent of the dialog box.                  */
  354.          HWND_DESKTOP,          /* Owner of the dialog box.                   */
  355.          (PFNWP) MainDialogProc,/* 'Window' procedure for the dialog box.     */
  356.          (HMODULE) NULL,        /* Where is the dialog.  Null is EXE file..   */
  357.          ID_MAIN_DIALOG_BOX,    /* Dialog ID.                                 */
  358.          (PVOID) NULL );        /* Creation Parameters for the dialog.        */
  359.  
  360.    /*
  361.     * Retrieve the handle to the dialog box by specifying the QS_DIALOG flag.
  362.     */
  363.    hwndMainDialogBox = WinQuerySecondaryHWND(hwndFrame, QS_DIALOG);
  364.  
  365.    /*
  366.     * Add Default Size menu item to system menu of the secondary window.
  367.     */
  368.    WinInsertDefaultSize(hwndFrame, szDefaultSize);
  369.  
  370.    /*
  371.     * Set the name of the sample program in the title bar of the dialog
  372.     * window.  This is done so that the program name will show up in the
  373.     * Task List window, via the FCF_TASKLIST flag AND will NOT show the
  374.     * .exe file name of the program.  If the FCF_TASKLIST flag is used the
  375.     * .exe file name AND the dialog title will show up in the title bar.
  376.     * This is not wanted.
  377.     */
  378.    WinSetWindowText(
  379.       hwndFrame,
  380.       acStringBuffer[ IDS_MAIN_WINDOW_TITLE - 1 ] );
  381.  
  382.    /*
  383.     * This window is initially loaded but is NOT visible.  Only by pressing
  384.     * the Display Messages Pushbutton on the main window will this dialog
  385.     * box be displayed.  This is a non-modal dialog window.
  386.     */
  387.    hwndDisplayDialogBox =
  388.       WinLoadDlg(
  389.          HWND_DESKTOP,              /* Parent of the dialog box.              */
  390.          (HWND) NULL,               /* Owner of the dialog box.               */
  391.          (PFNWP) DisplayDialogProc, /* 'Window' procedure for the dialog box. */
  392.          (HMODULE) NULL,            /* Where is the dialog.  Null is EXE file.*/
  393.          ID_DISPLAY_DIALOG_BOX,     /* Dialog ID.                             */
  394.          (PVOID) NULL );            /* Creation Parameters for the dialog.    */
  395.  
  396.    /*
  397.     * Now that the Display Message dialog box has been created, show the
  398.     * Main Dialog window.
  399.     */
  400.    WinShowWindow(
  401.       hwndFrame,
  402.       TRUE );
  403.  
  404.    /*
  405.     * Initialize the help structures and associate the help instances to the
  406.     * correct dialogs via the handle to anchor block.
  407.     */
  408.    InitializeHelp(
  409.       &hmiMainHelpStructure,     /* Structure to hold help information.       */
  410.       MAIN_DIALOG );             /* Which dialog is being initialized.        */
  411.  
  412.    InitializeHelp(
  413.       &hmiDisplayHelpStructure, /* Structure to hold help information.        */
  414.       DISPLAY_DIALOG );         /* Which dialog is being initialized.         */
  415.  
  416.    InitializeHelp(
  417.       &hmiIncludeHelpStructure, /* Structure to hold help information.        */
  418.       INCLUDE_DIALOG );         /* Which dialog is being initialized.         */
  419.  
  420. } /* End of InitializeDialog */
  421.  
  422.  
  423. /******************************************************************************
  424.  * Name        : TerminateDialog
  425.  *
  426.  * Description : This routine is called after the message dispatch loop
  427.  *               has ended because of a WM_QUIT message.  The code will
  428.  *               destroy the help instance, messages queue and window.
  429.  *
  430.  * Concepts    : None.
  431.  *
  432.  * MMPM/2 API's: None.
  433.  *
  434.  * Parameters  : None.
  435.  *
  436.  * Return      : None.
  437.  *
  438.  ******************************************************************************/
  439. VOID TerminateDialog( VOID )
  440. {
  441.    USHORT usCounter = 0;            /* Generic Counter.                       */
  442.  
  443.    /*
  444.     * Destroy the Help Instance for this dialog window.
  445.     */
  446.    if ( hwndMainHelpInstance != (HWND) NULL )
  447.    {
  448.       WinDestroyHelpInstance( hwndMainHelpInstance );
  449.    }
  450.  
  451.    if ( hwndDisplayHelpInstance != (HWND) NULL )
  452.    {
  453.       WinDestroyHelpInstance( hwndDisplayHelpInstance );
  454.    }
  455.  
  456.    if ( hwndIncludeHelpInstance != (HWND) NULL )
  457.    {
  458.       WinDestroyHelpInstance( hwndIncludeHelpInstance );
  459.    }
  460.  
  461.    WinDestroySecondaryWindow( hwndFrame );
  462.    WinDestroyWindow( hwndDisplayDialogBox );
  463.    WinDestroyMsgQueue( hmq );
  464.    WinTerminate( hab );
  465.  
  466. }  /* End of TerminateDialog */
  467.  
  468.  
  469. /******************************************************************************
  470.  * Name        : MainDialogProc
  471.  *
  472.  * Description : This function controls the main dialog box.  It will handle
  473.  *               received messages such as pushbutton notifications, timing
  474.  *               events, etc.
  475.  *
  476.  * Concepts    : None.
  477.  *
  478.  * MMPM/2 API's: None.
  479.  *
  480.  * Parameters  : hwnd - Handle for the Main dialog box.
  481.  *               msg  - Message received by the dialog box.
  482.  *               mp1  - Parameter 1 for the just recieved message.
  483.  *               mp2  - Parameter 2 for the just recieved message.
  484.  *
  485.  * Return      : 0 or the result of default processing.
  486.  *
  487.  ******************************************************************************/
  488. MRESULT EXPENTRY MainDialogProc( HWND   hwnd,
  489.                                  ULONG  msg,
  490.                                  MPARAM mp1,
  491.                                  MPARAM mp2 )
  492. {
  493.    static PSWP  pswpWindowActionMP    = (PSWP) NULL; /*  Action of Window.    */
  494.    static BOOL  fIsTheWindowMinimized = FALSE;       /* State of Window.      */
  495.  
  496.    HPOINTER hpProgramIcon;                           /* Pointer to Icon.      */
  497.    CHAR szFileNameBuffer[ FILE_NAME_SIZE ];
  498.  
  499.    switch( msg )
  500.    {
  501.       /*
  502.        * Since the dialog was just started, setup various objects.
  503.        */
  504.       case WM_INITDLG :
  505.          /*
  506.           * Set the sample programs minimize icon.
  507.           */
  508.          hpProgramIcon =
  509.             WinLoadPointer(
  510.                HWND_DESKTOP,
  511.                (HMODULE) NULL, /* Where the resource is kept. (Exe file)      */
  512.                ID_ICON );      /* Which icon to use.                          */
  513.  
  514.          WinDefSecondaryWindowProc(
  515.             hwnd,              /* Dialog window handle.                       */
  516.             WM_SETICON,        /* Message to the dialog.  Set it's icon.      */
  517.             (MPARAM) hpProgramIcon,
  518.             (MPARAM) 0 );      /* mp2 no value.                               */
  519.  
  520.          /*
  521.           * Get the handle of the Combination box so that it can be reused
  522.           * in future processing.
  523.           */
  524.          hwndComboBox =
  525.             WinWindowFromID(
  526.                hwnd,
  527.                ID_STRING_COMBO_BOX );
  528.  
  529.          /*
  530.           * Get the handle of the Send push button.
  531.           */
  532.          hwndSendPB =
  533.             WinWindowFromID(
  534.                hwnd,                   /* Handle of this dialog window.       */
  535.                ID_MAIN_SEND_PB );      /* ID of the left most PM control.     */
  536.  
  537.          /*
  538.           * Disable the Send push button until valid text has been placed
  539.           * into the entry field.
  540.           */
  541.          WinEnableWindow(
  542.                hwndSendPB,             /* Handle of this dialog window.       */
  543.                FALSE );                /* ID of the left most PM control.     */
  544.  
  545.          /*
  546.           * Set the String limit size for the Combo Box's Entry Field.
  547.           */
  548.          WinSendMsg(
  549.             hwndComboBox,
  550.             EM_SETTEXTLIMIT,
  551.             MPFROMLONG( MCI_STRING_LENGTH ),
  552.             0L );
  553.  
  554.          return( 0 );
  555.  
  556.       case WM_CLOSE :
  557.          /*
  558.           * The call to the WinDefSecondaryWindowProc is required so that the
  559.           * dialog box will be closed.  This is needed since the WM_QUIT is
  560.           * not processed in the same manner for dialog boxes and windows.
  561.           * But first cause the Display Messages Dialog to shutdown.
  562.           */
  563.          WinSendMsg(
  564.             hwndDisplayDialogBox,
  565.             WM_QUIT,
  566.             0L,
  567.             0L );
  568.  
  569.          return( WinDefSecondaryWindowProc( hwnd, msg, mp1, mp2 ) );
  570.  
  571.       case WM_HELP :
  572.          /*
  573.           * The dialog window has recieved a request for help from the user,
  574.           * i.e., the Help pushbutton was pressed.  Send the HM_DISPLAY_HELP
  575.           * message to the Help Instance with the IPF resource identifier
  576.           * for the correct HM panel.  This will show the help panel for this
  577.           * sample program.
  578.           */
  579.          WinSendMsg(
  580.             hwndMainHelpInstance,
  581.             HM_DISPLAY_HELP,
  582.             MPFROMSHORT( 1 ),
  583.             MPFROMSHORT( HM_RESOURCEID ) );
  584.          return( 0 );
  585.  
  586.       case WM_CONTROL :
  587.          switch( SHORT1FROMMP( mp1 ))
  588.          {
  589.             case ID_STRING_COMBO_BOX :
  590.             {
  591.                if ( SHORT2FROMMP( mp1 ) == CBN_EFCHANGE )
  592.                {
  593.                  /*
  594.                   * See if the text in the entry field is greater than zero.
  595.                   */
  596.                  if ( WinQueryWindowText(
  597.                          hwndComboBox,
  598.                          FILE_NAME_SIZE,
  599.                          szFileNameBuffer ) > 0 )
  600.                  {
  601.                     /*
  602.                      * If greater than zero enable the Send push button,
  603.                      */
  604.                     WinEnableWindow(
  605.                        hwndSendPB,
  606.                        TRUE );
  607.                  }
  608.                  else
  609.                  {
  610.                     /*
  611.                      *  Else disable the Send push button.
  612.                      */
  613.                     WinEnableWindow(
  614.                        hwndSendPB,
  615.                        FALSE );
  616.                  }
  617.                }
  618.             } /* endif */
  619.           return( 0 );
  620.         }
  621.  
  622.       case WM_COMMAND :
  623.          /*
  624.           * To get which pushbutton was pressed the SHORT1FROMMP macro
  625.           * is used.
  626.           */
  627.          switch( SHORT1FROMMP( mp1 ) )
  628.          {
  629.             /*
  630.              * The Send Push Button was pressed on the main dialog window.
  631.              */
  632.             case ID_MAIN_SEND_PB :
  633.  
  634.                SendStringToMCD( hwndComboBox );
  635.  
  636.                return( 0 );
  637.  
  638.             /*
  639.              * The Display Messages Push Button was pressed on the main
  640.              * dialog window.
  641.              */
  642.             case ID_DISPLAY_MESSAGES_PB :
  643.  
  644.                /*
  645.                 * Show the Display Messages dialog box.  This dialog is always
  646.                 * running but is initially made invisible.  Therefore we will
  647.                 * make it visible at this point.
  648.                 */
  649.                WinShowWindow(
  650.                   hwndDisplayDialogBox,   /* Handle to the window.            */
  651.                   TRUE );                 /* Make the window visible.         */
  652.  
  653.                fDisplayMessageWindowIsUp = TRUE; /* Visible, set the flag.    */
  654.  
  655.                WinSetFocus(
  656.                   HWND_DESKTOP,           /* Window is in Desk top.           */
  657.                   hwndDisplayDialogBox ); /* Make the Display dialog in focus.*/
  658.  
  659.                return( 0 );
  660.  
  661.             /*
  662.              * The Cancel Push Button was pressed on the main dialog window.
  663.              * Or the ESC key was pressed.
  664.              */
  665.             case DID_CANCEL:
  666.             case ID_MAIN_CANCEL_PB :
  667.                /*
  668.                 * Send a WM_CLOSE message to the sample program so that it
  669.                 * closes itself.
  670.                 */
  671.                WinSendMsg(
  672.                   hwnd,                   /* Window handle.                   */
  673.                   WM_CLOSE,               /* The message that is sent.        */
  674.                   (MPARAM) NULL,          /* No MP1 parameter.                */
  675.                   (MPARAM) NULL );        /* No MP2 parameter.                */
  676.  
  677.                return( 0 );
  678.  
  679.          }  /* End of Command Switch */
  680.  
  681.          return( 0 );
  682.  
  683.       case WM_MINMAXFRAME :
  684.       {
  685.          /*
  686.           * The code for this message is required since this sample program
  687.           * is using a dialog box as the main window.  There is a feature
  688.           * of PM that some controls may have to be hidden if an icon is
  689.           * desired when the program is minimized.  If the control is not
  690.           * hidden then it or a piece of it may show up in place of the icon.
  691.           *
  692.           * Therefore we use the handle to the left most control and if the
  693.           * message indicates that the program is to be minimized then we
  694.           * will hide the control.  When the program is Restored the control
  695.           * will be shown.
  696.           */
  697.  
  698.          pswpWindowActionMP = (PSWP) LONGFROMMP( mp1 );
  699.  
  700.          if ( pswpWindowActionMP->fl & SWP_MINIMIZE )
  701.          {
  702.             WinShowWindow(
  703.                hwndSendPB,             /* Handle to the control.              */
  704.                FALSE );                /* Hide the control window.            */
  705.  
  706.            /*
  707.             * If Display Message Window is visible, hide it.
  708.             */
  709.            if (fDisplayMessageWindowIsUp == TRUE)
  710.               WinShowWindow(
  711.                  hwndDisplayDialogBox,
  712.                  FALSE );
  713.  
  714.          }
  715.          else
  716.          {
  717.             WinShowWindow(
  718.                hwndSendPB,             /* Handle to the control.              */
  719.                TRUE );                 /* Show the control window.            */
  720.  
  721.            /*
  722.             * If Display Message Window was visible at the time of minimizing
  723.             * the main window, make it visible.
  724.             */
  725.  
  726.            if (fDisplayMessageWindowIsUp == TRUE)
  727.               WinShowWindow(
  728.                  hwndDisplayDialogBox,
  729.                  TRUE );
  730.          }
  731.  
  732.          return( WinDefSecondaryWindowProc( hwnd, msg, mp1, mp2 ) );
  733.       }  /* End of MINMAXFRAM */
  734.  
  735.       default:
  736.           return( WinDefSecondaryWindowProc( hwnd, msg, mp1, mp2 ) );
  737.  
  738.    }  /* End of Switch */
  739.  
  740.    return( (MRESULT) FALSE );
  741.  
  742. } /* End of MainDialogProc */
  743.  
  744.  
  745. /******************************************************************************
  746.  * Name        : DisplayDialogProc
  747.  *
  748.  * Description : This function controls the Display dialog box.  It will
  749.  *               handle received messages such as pushbutton notifications,
  750.  *               timing events, etc.  This dialog is created with the Main
  751.  *               dialog box and is not destroyed until the termination of the
  752.  *               Main window.  The window is kept alive so that it can
  753.  *               process arriving MCI Notification messages.
  754.  *
  755.  *               The following messages are handled specifically by this
  756.  *               routine.
  757.  *
  758.  *                  WM_INITDLG
  759.  *                  WM_CLOSE
  760.  *                  WM_HELP
  761.  *                  WM_COMMAND
  762.  *                  WM_MINMAXFRAME
  763.  *
  764.  * Concepts    : Handling of arriving MCI Notification messages.
  765.  *
  766.  * MMPM/2 API's: MM_MCINOTIFY
  767.  *               MM_MCIPASSDEVICE
  768.  *               MM_MCIPOSITIONCHANGE
  769.  *               MM_MCIEVENT
  770.  *               MM_MCICUEPOINT
  771.  *               MM_MCIPLAYLISTMESSAGE
  772.  *
  773.  * Parameters  : hwnd - Handle for the Display dialog box.
  774.  *               msg  - Message received by the dialog box.
  775.  *               mp1  - Parameter 1 for the just recieved message.
  776.  *               mp2  - Parameter 2 for the just recieved message.
  777.  *
  778.  * Return      : 0 or the result of default processing.
  779.  *
  780.  ******************************************************************************/
  781. MRESULT EXPENTRY DisplayDialogProc( HWND   hwnd,
  782.                                     ULONG  msg,
  783.                                     MPARAM mp1,
  784.                                     MPARAM mp2 )
  785. {
  786.  
  787.    /*
  788.     * This array will hold the text that is used for the MCI Notification
  789.     * messages.
  790.     */
  791.    static CHAR acMCINotMessage[ NUMBER_OF_NOTIFICATION_MESSAGES ]
  792.                                        [ STRING_SIZE ];
  793.  
  794.    USHORT usI = 0,                             /* Generic Counter.            */
  795.           usJ = 0;                             /* Generic Counter.            */
  796.    CHAR   acTempString[ STRING_SIZE ];         /* Temp string buffer.         */
  797.    CHAR   acErrorBuf[20];                      /* Another temp buffer.        */
  798.    CHAR   acIDBuf[20];                         /* Another temp buffer.        */
  799.    CHAR   acUserParmBuf[20];                   /* Another temp buffer.        */
  800.    CHAR   acTimeBuf[20];                       /* Another temp buffer.        */
  801.    SHORT  sRC;
  802.  
  803.    switch( msg )
  804.    {
  805.  
  806.       case WM_INITDLG :
  807.          /*
  808.           * Hide the window until it is called.
  809.           */
  810.          WinShowWindow(
  811.             hwnd,
  812.             FALSE );
  813.  
  814.          fDisplayMessageWindowIsUp = FALSE;   /* Not visible, set the flag.   */
  815.  
  816.          /*
  817.           * Set the Child Dialog window's System Menu.
  818.           */
  819.          SetSystemMenu( hwnd );
  820.  
  821.          /*
  822.           * Load the text for the MCI Notification Messages.  This text
  823.           * will be shown in the Display Dialog Box's list box.
  824.           */
  825.          for( usI=STARTING_IDS_VALUE_FOR_MCI_NOTIFICATION_MESSAGES,usJ = 0;
  826.               usI<STARTING_IDS_VALUE_FOR_MCI_NOTIFICATION_MESSAGES +
  827.                      NUMBER_OF_NOTIFICATION_MESSAGES;
  828.               usI++)
  829.          {
  830.             /*
  831.              * Get the string from the Resource defined string table and
  832.              * show it in the message box.
  833.              */
  834.             sRC = WinLoadString(
  835.                   hab,                     /* HAB for this dialog box.      */
  836.                   (HMODULE) NULL,          /* The string is in the exe file.*/
  837.                   usI,                     /* Which string to get.          */
  838.                   (SHORT) STRING_SIZE,     /* The size of the buffer.       */
  839.                   acMCINotMessage[ usJ ]); /* String Buffer                 */
  840.             usJ++;
  841.          }  /* End of For that loads the MCI message text. */
  842.  
  843.          /*
  844.           * Get the handle to the list box that is in the Display Dialog.
  845.           */
  846.          hwndDisplayListBox =
  847.             WinWindowFromID(
  848.                hwnd,
  849.                ID_DISPLAY_CONTROL );
  850.  
  851.          /*
  852.           * Subclass the Display Dialog's list box so that certain actions
  853.           * can be ignored.  Some user interactions with this List Box, i.e.,
  854.           * selection of items, etc. will be trapped and ignored by the
  855.           * the sample program to meet CUA requirements.
  856.           */
  857.          pfnwpDisplayListBoxProc =
  858.             WinSubclassWindow(
  859.                hwndDisplayListBox,
  860.                (PFNWP)DisplayListBoxProc );
  861.  
  862.          return( 0 );
  863.  
  864.       case WM_CLOSE :
  865.          /*
  866.           * Since this window is not destroyed until the main dialog box
  867.           * closes, this WM_CLOSE message will simply hide the window.
  868.           */
  869.          WinShowWindow(
  870.             hwnd,                     /* Handle of the window to hide.        */
  871.             FALSE );                  /* Hide the window.                     */
  872.  
  873.          fDisplayMessageWindowIsUp = FALSE;     /* Not visible, set the flag. */
  874.  
  875.          /*
  876.           * Set the focus to the Main Dialog window.
  877.           */
  878.          WinSetFocus(
  879.             HWND_DESKTOP,             /* Use window in DESKTOP.               */
  880.             hwndMainDialogBox );      /* Set focus on the Main Dialog.        */
  881.  
  882.          WinSetFocus( HWND_DESKTOP, hwndComboBox);
  883.  
  884.          return( 0 );
  885.  
  886.       case WM_HELP :
  887.          /*
  888.           * The dialog window has recieved a request for help from the user,
  889.           * i.e., the Help pushbutton was pressed.  Send the HM_DISPLAY_HELP
  890.           * message to the Help Instance with the IPF resource identifier
  891.           * for the correct HM panel.  This will show the help panel for this
  892.           * sample program.
  893.           */
  894.          WinSendMsg(
  895.             hwndDisplayHelpInstance,
  896.             HM_DISPLAY_HELP,
  897.             MPFROMSHORT( 1 ),
  898.             MPFROMSHORT( HM_RESOURCEID ) );
  899.          return( 0 );
  900.  
  901.       case WM_COMMAND :
  902.          /*
  903.           * To get which pushbutton was pressed the SHORT1FROMMP macro
  904.           * is used.
  905.           */
  906.          switch( SHORT1FROMMP( mp1 ) )
  907.          {
  908.             /*
  909.              * The Include pushbutton was pressed.  If the Include dialog
  910.              * window is NOT currently in view then show it.  However if is
  911.              * already shown then this message will be ignored.
  912.              */
  913.             case ID_DISPLAY_INCLUDE_PB :
  914.  
  915.                /*
  916.                 * Call the Include dialog window.  This call will disable
  917.                 * the Display dialog until the Include dialog is closed.
  918.                 */
  919.                WinDlgBox(
  920.                   HWND_DESKTOP,                /* Parent of the dialog box.   */
  921.                   hwndDisplayDialogBox,        /* Owner of the dialog box.    */
  922.                   (PFNWP) IncludeDialogProc,   /* Dialog box procedure.       */
  923.                   (HMODULE) NULL,              /* Dialog is where, EXE file.  */
  924.                   ID_INCLUDE_DIALOG_BOX,       /* Dialog ID.                  */
  925.                   (PVOID) NULL );              /* Dialog Creation Parameters. */
  926.  
  927.                hwndIncludeDialogBox =
  928.                   WinWindowFromID(
  929.                      hwnd,                      /* Parent of the dialog box.  */
  930.                      ID_INCLUDE_DIALOG_BOX );   /* Dialog ID.                 */
  931.  
  932.                return( 0 );
  933.  
  934.             /*
  935.              * The Cancel pushbutton was pressed, or the ESC key was pressed.
  936.              * This will just cause the window to be hidden while the focus
  937.              * is given back to the Main dialog box.
  938.              */
  939.             case DID_CANCEL:
  940.             case ID_DISPLAY_CANCEL_PB :
  941.                /*
  942.                 * Hide the Display Messages Dialog Box.
  943.                 */
  944.                WinShowWindow(
  945.                   hwnd,                     /* Handle of the window to hide.  */
  946.                   FALSE );                  /* Hide the window.               */
  947.  
  948.                fDisplayMessageWindowIsUp = FALSE;/* Not visible, set the flag.*/
  949.  
  950.                WinSetFocus(
  951.                   HWND_DESKTOP,             /* Use window in DESKTOP.         */
  952.                   hwndMainDialogBox );      /* Set focus on the Main Dialog.  */
  953.  
  954.                WinSetFocus( HWND_DESKTOP, hwndComboBox);
  955.  
  956.                return( 0 );
  957.  
  958.          }  /* End of Command Switch */
  959.  
  960.          return( 0 );
  961.  
  962.       /*
  963.        * The following MCI Notification messages will be caused by the sending
  964.        * of MCI String Commands from the Main Dialog window.  ALL of the MCI
  965.        * messages perform a check to see if the user wishes to see the arrival
  966.        * of the MCI messages.  This is filtered through the Include Dialog box.
  967.        * If the user has indicated that the messages are to be viewed, the
  968.        * MCI Notification Messages are placed into the List Box of this window.
  969.        */
  970.       case MM_MCINOTIFY :
  971.  
  972.          /*
  973.           * Check to see if the user has filtered out this message.
  974.           */
  975.  
  976.          if ( afCheckBoxState[ ID_MM_MCINOTIFY ] == TRUE )
  977.          {
  978.             /*
  979.              * If the user has not filtered out this message, then display
  980.              * the message in the list box of the Display Messages window.
  981.              */
  982.  
  983.             WinSendMsg( hwndDisplayListBox,             /* Handle to the lb  */
  984.                         LM_INSERTITEM,                  /* Action for the lb */
  985.                         MPFROMSHORT( LIT_END ),         /* Order             */
  986.                         MPFROMP( acMCINotMessage[ ID_MM_MCINOTIFY ] ));
  987.  
  988.             /* Not only do we want to display the type of message received,
  989.              * we also want to display the information recieved with the
  990.              * message, because it can be very helpful in debugging media
  991.              * drivers.
  992.              *
  993.              * First display the command message in the list box.
  994.              */
  995.  
  996.              strcpy ( acTempString, acMCINotMessage[ ID_CMD_MSG ] );
  997.  
  998.              /*
  999.               * If the command message string is in the szMessage array
  1000.               * display it, else display UNKNOWN.
  1001.               */
  1002.              if ( HIUSHORT(mp2) <= 55 )
  1003.                 strcat ( acTempString, szMessage[ HIUSHORT(mp2) ] );
  1004.              else
  1005.                 strcat ( acTempString, acStringBuffer[ IDS_UNKNOWN - 1 ] );
  1006.  
  1007.              WinSendMsg( hwndDisplayListBox,
  1008.                          LM_INSERTITEM,
  1009.                          MPFROMSHORT( LIT_END ),
  1010.                          MPFROMP( acTempString ));
  1011.  
  1012.             /*
  1013.              * Next display the notify code.
  1014.              */
  1015.  
  1016.             if (LOUSHORT(mp1) == MCI_NOTIFY_SUPERSEDED)
  1017.                WinSendMsg( hwndDisplayListBox,
  1018.                            LM_INSERTITEM,
  1019.                            MPFROMSHORT( LIT_END ),
  1020.                            MPFROMP(acMCINotMessage[ID_MCI_NOTIFY_SUPERSEDED]));
  1021.  
  1022.             else if (LOUSHORT(mp1) == MCI_NOTIFY_ABORTED)
  1023.                WinSendMsg( hwndDisplayListBox,
  1024.                            LM_INSERTITEM,
  1025.                            MPFROMSHORT( LIT_END ),
  1026.                            MPFROMP(acMCINotMessage[ID_MCI_NOTIFY_ABORTED]));
  1027.  
  1028.             else if (LOUSHORT(mp1) == MCI_NOTIFY_SUCCESSFUL)
  1029.                WinSendMsg( hwndDisplayListBox,
  1030.                            LM_INSERTITEM,
  1031.                            MPFROMSHORT( LIT_END ),
  1032.                            MPFROMP(acMCINotMessage[ID_MCI_NOTIFY_SUCCESSFUL]));
  1033.  
  1034.             else /* it's MCI_NOTIFY_ERROR */
  1035.                {
  1036.                   strcpy(acTempString,acMCINotMessage[ID_MCI_NOTIFY_ERROR] );
  1037.                   _itoa(LOUSHORT(mp1), acErrorBuf, 10);
  1038.                   strcat(acTempString, acErrorBuf);
  1039.                   WinSendMsg( hwndDisplayListBox,
  1040.                               LM_INSERTITEM,
  1041.                               MPFROMSHORT( LIT_END ),
  1042.                               MPFROMP( acTempString ));
  1043.                }
  1044.  
  1045.             /*
  1046.              * Next, display the device ID.
  1047.              */
  1048.  
  1049.             strcpy (acTempString, acMCINotMessage[ID_DEVICE_ID]);
  1050.             _itoa(LOUSHORT(mp2), acIDBuf, 10);
  1051.             strcat (acTempString, acIDBuf);
  1052.             WinSendMsg( hwndDisplayListBox,
  1053.                         LM_INSERTITEM,
  1054.                         MPFROMSHORT( LIT_END ),
  1055.                         MPFROMP( acTempString ));
  1056.  
  1057.             /*
  1058.              * Finally, display the user parameter.
  1059.              */
  1060.  
  1061.             strcpy (acTempString, acMCINotMessage[ID_USER_PARM]);
  1062.             _itoa(HIUSHORT(mp1), acUserParmBuf, 10);
  1063.             strcat (acTempString, acUserParmBuf);
  1064.             WinSendMsg( hwndDisplayListBox,
  1065.                         LM_INSERTITEM,
  1066.                         MPFROMSHORT( LIT_END ),
  1067.                         MPFROMP( acTempString ));
  1068.          }
  1069.          return( 0 );
  1070.  
  1071.       case MM_MCIPASSDEVICE :
  1072.  
  1073.          /*
  1074.           * Check to see if the user has filtered out this message.
  1075.           */
  1076.  
  1077.          if ( afCheckBoxState[ ID_MM_MCIPASSDEVICE] == TRUE )
  1078.          {
  1079.             /*
  1080.              * If the user has not filtered out this message, then display
  1081.              * the message in the list box of the Display Messages window.
  1082.              */
  1083.  
  1084.             WinSendMsg( hwndDisplayListBox,             /* Handle to the lb  */
  1085.                         LM_INSERTITEM,                  /* Action for the lb */
  1086.                         MPFROMSHORT( LIT_END ),         /* Order             */
  1087.                         MPFROMP( acMCINotMessage[ ID_MM_MCIPASSDEVICE ] ));
  1088.  
  1089.             /* Not only do we want to display the type of message received,
  1090.              * we also want to display the information recieved with the
  1091.              * message, because it can be very helpful in debugging media
  1092.              * drivers.
  1093.              *
  1094.              * First display the ID of the device.
  1095.              */
  1096.  
  1097.             strcpy (acTempString, acMCINotMessage[ID_DEVICE_ID]);
  1098.             _itoa(LOUSHORT(mp1), acIDBuf, 10);
  1099.             strcat (acTempString, acIDBuf);
  1100.             WinSendMsg( hwndDisplayListBox,
  1101.                         LM_INSERTITEM,
  1102.                         MPFROMSHORT( LIT_END ),
  1103.                         MPFROMP( acTempString ));
  1104.  
  1105.             /*
  1106.              * Next, determine if we're gaining use, or losing use.
  1107.              */
  1108.  
  1109.             if ((ULONG)mp2 == MCI_LOSING_USE)
  1110.                WinSendMsg( hwndDisplayListBox,
  1111.                            LM_INSERTITEM,
  1112.                            MPFROMSHORT( LIT_END ),
  1113.                            MPFROMP(acMCINotMessage[ID_LOSING_USE]));
  1114.             else
  1115.                WinSendMsg( hwndDisplayListBox,
  1116.                            LM_INSERTITEM,
  1117.                            MPFROMSHORT( LIT_END ),
  1118.                            MPFROMP(acMCINotMessage[ID_GAINING_USE]));
  1119.          }
  1120.  
  1121.          return( 0 );
  1122.  
  1123.       case MM_MCIPOSITIONCHANGE :
  1124.  
  1125.          /*
  1126.           * Check to see if the user has filtered out this message.
  1127.           */
  1128.  
  1129.          if ( afCheckBoxState[ ID_MM_MCIPOSITIONCHANGE ] == TRUE )
  1130.          {
  1131.             /*
  1132.              * If the user has not filtered out this message, then display
  1133.              * the message in the list box of the Display Messages window.
  1134.              */
  1135.  
  1136.             WinSendMsg( hwndDisplayListBox,            /* Handle to the lb  */
  1137.                         LM_INSERTITEM,                 /* Action for the lb */
  1138.                         MPFROMSHORT( LIT_END ),        /* Order             */
  1139.                         MPFROMP( acMCINotMessage[ID_MM_MCIPOSITIONCHANGE] ));
  1140.  
  1141.             /* Not only do we want to display the type of message received,
  1142.              * we also want to display the information recieved with the
  1143.              * message, because it can be very helpful in debugging media
  1144.              * drivers.
  1145.              *
  1146.              * First display the ID of the device.
  1147.              */
  1148.  
  1149.             strcpy (acTempString, acMCINotMessage[ID_DEVICE_ID]);
  1150.             _itoa(HIUSHORT(mp1), acIDBuf, 10);
  1151.             strcat (acTempString, acIDBuf);
  1152.             WinSendMsg( hwndDisplayListBox,
  1153.                         LM_INSERTITEM,
  1154.                         MPFROMSHORT( LIT_END ),
  1155.                         MPFROMP( acTempString ));
  1156.  
  1157.             /*
  1158.              * Next, display the media position (time).
  1159.              */
  1160.  
  1161.             strcpy (acTempString, acMCINotMessage[ID_TIME]);
  1162.             _itoa((DWORD)mp2, acTimeBuf, 10);
  1163.             strcat (acTempString, acTimeBuf);
  1164.             WinSendMsg( hwndDisplayListBox,
  1165.                         LM_INSERTITEM,
  1166.                         MPFROMSHORT( LIT_END ),
  1167.                         MPFROMP( acTempString ));
  1168.  
  1169.             /*
  1170.              * Finally, display the user parameter.
  1171.              */
  1172.  
  1173.             strcpy (acTempString, acMCINotMessage[ID_USER_PARM]);
  1174.             _itoa(LOUSHORT(mp1), acUserParmBuf, 10);
  1175.             strcat (acTempString, acUserParmBuf);
  1176.             WinSendMsg( hwndDisplayListBox,
  1177.                         LM_INSERTITEM,
  1178.                         MPFROMSHORT( LIT_END ),
  1179.                         MPFROMP( acTempString ));
  1180.          }
  1181.          return( 0 );
  1182.  
  1183.       case MM_MCICUEPOINT :
  1184.  
  1185.          /*
  1186.           * Check to see if the user has filtered out this message.
  1187.           */
  1188.  
  1189.          if ( afCheckBoxState[ ID_MM_MCICUEPOINT ] == TRUE )
  1190.          {
  1191.             /*
  1192.              * If the user has not filtered out this message, then display
  1193.              * the message in the list box of the Display Messages window.
  1194.              */
  1195.  
  1196.             WinSendMsg( hwndDisplayListBox,            /* Handle to the lb  */
  1197.                         LM_INSERTITEM,                 /* Action for the lb */
  1198.                         MPFROMSHORT( LIT_END ),        /* Order             */
  1199.                         MPFROMP( acMCINotMessage[ID_MM_MCICUEPOINT] ));
  1200.  
  1201.             /* Not only do we want to display the type of message received,
  1202.              * we also want to display the information recieved with the
  1203.              * message, because it can be very helpful in debugging media
  1204.              * drivers.
  1205.              *
  1206.              * First display the ID of the device.
  1207.              */
  1208.  
  1209.             strcpy (acTempString, acMCINotMessage[ID_DEVICE_ID]);
  1210.             _itoa(HIUSHORT(mp1), acIDBuf, 10);
  1211.             strcat (acTempString, acIDBuf);
  1212.             WinSendMsg( hwndDisplayListBox,
  1213.                         LM_INSERTITEM,
  1214.                         MPFROMSHORT( LIT_END ),
  1215.                         MPFROMP( acTempString ));
  1216.  
  1217.             /*
  1218.              * Next, display the media position (time).
  1219.              */
  1220.  
  1221.             strcpy (acTempString, acMCINotMessage[ID_TIME]);
  1222.             _itoa((DWORD)mp2, acTimeBuf, 10);
  1223.             strcat (acTempString, acTimeBuf);
  1224.             WinSendMsg( hwndDisplayListBox,
  1225.                         LM_INSERTITEM,
  1226.                         MPFROMSHORT( LIT_END ),
  1227.                         MPFROMP( acTempString ));
  1228.  
  1229.             /*
  1230.              * Finally, display the user parameter.
  1231.              */
  1232.  
  1233.             strcpy (acTempString, acMCINotMessage[ID_USER_PARM]);
  1234.             _itoa(LOUSHORT(mp1), acUserParmBuf, 10);
  1235.             strcat (acTempString, acUserParmBuf);
  1236.             WinSendMsg( hwndDisplayListBox,
  1237.                         LM_INSERTITEM,
  1238.                         MPFROMSHORT( LIT_END ),
  1239.                         MPFROMP( acTempString ));
  1240.          }
  1241.          return( 0 );
  1242.  
  1243.       case MM_MCIEVENT :
  1244.  
  1245.          /*
  1246.           * Check to see if the user has filtered out this message.
  1247.           */
  1248.  
  1249.          if ( afCheckBoxState[ ID_MM_MCIEVENT ] == TRUE )
  1250.          {
  1251.             /*
  1252.              * If the user has not filtered out this message, then display
  1253.              * the message in the list box of the Display Messages window.
  1254.              *
  1255.              */
  1256.  
  1257.             WinSendMsg( hwndDisplayListBox,            /* Handle to the lb  */
  1258.                         LM_INSERTITEM,                 /* Action for the lb */
  1259.                         MPFROMSHORT( LIT_END ),        /* Order             */
  1260.                         MPFROMP( acMCINotMessage[ID_MM_MCIEVENT] ));
  1261.          }
  1262.          return( 0 );
  1263.  
  1264.       case MM_MCIPLAYLISTMESSAGE :
  1265.          /*
  1266.           * Check to see if the user has filtered out this message.
  1267.           */
  1268.  
  1269.          if ( afCheckBoxState[ ID_MM_MCIPLAYLISTMESSAGE ] == TRUE )
  1270.          {
  1271.             /*
  1272.              * If the user has not filtered out this message, then
  1273.              * display the message in the list box of the Display
  1274.              * Messages window.
  1275.              */
  1276.  
  1277.             WinSendMsg( hwndDisplayListBox,            /* Handle to the lb  */
  1278.                         LM_INSERTITEM,                 /* Action for the lb */
  1279.                         MPFROMSHORT( LIT_END ),        /* Order             */
  1280.                         MPFROMP( acMCINotMessage[ID_MM_MCIPLAYLISTMESSAGE] ));
  1281.          }
  1282.          return( 0 );
  1283.  
  1284.       default:
  1285.           return( WinDefDlgProc( hwnd, msg, mp1, mp2 ) );
  1286.  
  1287.    }  /* End of Switch */
  1288.  
  1289.    return( (MRESULT) FALSE );
  1290.  
  1291. } /* End of DisplayDialogProc */
  1292.  
  1293.  
  1294. /******************************************************************************
  1295.  * Name        : DisplayListBoxProc
  1296.  *
  1297.  * Description : This function controls the Display Messages dialog box's
  1298.  *               list box. The list box window has been subclassed when the
  1299.  *               Display Dialog box was created.  This is required since the
  1300.  *               user is not allowed to select any text displayed in the list
  1301.  *               box via the keyboard or the mouse.  Therefore this window
  1302.  *               proceedure will trap all appropriate keyboard and mouse
  1303.  *               actions so that no selections can be made.  All other
  1304.  *               messages received by this function that do not invlove
  1305.  *               the relevent mouse or keyboard actions are passed back to
  1306.  *               the original List Box window procedure for processing.
  1307.  *
  1308.  *               The following messages are handled specifically by this
  1309.  *               routine.
  1310.  *               WM_BUTTON1DBLCLK
  1311.  *               WM_BUTTON1DOWN
  1312.  *               WM_CHAR
  1313.  *
  1314.  * Concepts    : None.
  1315.  *
  1316.  * MMPM/2 API's: None.
  1317.  *
  1318.  * Parameters  : hwnd - Handle for the Display dialog box.
  1319.  *               msg  - Message received by the dialog box.
  1320.  *               mp1  - Parameter 1 for the just recieved message.
  1321.  *               mp2  - Parameter 2 for the just recieved message.
  1322.  *
  1323.  * Return      : 0 or the result of default processing.
  1324.  *
  1325.  ******************************************************************************/
  1326. MRESULT EXPENTRY DisplayListBoxProc( HWND   hwnd,
  1327.                                      ULONG  msg,
  1328.                                      MPARAM mp1,
  1329.                                      MPARAM mp2 )
  1330. {
  1331.    static RECTL    rctListBox,                  /* Placement of the List Box. */
  1332.                    rctForbiddenMouseArea;       /* Area where mouse is forbid.*/
  1333.    static BOOL     fHasThisBeenDoneYet = FALSE; /* Indicates that first time  */
  1334.                                                 /* into this routine.         */
  1335.  
  1336.    SHORT sMouseXPosition,                       /* Mouse X position.          */
  1337.          sMouseYPosition;                       /* Mouse Y position.          */
  1338.  
  1339.    switch( msg )
  1340.    {
  1341.  
  1342.       /*
  1343.        * If the message indicates a mouse action that tries to select
  1344.        * text that is in the list box, reject the action.
  1345.        */
  1346.       case WM_BUTTON1DBLCLK :
  1347.       case WM_BUTTON1DOWN :
  1348.       {
  1349.          /*
  1350.           * The first time into this routine some initialization will be
  1351.           * performed.  Basically get the area in which the list box resides
  1352.           * so that any mouse actions in that region can be rejected.  Since
  1353.           * the control has already been created, the WM_INITDLG message
  1354.           * will not be received by this routine.  Therefore the first time
  1355.           * in this procedure we must do some initial processing.
  1356.           */
  1357.          if ( fHasThisBeenDoneYet == FALSE )
  1358.          {
  1359.             fHasThisBeenDoneYet = TRUE;
  1360.  
  1361.             WinQueryWindowRect(
  1362.                hwnd,                               /* Handle to the window.   */
  1363.                (PRECTL) &rctListBox );             /* Size of the window.     */
  1364.  
  1365.             /*
  1366.              * Calculate the area in which mouse/cursor selections are not
  1367.              * going to be allowed.
  1368.              */
  1369.             rctForbiddenMouseArea.xLeft   =
  1370.                rctListBox.xLeft + DISPLAY_CONTROL_X_POSITION;
  1371.  
  1372.             rctForbiddenMouseArea.yBottom =
  1373.                rctListBox.yBottom + DISPLAY_CONTROL_Y_POSITION;
  1374.  
  1375.             rctForbiddenMouseArea.xRight  =
  1376.                rctListBox.xRight + DISPLAY_CONTROL_X_POSITION;
  1377.  
  1378.             rctForbiddenMouseArea.yTop    =
  1379.                rctListBox.yTop + DISPLAY_CONTROL_Y_POSITION;
  1380.  
  1381.          }  /* End of the initial setup for this window procedure. */
  1382.  
  1383.          /*
  1384.           * Set the focus on the Display Messages dialog.
  1385.           */
  1386.          WinSetFocus(
  1387.             HWND_DESKTOP,
  1388.             hwndDisplayDialogBox );
  1389.  
  1390.          /*
  1391.           * Get the position of the mouse in the window.
  1392.           */
  1393.          sMouseXPosition = SHORT1FROMMP( mp1 );
  1394.          sMouseYPosition = SHORT2FROMMP( mp1 );
  1395.  
  1396.          /*
  1397.           * See if the mouse is in the forbbiden.  If it is, ignore the
  1398.           * mouse action.
  1399.           */
  1400.          if ( sMouseXPosition < (SHORT) rctForbiddenMouseArea.xRight  ||
  1401.               sMouseXPosition > (SHORT) rctForbiddenMouseArea.xLeft   ||
  1402.               sMouseYPosition < (SHORT) rctForbiddenMouseArea.yTop    ||
  1403.               sMouseYPosition > (SHORT) rctForbiddenMouseArea.yBottom  )
  1404.          {
  1405.             return( 0 );
  1406.          }
  1407.  
  1408.          return( (pfnwpDisplayListBoxProc( hwnd, msg, mp1, mp2 )) );
  1409.  
  1410.       }  /* End of Mouse Button catches. */
  1411.  
  1412.       /*
  1413.        * A keyboard key has been pressed by the user.  We need to check
  1414.        * to see if the key(s) are up/down cursor keys, space bar,  AND if
  1415.        * the focus of the window is the List Box within the Display Dialog.
  1416.        */
  1417.       case WM_CHAR :
  1418.       {
  1419.          /*
  1420.           * Find out which key was pressed.  We only care about cursor keys
  1421.           * AND the Space Bar.  The space bar is to be ignored since if it
  1422.           * was passed into the default window procedure it would be used
  1423.           * and a List Box item would be selected.
  1424.           */
  1425.          switch( SHORT2FROMMP( mp2 ) )
  1426.          {
  1427.             case VK_SPACE :
  1428.             {
  1429.                return( 0 );
  1430.             }
  1431.  
  1432.             case VK_UP :
  1433.             {
  1434.                SendScrollBarMessage(
  1435.                   hwnd,
  1436.                   SB_LINEUP );
  1437.  
  1438.                   return( 0 );
  1439.             }  /* End of VK_UP */
  1440.  
  1441.             case VK_DOWN :
  1442.             {
  1443.                SendScrollBarMessage(
  1444.                   hwnd,
  1445.                   SB_LINEDOWN );
  1446.  
  1447.                   return( 0 );
  1448.             }  /* End of VK_DOWN. */
  1449.  
  1450.             case VK_PAGEUP   :
  1451.             {
  1452.                SendScrollBarMessage(
  1453.                   hwnd,
  1454.                   SB_PAGEUP );
  1455.  
  1456.                return( 0 );
  1457.  
  1458.             }  /* End of VK_PAGEUP. */
  1459.  
  1460.             case VK_PAGEDOWN :
  1461.             {
  1462.                SendScrollBarMessage(
  1463.                   hwnd,
  1464.                   SB_PAGEDOWN );
  1465.  
  1466.                   return( 0 );
  1467.  
  1468.             }  /* End of VK_PAGEDOWN. */
  1469.  
  1470.          }  /* End of CHAR switch. */
  1471.  
  1472.       }  /* End of WM_CHAR processing. */
  1473.  
  1474.       default:
  1475.           return( (pfnwpDisplayListBoxProc( hwnd, msg, mp1, mp2 )) );
  1476.  
  1477.    }  /* End of Switch */
  1478.  
  1479.    return( (pfnwpDisplayListBoxProc( hwnd, msg, mp1, mp2 )) );
  1480.  
  1481. }  /* End of DisplayListBoxProc. */
  1482.  
  1483.  
  1484. /*******************************************************************************
  1485.  * Name        : IncludeDialogProc
  1486.  *
  1487.  * Description : This function controls the Include dialog box.  It will
  1488.  *               allow, filter, MCI Notification messages to received by
  1489.  *               the Display Messages dialog.  The dialog window is
  1490.  *               application modal.
  1491.  *
  1492.  *               The following messages are handled specifically by this
  1493.  *               routine.
  1494.  *
  1495.  *                  WM_INITDLG
  1496.  *                  WM_CLOSE
  1497.  *                  WM_HELP
  1498.  *                  WM_COMMAND
  1499.  *
  1500.  * Concepts    : None.
  1501.  *
  1502.  * MMPM/2 API's: None.
  1503.  *
  1504.  * Parameters  : hwnd - Handle for the Include dialog box.
  1505.  *               msg  - Message received by the dialog box.
  1506.  *               mp1  - Parameter 1 for the just recieved message.
  1507.  *               mp2  - Parameter 2 for the just recieved message.
  1508.  *
  1509.  * Return      : 0 or the result of default processing.
  1510.  *
  1511.  ******************************************************************************/
  1512. MRESULT EXPENTRY IncludeDialogProc( HWND   hwnd,
  1513.                                     ULONG  msg,
  1514.                                     MPARAM mp1,
  1515.                                     MPARAM mp2 )
  1516. {
  1517.    /*
  1518.     * Holds the status of the checkboxes.
  1519.     */
  1520.    static HWND hwndCheckBoxes[ INCLUDE_NUMBER_OF_CHECKBOXES ];
  1521.  
  1522.    USHORT usI,                            /* Generic Counter.                 */
  1523.           usRC;                           /* Generic Return Code variable.    */
  1524.  
  1525.    BOOL   fOneCheckBoxWasChecked = FALSE; /* Indicates if a checkbox is used. */
  1526.    BOOL   afTempCheckBoxState[
  1527.              INCLUDE_NUMBER_OF_CHECKBOXES ]; /* Temp buffer for CB state.     */
  1528.  
  1529.    switch( msg )
  1530.    {
  1531.  
  1532.       case WM_INITDLG :
  1533.  
  1534.          /*
  1535.           * Set the Child Dialog window's System Menu.
  1536.           */
  1537.          SetSystemMenu( hwnd );
  1538.  
  1539.          /*
  1540.           * Get the window handles for the Check Boxes.  The handles
  1541.           * will be used to set the initial values in the Check Boxes
  1542.           * when the dialog is first started.
  1543.           */
  1544.          for( usI=0; usI<INCLUDE_NUMBER_OF_CHECKBOXES; usI++ )
  1545.          {
  1546.             hwndCheckBoxes[ usI ] =
  1547.                WinWindowFromID(
  1548.                   hwnd,
  1549.                   ausCheckBoxIDs[ usI ] );
  1550.          }
  1551.  
  1552.          /*
  1553.           * Set the state of the check boxes.
  1554.           */
  1555.          for( usI=0; usI<INCLUDE_NUMBER_OF_CHECKBOXES; usI++ )
  1556.          {
  1557.              WinSendMsg(
  1558.                hwndCheckBoxes[ usI ],
  1559.                BM_SETCHECK,
  1560.                MPFROM2SHORT( afCheckBoxState[ usI ], 0 ),
  1561.                0L );
  1562.          }  /* End of FOR that sets the Check Boxes. */
  1563.  
  1564.          return( 0 );
  1565.  
  1566.       case WM_CLOSE :
  1567.          /*
  1568.           * The Include dialog is closing.
  1569.           */
  1570.          WinDismissDlg(
  1571.             hwnd,                     /* Dialog box to close.                 */
  1572.             TRUE );                   /* Get rid of the dialog box.           */
  1573.  
  1574.          return( 0 );
  1575.  
  1576.       case WM_HELP :
  1577.          /*
  1578.           * The dialog window has recieved a request for help from the user,
  1579.           * i.e., the Help pushbutton was pressed.  Send the HM_DISPLAY_HELP
  1580.           * message to the Help Instance with the IPF resource identifier
  1581.           * for the correct HM panel.  This will show the help panel for this
  1582.           * sample program.
  1583.           */
  1584.          WinSendMsg(
  1585.             hwndIncludeHelpInstance,
  1586.             HM_DISPLAY_HELP,
  1587.             MPFROMSHORT( 1 ),
  1588.             MPFROMSHORT( HM_RESOURCEID ) );
  1589.          return( 0 );
  1590.  
  1591.       case WM_COMMAND :
  1592.          /*
  1593.           * To get which pushbutton was pressed, the SHORT1FROMMP macro
  1594.           * is used.
  1595.           */
  1596.          switch( SHORT1FROMMP( mp1 ) )
  1597.          {
  1598.             /*
  1599.              * The include pushbutton has been pressed therefore get the
  1600.              * state of the checkboxes so that the Display Messages dialog
  1601.              * can determine if MCI Notification messages are to be displayed.
  1602.              */
  1603.             case ID_INCLUDE_PB :
  1604.                /*
  1605.                 * Query the checkboxes to get their current state...
  1606.                 * - Set the flag that at least one checkbox has been used.
  1607.                 * - Read the state of all of the checkboxes storing the result.
  1608.                 * - If one of the checkboxes has been checked set the flag.
  1609.                 *   This is done so that a message box can be shown indicating
  1610.                 *   that NO checkboxes have been used.
  1611.                 */
  1612.                fOneCheckBoxWasChecked = FALSE;
  1613.  
  1614.                for( usI=0; usI<INCLUDE_NUMBER_OF_CHECKBOXES; usI++ )
  1615.                {
  1616.                   afTempCheckBoxState[ usI ] = (BOOL)
  1617.                      WinSendMsg(
  1618.                         hwndCheckBoxes[ usI ],
  1619.                         BM_QUERYCHECK,
  1620.                         0L,
  1621.                         0L );
  1622.  
  1623.                   if ( afTempCheckBoxState[ usI ] == TRUE )
  1624.                   {
  1625.                      fOneCheckBoxWasChecked = TRUE;
  1626.                   }
  1627.                }  /* End of FOR loop that gets the state of the Check Boxes. */
  1628.  
  1629.                /*
  1630.                 * Set the return code so that the dialog will be dismissed
  1631.                 * if everything is ok.
  1632.                 */
  1633.                usRC = MBID_OK;
  1634.  
  1635.                /*
  1636.                 * See if any of the checkboxes are checked.  If not then tell
  1637.                 * the user that no MCI Notification messages will be seen.
  1638.                 */
  1639.                if ( fOneCheckBoxWasChecked == FALSE )
  1640.                {
  1641.  
  1642.                   usRC =
  1643.                      ShowAMessage(
  1644.                          hwnd,                           /* Owner Window.     */
  1645.                          acStringBuffer[ IDS_NORMAL_ERROR_MESSAGE_BOX_TEXT - 1 ],
  1646.                          IDS_ALL_CHECKBOXES_ARE_FALSE,   /* ID of the message.*/
  1647.                          MB_OKCANCEL  | MB_HELP | MB_MOVEABLE |
  1648.                          MB_APPLMODAL | MB_WARNING );    /* Message box style.*/
  1649.                }
  1650.  
  1651.                /*
  1652.                 * If the user says OK, then go ahead and end the dialog after
  1653.                 * getting the state of the checkboxes from the temp buffer.
  1654.                 * Otherwise do not end the dialog so that the user can change
  1655.                 * the checkboxes.
  1656.                 */
  1657.                if ( usRC == MBID_OK )
  1658.                {
  1659.  
  1660.                   for( usI=0; usI<INCLUDE_NUMBER_OF_CHECKBOXES; usI++ )
  1661.                   {
  1662.                      afCheckBoxState[ usI ] = afTempCheckBoxState[ usI ];
  1663.                   }
  1664.  
  1665.                   WinDismissDlg(
  1666.                      hwnd,                  /* Dialog box to close.           */
  1667.                      TRUE );                /* Get rid of the dialog box.     */
  1668.                }
  1669.  
  1670.                return( 0 );
  1671.  
  1672.             /*
  1673.              * The cancel pushbutton has been pressed the dialog will be
  1674.              * dismissed. (Or the ESC key was pressed)
  1675.              */
  1676.             case DID_CANCEL:
  1677.             case ID_INCLUDE_CANCEL_PB :
  1678.  
  1679.                WinDismissDlg(
  1680.                   hwnd,                     /* Dialog box to close.           */
  1681.                   TRUE );                   /* Get rid of the dialog box.     */
  1682.  
  1683.                return( 0 );
  1684.  
  1685.          }  /* End of Command Switch */
  1686.  
  1687.          return( 0 );
  1688.  
  1689.       default:
  1690.          return( WinDefDlgProc( hwnd, msg, mp1, mp2 ) );
  1691.  
  1692.    }  /* End of Switch */
  1693.  
  1694.    return( (MRESULT) FALSE );
  1695.  
  1696. } /* End of IncludeDialogProc */
  1697.  
  1698.  
  1699. /******************************************************************************
  1700.  * Name        : SendStringToMCD
  1701.  *
  1702.  * Description : This procedure will take the string from the Combo Box,
  1703.  *               check for it's validity and send it to the MCD for processing.
  1704.  *
  1705.  * Concepts    : None.
  1706.  *
  1707.  * MMPM/2 API's: mciSendString
  1708.  *               mciGetErrorString
  1709.  *
  1710.  * Parameters  : hwndComboBox - Handle to the Combo Box.
  1711.  *
  1712.  * Return      : None.
  1713.  *
  1714.  ******************************************************************************/
  1715. VOID SendStringToMCD( HWND hwndComboBox )
  1716. {
  1717.    static USHORT usCountOfMCIStringSent = 1;            /* Number of sent cmds*/
  1718.    CHAR   acTempString[ STRING_SIZE ];                  /* Temp string buffer.*/
  1719.  
  1720.    CHAR acMCIString[ MCI_STRING_LENGTH ],               /* MCI String Command.*/
  1721.         acErrorStringBuffer[ MCI_ERROR_STRING_LENGTH ]; /* Error string buffer*/
  1722.    LONG lSendStringRC     = 0,                          /* Send String API RC.*/
  1723.         lGetErrorStringRC = 0;                          /* Error String API RC*/
  1724.  
  1725.    /*
  1726.     * Get the MCI String Command that is supposed to be in the Entry field
  1727.     * of the combination box.
  1728.     */
  1729.    GetStringFromComboBox(
  1730.       hwndComboBox,
  1731.       &acMCIString[ 0 ] );
  1732.  
  1733.    if ( IsMCIStringValid( &acMCIString[ 0 ] ) == FALSE )
  1734.    {
  1735.       /*
  1736.        * The given MCI String is not valid.  Get out of this routine.
  1737.        */
  1738.       return;
  1739.    }
  1740.  
  1741.    /*
  1742.     * Place the string in the list box portion of the combination box.
  1743.     */
  1744.    WinSendMsg(
  1745.       hwndComboBox,                       /* Handle to the Combination Box.   */
  1746.       LM_INSERTITEM,                      /* Action for the Combo box to do.  */
  1747.       MPFROM2SHORT( LIT_END, 0 ),         /* MP 1.  Place text at end of list.*/
  1748.       (MPARAM) (PSZ) &acMCIString[ 0 ] ); /* MP 2.  MCI String Command.       */
  1749.  
  1750.    /*
  1751.     * Erase the string that is in the Entry Field of the combination box by
  1752.     * first selecting all of the text in the filed and then clearing it.
  1753.     * Then force the cursor to go back to the entry field to accept the
  1754.     * next string command.
  1755.     */
  1756.    WinSendMsg(
  1757.       hwndComboBox,                       /* Handle to the Combination Box.   */
  1758.       EM_SETSEL,                          /* Action for the Combo box to do.  */
  1759.       MPFROM2SHORT( 0,MCI_STRING_LENGTH ),/* MP 1.  Reserved.                 */
  1760.       (MPARAM) NULL );                    /* MP 2.  Reserved.                 */
  1761.  
  1762.    WinSendMsg(
  1763.       hwndComboBox,                       /* Handle to the Combination Box.   */
  1764.       EM_CLEAR,                           /* Action for the Combo box to do.  */
  1765.       (MPARAM) NULL,                      /* MP 1.  Reserved.                 */
  1766.       (MPARAM) NULL );                    /* MP 2.  Reserved.                 */
  1767.  
  1768.  
  1769.    /*
  1770.     * We have a 'valid' MCI string from the sample programs point of view,
  1771.     * whether it really is valid will be decided by MCD.  Send the MCI String
  1772.     * Command and increment the counter so that we know how many MCI strings
  1773.     * have been sent.
  1774.     *
  1775.     * Set the pointer to an hourglass first, since this might take a couple
  1776.     * of seconds.
  1777.     */
  1778.  
  1779.    WinSetPointer(
  1780.       HWND_DESKTOP,              /* Desktop window handle.                    */
  1781.       WinQuerySysPointer(        /* This API will give the handle of the PTR. */
  1782.          HWND_DESKTOP,           /* Desktop window handle.                    */
  1783.          SPTR_WAIT,              /* The Hourglass icon.                       */
  1784.          FALSE ) );              /* Return the system pointer's handle.       */
  1785.  
  1786.    lSendStringRC =
  1787.       mciSendString(
  1788.          (LPSTR) &acMCIString[ 0 ],       /* The MCI String Command.          */
  1789.          (LPSTR)&acMCIReturnString[ 0 ],  /* The place to put Return strings. */
  1790.          (WORD) MCI_RETURN_STRING_LENTGH, /* How large is the Return space.   */
  1791.          hwndDisplayDialogBox,            /* Which window recieves Notifies.  */
  1792.          usCountOfMCIStringSent );        /* The user parameter.              */
  1793.  
  1794.    WinSetPointer(
  1795.       HWND_DESKTOP,              /* Desktop window handle.                    */
  1796.       WinQuerySysPointer(        /* This API will give the handle of the PTR. */
  1797.          HWND_DESKTOP,           /* Desktop window handle.                    */
  1798.          SPTR_ARROW,             /* The Arrow icon.                           */
  1799.          FALSE ) );              /* Return the system pointer's handle.       */
  1800.  
  1801.    usCountOfMCIStringSent++;
  1802.  
  1803.    /*
  1804.     * Display the return string from mciSendString api.
  1805.     */
  1806.  
  1807.    strcpy (acTempString, acStringBuffer[IDS_RETURN_STRING - 1]);
  1808.    strcat (acTempString, acMCIReturnString);
  1809.    WinSendMsg( hwndDisplayListBox,
  1810.                LM_INSERTITEM,
  1811.                MPFROMSHORT( LIT_END ),
  1812.                MPFROMP( acTempString ));
  1813.  
  1814.    acMCIReturnString[ 0 ] =  (CHAR) NULL;  /* Initialize the return string   */
  1815.  
  1816.    /*
  1817.     * Keep count up to some number which is less than the maximum for the
  1818.     * number of items in a list box.
  1819.     */
  1820.    if ( usCountOfMCIStringSent == (USHORT) 65500 )
  1821.    {
  1822.       usCountOfMCIStringSent = 1;
  1823.    }
  1824.  
  1825.    /*
  1826.     * IF the string return code is not 0 then there was an error.  Indicate
  1827.     * this to the user, find out what the problem was, and show that to the
  1828.     * user.
  1829.     */
  1830.    if ( lSendStringRC != 0 )
  1831.    {
  1832.  
  1833.       usCountOfMCIStringSent--;
  1834.  
  1835.       lGetErrorStringRC =
  1836.          mciGetErrorString(
  1837.             lSendStringRC,
  1838.             (LPSTR) &acErrorStringBuffer[ 0 ],
  1839.             (WORD) MCI_ERROR_STRING_LENGTH );
  1840.  
  1841.       /*
  1842.        * Make sure that the retrieving of the error string was successfull.
  1843.        */
  1844.       if ( lGetErrorStringRC != MCIERR_SUCCESS )
  1845.       {
  1846.          ShowAMessage(
  1847.             hwndMainDialogBox,                   /* Owner Window.             */
  1848.             acStringBuffer[ IDS_NORMAL_ERROR_MESSAGE_BOX_TEXT - 1 ],
  1849.             IDS_MCI_GETTING_STRING_ERROR_FAILED,  /* ID of the message.       */
  1850.             MB_APPLMODAL | MB_MOVEABLE | MB_HELP |
  1851.                MB_OK | MB_INFORMATION );          /* Message box style.       */
  1852.  
  1853.          return;
  1854.  
  1855.       }  /* End of IF testing for failed Get Error String API. */
  1856.  
  1857.       /*
  1858.        * Show the error string that was retrieved by the mciGetErrorString
  1859.        * MMPM/2 API.
  1860.        */
  1861.       WinMessageBox(
  1862.          HWND_DESKTOP,                  /* Parent handle of the message box.  */
  1863.          hwndMainDialogBox,             /* Owner handle of the message box.   */
  1864.          (PSZ) &acErrorStringBuffer,    /* String to show in the message box. */
  1865.          acStringBuffer[ IDS_NORMAL_ERROR_MESSAGE_BOX_TEXT - 1 ], /* Title.   */
  1866.          (USHORT) ID_MESSAGE_BOX,       /* Message Box Id.                    */
  1867.          MB_CANCEL | MB_MOVEABLE | MB_APPLMODAL | MB_HELP |
  1868.             MB_INFORMATION );           /* The style of the message box.      */
  1869.  
  1870.    }  /* End of IF testing for failed MCI Send String API. */
  1871.  
  1872.    WinSetFocus( HWND_DESKTOP, hwndComboBox);
  1873.  
  1874. }  /* End of SendStringToMCD */
  1875.  
  1876.  
  1877. /******************************************************************************
  1878.  * Name        : InitializeHelp
  1879.  *
  1880.  * Description : This procedure will set up the initial values in the global
  1881.  *               help structure.  This help structure will then be passed on
  1882.  *               to the Help Manager when the Help Instance is created.  The
  1883.  *               handle to the Help Instance will be kept for later use.
  1884.  *
  1885.  * Concepts    : None.
  1886.  *
  1887.  * MMPM/2 API's: None.
  1888.  *
  1889.  * Parameters  : phmiHelpStructure - Help structure for a particular dialog.
  1890.  *               wdtDialog         - Which Dialog box to setup.
  1891.  *
  1892.  * Return      : None.
  1893.  *
  1894.  ******************************************************************************/
  1895. VOID InitializeHelp( HELPINIT       *phmiHelpStructure,
  1896.                      WHICH_DIALOG_T wdtDialog )
  1897. {
  1898.  
  1899.    /*
  1900.     * Get the size of the initialization structure.
  1901.     */
  1902.    phmiHelpStructure->cb              = sizeof( HELPINIT );
  1903.  
  1904.    phmiHelpStructure->ulReturnCode    = (USHORT) NULL; /* RC from HM initial. */
  1905.    phmiHelpStructure->pszTutorialName = (PSZ) NULL;    /* No tutorial program.*/
  1906.  
  1907.    /*
  1908.     * The action bar is not used, so set the following to NULL.
  1909.     */
  1910.    phmiHelpStructure->hmodAccelActionBarModule = (HMODULE) NULL;
  1911.    phmiHelpStructure->idAccelTable             = (USHORT) NULL;
  1912.    phmiHelpStructure->idActionBar              = (USHORT) NULL;
  1913.  
  1914.    /*
  1915.     * The Help table is in the executable file.
  1916.     */
  1917.    phmiHelpStructure->hmodHelpTableModule = (HMODULE) NULL;
  1918.  
  1919.    /*
  1920.     * The help panel ID is not displayed.
  1921.     */
  1922.    phmiHelpStructure->fShowPanelId       = (ULONG) NULL;
  1923.  
  1924.    /*
  1925.     * Setup the help based on the wdtDialog value passed into this function.
  1926.     */
  1927.    switch( wdtDialog )
  1928.    {
  1929.       case MAIN_DIALOG :
  1930.       {
  1931.          /*
  1932.           * The library that contains the help panels.
  1933.           */
  1934.          phmiHelpStructure->pszHelpLibraryName  =
  1935.             acStringBuffer[ IDS_MAIN_HELP_LIBRARY_FILE - 1 ];
  1936.          /*
  1937.           * The Help window title.
  1938.           */
  1939.          phmiHelpStructure->pszHelpWindowTitle  =
  1940.             acStringBuffer[ IDS_MAIN_HELP_WINDOW_TITLE - 1 ];
  1941.  
  1942.          phmiHelpStructure->phtHelpTable    = (PVOID)(0xffff0000 |
  1943.             ID_MCI_STRING_MAIN_DIALOG_HELPTABLE);
  1944.  
  1945.          /*
  1946.           * Create the Help Instance for IPF.  Give IPF the Anchor Block
  1947.           * handle and address of the IPF initialization structure, and
  1948.           * check that creation of Help was a success.
  1949.           */
  1950.          hwndMainHelpInstance =
  1951.             WinCreateHelpInstance(
  1952.                hab,                  /* Anchor Block Handle.                  */
  1953.                phmiHelpStructure );  /* Help Structure.                       */
  1954.  
  1955.          if ( hwndMainHelpInstance == (HWND) NULL )
  1956.          {
  1957.             ShowAMessage(
  1958.                hwndMainDialogBox,                       /* Owner Window       */
  1959.                acStringBuffer[ IDS_NORMAL_ERROR_MESSAGE_BOX_TEXT - 1 ],
  1960.                IDS_MAIN_HELP_CREATION_FAILED,           /* ID of the message. */
  1961.                MB_APPLMODAL | MB_MOVEABLE |
  1962.                   MB_OK | MB_INFORMATION );             /* Message box style. */
  1963.          }
  1964.          else
  1965.          {
  1966.             if ( phmiHelpStructure->ulReturnCode )
  1967.             {
  1968.                ShowAMessage(
  1969.                   hwndMainDialogBox,                 /* Owner Window          */
  1970.                   acStringBuffer[ IDS_NORMAL_ERROR_MESSAGE_BOX_TEXT - 1 ],
  1971.                   IDS_MAIN_HELP_CREATION_FAILED,     /* ID of the message.    */
  1972.                   MB_APPLMODAL | MB_OK | MB_MOVEABLE |
  1973.                      MB_INFORMATION );               /* Message box style.    */
  1974.  
  1975.                WinDestroyHelpInstance( hwndMainHelpInstance );
  1976.             }
  1977.          }  /* End of IF checking the creation of the Help Instance. */
  1978.  
  1979.          /*
  1980.           * Associate the Help Instance of the IPF to this dialog window.
  1981.           */
  1982.          if ( hwndMainHelpInstance != (HWND) NULL )
  1983.          {
  1984.            WinAssociateHelpInstance(
  1985.               hwndMainHelpInstance, /* The handle of the Help Instance.       */
  1986.               hwndFrame );          /* Associate to this dialog window.       */
  1987.          }
  1988.  
  1989.          break;
  1990.  
  1991.       }  /* End of case MAIN_DIALOG. */
  1992.  
  1993.       case INCLUDE_DIALOG :
  1994.       {
  1995.          /*
  1996.           * The library that contains the help panels.
  1997.           */
  1998.          phmiHelpStructure->pszHelpLibraryName  =
  1999.             acStringBuffer[ IDS_INCLUDE_HELP_LIBRARY_FILE - 1 ];
  2000.  
  2001.          /*
  2002.           * The Help window title.
  2003.           */
  2004.          phmiHelpStructure->pszHelpWindowTitle  =
  2005.             acStringBuffer[ IDS_INCLUDE_HELP_WINDOW_TITLE - 1 ];
  2006.  
  2007.          phmiHelpStructure->phtHelpTable    = (PVOID)(0xffff0000 |
  2008.             ID_MCI_STRING_INCLUDE_DIALOG_HELPTABLE);
  2009.  
  2010.          /*
  2011.           * Create the Help Instance for IPF. Give IPF the Anchor Block
  2012.           * handle and address of the IPF initialization structure, and
  2013.           * check that creation of Help was a success.
  2014.           */
  2015.          hwndIncludeHelpInstance =
  2016.             WinCreateHelpInstance(
  2017.                hab,                  /* Anchor Block Handle.                  */
  2018.                phmiHelpStructure );  /* Help Structure.                       */
  2019.  
  2020.          if ( hwndIncludeHelpInstance == (HWND) NULL )
  2021.          {
  2022.             ShowAMessage(
  2023.                hwndMainDialogBox,                    /* Owner Window          */
  2024.                acStringBuffer[ IDS_NORMAL_ERROR_MESSAGE_BOX_TEXT - 1 ],
  2025.                IDS_INCLUDE_HELP_CREATION_FAILED,     /* ID of the message.    */
  2026.                MB_APPLMODAL | MB_MOVEABLE |
  2027.                   MB_OK | MB_INFORMATION );          /* Message box style.    */
  2028.          }
  2029.          else
  2030.          {
  2031.             if ( phmiHelpStructure->ulReturnCode )
  2032.             {
  2033.                ShowAMessage(
  2034.                   hwndMainDialogBox,                 /* Owner Window          */
  2035.                   acStringBuffer[ IDS_NORMAL_ERROR_MESSAGE_BOX_TEXT - 1 ],
  2036.                   IDS_INCLUDE_HELP_CREATION_FAILED,  /* ID of the message.    */
  2037.                   MB_APPLMODAL | MB_MOVEABLE |
  2038.                      MB_OK | MB_INFORMATION );       /* Message box style.    */
  2039.  
  2040.                WinDestroyHelpInstance( hwndIncludeHelpInstance );
  2041.             }
  2042.          }  /* End of IF checking the creation of the Help Instance. */
  2043.  
  2044.          /*
  2045.           * Associate the Help Instance of the IPF to this dialog window.
  2046.           */
  2047.          if ( hwndIncludeHelpInstance != (HWND) NULL )
  2048.          {
  2049.            WinAssociateHelpInstance(
  2050.               hwndIncludeHelpInstance, /* The handle of the Help Instance.    */
  2051.               hwndIncludeDialogBox );  /* Associate to this dialog window.    */
  2052.          }
  2053.  
  2054.          break;
  2055.  
  2056.       }  /* End of case INCLUDE_DIALOG. */
  2057.  
  2058.       case DISPLAY_DIALOG :
  2059.       {
  2060.          /*
  2061.           * The library that contains the help panels.
  2062.           */
  2063.          phmiHelpStructure->pszHelpLibraryName  =
  2064.             acStringBuffer[ IDS_DISPLAY_HELP_LIBRARY_FILE - 1 ];
  2065.  
  2066.          /*
  2067.           * The Help window title.
  2068.           */
  2069.          phmiHelpStructure->pszHelpWindowTitle  =
  2070.             acStringBuffer[ IDS_DISPLAY_HELP_WINDOW_TITLE - 1 ];
  2071.  
  2072.          phmiHelpStructure->phtHelpTable    = (PVOID)(0xffff0000 |
  2073.             ID_MCI_STRING_DISPLAY_DIALOG_HELPTABLE);
  2074.  
  2075.          /*
  2076.           * Create the Help Instance for IPF. Give IPF the Anchor Block
  2077.           * handle and address of the IPF initialization structure, and
  2078.           * check that creation of Help was a success.
  2079.           */
  2080.          hwndDisplayHelpInstance =
  2081.             WinCreateHelpInstance(
  2082.                hab,                  /* Anchor Block Handle.                  */
  2083.                phmiHelpStructure );  /* Help Structure.                       */
  2084.  
  2085.          if ( hwndDisplayHelpInstance == (HWND) NULL )
  2086.          {
  2087.             ShowAMessage(
  2088.                hwndMainDialogBox,                    /* Owner Window          */
  2089.                acStringBuffer[ IDS_NORMAL_ERROR_MESSAGE_BOX_TEXT - 1 ],
  2090.                IDS_DISPLAY_HELP_CREATION_FAILED,     /* ID of the message.    */
  2091.                MB_APPLMODAL |  MB_MOVEABLE |
  2092.                   MB_OK | MB_INFORMATION );          /* Message box style.    */
  2093.          }
  2094.          else
  2095.          {
  2096.             if ( phmiHelpStructure->ulReturnCode )
  2097.             {
  2098.                ShowAMessage(
  2099.                   hwndMainDialogBox,              /* Owner Window          */
  2100.                   acStringBuffer[ IDS_NORMAL_ERROR_MESSAGE_BOX_TEXT - 1 ],
  2101.                   IDS_DISPLAY_HELP_CREATION_FAILED,  /* ID of the message.    */
  2102.                   MB_APPLMODAL | MB_MOVEABLE |
  2103.                      MB_OK | MB_INFORMATION );       /* Message box style.    */
  2104.  
  2105.                WinDestroyHelpInstance( hwndDisplayHelpInstance );
  2106.             }
  2107.          }  /* End of IF checking the creation of the Help Instance. */
  2108.  
  2109.          /*
  2110.           * Associate the Help Instance of the IPF to this dialog window.
  2111.           */
  2112.          if ( hwndDisplayHelpInstance != (HWND) NULL )
  2113.          {
  2114.            WinAssociateHelpInstance(
  2115.               hwndDisplayHelpInstance, /* The handle of the Help Instance.    */
  2116.               hwndDisplayDialogBox );  /* Associate to this dialog window.    */
  2117.          }
  2118.  
  2119.          break;
  2120.  
  2121.       }  /* End of case DISPLAY_DIALOG. */
  2122.  
  2123.    }  /* End of switch on Dialog Box. */
  2124. }  /* End of InitializeHelp */
  2125.  
  2126.  
  2127. /******************************************************************************
  2128.  * Name        : ShowAMessage
  2129.  *
  2130.  * Description : This function will show text in a message box.  The text
  2131.  *               is pulled from the string table that is originally kept
  2132.  *               in the resource file.  The text is retrieved by the
  2133.  *               message id that is passed into this function.  This id
  2134.  *               is used in the WinLoadString OS/2 API to get the correct
  2135.  *               string from the table.
  2136.  *
  2137.  * Concepts    : None.
  2138.  *
  2139.  * MMPM/2 API's: None.
  2140.  *
  2141.  * Parameters  : hwndOwnerWindow   - Handle to the window which called for
  2142.  *                                   a message box.
  2143.  *               pcMessageTitle    - The tile to be placed in the message
  2144.  *                                   box.
  2145.  *               usMessageId       - The message id that identifies which
  2146.  *                                   string to retreived from the string
  2147.  *                                   table.
  2148.  *               ulMessageBoxStyle - The style of the message box.  Which
  2149.  *                                   icons, buttons, etc., to show.
  2150.  *
  2151.  * Return      : The result from the message box.
  2152.  *
  2153.  ******************************************************************************/
  2154. USHORT ShowAMessage( HWND   hwndOwnerWindow,
  2155.                      CHAR   *pcMessageTitle,
  2156.                      USHORT usMessageId,
  2157.                      ULONG  ulMessageBoxStyle )
  2158. {
  2159.  
  2160.    CHAR   acStringBuffer[ STRING_SIZE ];        /* Buffer for RC string.      */
  2161.    USHORT usMessageBoxResult;                   /* Result from Message Box.   */
  2162.  
  2163.    /*
  2164.     * Get the string from the Resource defined string table and show it
  2165.     * in the message box.
  2166.     */
  2167.    WinLoadString(
  2168.       hab,                             /* HAB for this dialog box.            */
  2169.       (HMODULE) NULL,                  /* Get the string from the .exe file.  */
  2170.       usMessageId,                     /* Which string to get.                */
  2171.       (SHORT) STRING_SIZE,             /* The size of the buffer.             */
  2172.       acStringBuffer );                /* The buffer to place the string.     */
  2173.  
  2174.    usMessageBoxResult =
  2175.       WinMessageBox(
  2176.          HWND_DESKTOP,                 /* Parent handle of the message box.   */
  2177.          hwndOwnerWindow,              /* Owner handle of the message box.    */
  2178.          acStringBuffer,               /* String to show in the message box.  */
  2179.          pcMessageTitle,               /* Title to shown in the message box.  */
  2180.          (USHORT) ID_MESSAGE_BOX,      /* Message Box Id.                     */
  2181.          ulMessageBoxStyle );          /* The style of the message box.       */
  2182.  
  2183.    return( usMessageBoxResult );
  2184.  
  2185. }  /* End of ShowAMessage */
  2186.  
  2187.  
  2188. /******************************************************************************
  2189.  * Name        : IsMCIStringValid
  2190.  *
  2191.  * Description : This function will take a string and decide if it is valid,
  2192.  *               i.e., the string is not empty or full of blanks.
  2193.  *
  2194.  * Concepts    : None.
  2195.  *
  2196.  * MMPM/2 API's: None.
  2197.  *
  2198.  * Parameters  : pszMCIString - Points to the buffer that will hold
  2199.  *
  2200.  * Return      : TRUE if the string is valid worked otherwise FALSE.
  2201.  *
  2202.  ******************************************************************************/
  2203. BOOL IsMCIStringValid( PSZ pszMCIString )
  2204. {
  2205.    if ( strlen( pszMCIString ) == 0 )
  2206.    {
  2207.       return( FALSE );
  2208.    }
  2209.  
  2210.    return( TRUE );
  2211.  
  2212. }  /* End of IsMCIStringValid */
  2213.  
  2214.  
  2215. /******************************************************************************
  2216.  * Name        : GetStringFromComboBox
  2217.  *
  2218.  * Description : This function will get a string from the String Combo Box's
  2219.  *               Entry Field of the dialog box.
  2220.  *
  2221.  * Concepts    : None.
  2222.  *
  2223.  * MMPM/2 API's: None.
  2224.  *
  2225.  * Parameters  : pszMCIString - Points to the buffer that will hold
  2226.  *                              the Source File Name.
  2227.  *               hwndStringComboBox - Handle to the Combo Box.
  2228.  *
  2229.  * Return      : TRUE if the retrieval worked otherwise FALSE.
  2230.  *
  2231.  ******************************************************************************/
  2232. BOOL GetStringFromComboBox( HWND hwndStringComboBox,
  2233.                             PSZ  pszMCIString )
  2234. {
  2235.    SHORT sTextLength;                      /* Text length of combo box string.*/
  2236.  
  2237.    sTextLength =
  2238.       WinQueryWindowText(
  2239.          hwndStringComboBox,
  2240.          FILE_NAME_SIZE,
  2241.          (PCH) pszMCIString );
  2242.  
  2243.    if ( sTextLength == 0 )
  2244.    {
  2245.       pszMCIString[ 0 ] = (CHAR) NULL;
  2246.  
  2247.       ShowAMessage(
  2248.          hwndMainDialogBox,                    /* Owner Window.               */
  2249.          acStringBuffer[ IDS_NORMAL_ERROR_MESSAGE_BOX_TEXT - 1 ],
  2250.          IDS_MCI_STRING_HAS_NO_SIZE,           /* ID of the message.          */
  2251.          MB_APPLMODAL | MB_MOVEABLE | MB_HELP |
  2252.             MB_CANCEL | MB_INFORMATION );      /* Message box style.          */
  2253.  
  2254.       return( FALSE );
  2255.  
  2256.    }
  2257.  
  2258.    return( TRUE );
  2259.  
  2260. }  /* End of GetStringFromComboBox */
  2261.  
  2262.  
  2263. /******************************************************************************
  2264.  * Name        : SetSystemMenu
  2265.  *
  2266.  * Description : This procedure changes the System Menu of the given dialog
  2267.  *               window so that only the Move and Close options will be
  2268.  *               seen.
  2269.  *
  2270.  * Concepts    : None.
  2271.  *
  2272.  * MMPM/2 API's: None.
  2273.  *
  2274.  * Parameters  : hwndDialogWindow - Handle to the dialog window whose system
  2275.  *                                  menu is to be changed.
  2276.  *
  2277.  * Return      : None.
  2278.  *
  2279.  ******************************************************************************/
  2280. VOID SetSystemMenu( HWND hwndDialogWindow )
  2281. {
  2282.    HWND     hwndSysMenu;                 /* System menu pull-down handle.     */
  2283.  
  2284.    /*
  2285.     * Get the handle of the system menu pull-down.
  2286.     */
  2287.    hwndSysMenu =
  2288.       WinWindowFromID(
  2289.          hwndDialogWindow,
  2290.          (USHORT) FID_SYSMENU );
  2291.  
  2292.    WinSendMsg(
  2293.       hwndSysMenu,
  2294.       MM_DELETEITEM,
  2295.       MPFROM2SHORT( (SHORT) SC_TASKMANAGER, (SHORT) TRUE ),
  2296.       (MPARAM) NULL );
  2297.  
  2298.    WinSendMsg(
  2299.       hwndSysMenu,
  2300.       MM_DELETEITEM,
  2301.       MPFROM2SHORT( SC_RESTORE, TRUE ),
  2302.       (MPARAM) NULL );
  2303.  
  2304.    WinSendMsg(
  2305.       hwndSysMenu,
  2306.       MM_DELETEITEM,
  2307.       MPFROM2SHORT( SC_SIZE, TRUE ),
  2308.       (MPARAM) NULL );
  2309.  
  2310.    WinSendMsg(
  2311.       hwndSysMenu,
  2312.       MM_DELETEITEM,
  2313.       MPFROM2SHORT( SC_MINIMIZE, TRUE ),
  2314.       (MPARAM) NULL );
  2315.  
  2316.    WinSendMsg(
  2317.       hwndSysMenu,
  2318.       MM_DELETEITEM,
  2319.       MPFROM2SHORT( SC_MAXIMIZE, TRUE ),
  2320.       (MPARAM) NULL );
  2321.  
  2322. }  /* End of SetSystemMenu. */
  2323.  
  2324.  
  2325. /******************************************************************************
  2326.  * Name        : SendScrollBarMessage
  2327.  *
  2328.  * Description : This procedure sends scroll bar messages to the vertical
  2329.  *               scroll bar in the subclassed list box in the Display
  2330.  *               Messages dialog box.  This is done so that cursor keys
  2331.  *               for the list box can be trapped to prevent the items
  2332.  *               within the list box from being highlighted, i.e., selected.
  2333.  *
  2334.  * Concepts    : None.
  2335.  *
  2336.  * MMPM/2 API's: None.
  2337.  *
  2338.  * Parameters  : hwndControl       : Handle to the dialog window.
  2339.  *               sScrollBarMessage : Message to send to the scroll bar.
  2340.  *
  2341.  * Return      : None.
  2342.  *
  2343.  ******************************************************************************/
  2344. VOID SendScrollBarMessage(
  2345.          HWND  hwndControl,
  2346.          SHORT sScrollBarMessage )
  2347. {
  2348.    SHORT sCurrentSBPosition;     /* Position of the scroll bar.               */
  2349.    HWND  hwndVerticalSB;         /* Handle to the vertical scroll bar.        */
  2350.  
  2351.  
  2352.    if ( WinQueryFocus( HWND_DESKTOP ) == hwndControl )
  2353.    {
  2354.       /*
  2355.        * Get the handle to the list box's vertical scroll bar so that the
  2356.        * position of the scroll bar can be determined.
  2357.        */
  2358.       hwndVerticalSB =
  2359.          WinWindowFromID(
  2360.             hwndControl,
  2361.             (USHORT) LIST_BOX_VERTICAL_SB_ID );
  2362.  
  2363.       /*
  2364.        * Get the current position of the scroll bar.
  2365.        */
  2366.       sCurrentSBPosition = (SHORT)
  2367.          WinSendMsg(
  2368.             hwndVerticalSB,
  2369.             SBM_QUERYPOS,
  2370.             (MPARAM) 0,
  2371.             (MPARAM) 0 );
  2372.  
  2373.       /*
  2374.        * Send the scroll bar message that was passed into this routine to the
  2375.        * dialog box with the list box.
  2376.        */
  2377.       WinPostMsg(
  2378.          hwndControl,
  2379.          WM_VSCROLL,
  2380.          (MPARAM) (USHORT) LIST_BOX_VERTICAL_SB_ID,
  2381.          (MPARAM) MPFROM2SHORT( sCurrentSBPosition,
  2382.                                 sScrollBarMessage ) );
  2383.    }
  2384.  
  2385. }  /* End of SendScrollBarMessage. */
  2386.