home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wpentk.zip / WBPENTK1.DSK / WRTSMDLG.C < prev   
C/C++ Source or Header  |  1994-10-06  |  137KB  |  2,898 lines

  1. /******************************************************************************
  2. *                                                                             *
  3. *  File Name   : WRTSMDLG.C                                                   *
  4. *                                                                             *
  5. *  Description : Dialog functions for the WRTSAMPL.exe                        *
  6. *                                                                             *
  7. *  Function:  This file has all the dialog procedures for the wrtsampl.exe    *
  8. *                                                                             *
  9. *  Copyright (C) 1993 IBM Corporation                                         *
  10. *                                                                             *
  11. *      DISCLAIMER OF WARRANTIES.  The following [enclosed] code is            *
  12. *      sample code created by IBM Corporation. This sample code is not        *
  13. *      part of any standard or IBM product and is provided to you solely      *
  14. *      for  the purpose of assisting you in the development of your           *
  15. *      applications.  The code is provided "AS IS", without                   *
  16. *      warranty of any kind.  IBM shall not be liable for any damages         *
  17. *      arising out of your use of the sample code, even if they have been     *
  18. *      advised of the possibility of such damages.                            *
  19. *                                                                             *
  20. *******************************************************************************/
  21.  
  22. #define INCL_DOS
  23. #define INCL_PM
  24. #define INCL_GPI
  25. #define INCL_DOSMEMMGR
  26. #define  INCL_WINLOAD
  27. #define  INCL_DOSPROCESS
  28. #define  INCL_DOSSEMAPHORES
  29. #include <os2.h>
  30. #include <stdlib.h>
  31. #include <string.h>
  32. #include <stdio.h>
  33.  
  34. #include <penpm.h>
  35.  
  36. #include "wrtsampl.h"
  37.  
  38. ULONG ulNumDevices;
  39. CHAR aDeviceName[10][32];
  40. SHORT index1, index2, index3;
  41. HWND hwndCombo1, hwndCombo2, hwndCombo3;
  42. LONG startvalue;
  43. SHORT index;
  44. /******************************************************************************/
  45. /*     Display Dialogs                                                        */
  46. /******************************************************************************/
  47. /*******************************************************************************
  48. *                                                                              *
  49. * Function Name: QInpDevDlgProc                                                *
  50. *                                                                              *
  51. * Description :                                                                *
  52. *                                                                              *
  53. *   Displays the Query Input Device variable Pen for OS/2                      *
  54. *                                                                              *
  55. * Input:                                                                       *
  56. *                                                                              *
  57. * Output: Display the Query Input variable.                                    *
  58. *                                                                              *
  59. *******************************************************************************/
  60. MRESULT EXPENTRY QInpDevDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  61. {
  62.   HWND hwnd_temp;
  63.  
  64. switch(msg)
  65. {
  66.   case WM_INITDLG:
  67.     init_invar ( hwnd, 1 );
  68.   return(FALSE);
  69.  
  70.  case WM_COMMAND:
  71.     switch ( SHORT1FROMMP ( mp1 ) )
  72.     {
  73.        case EXIT:
  74.            WinDismissDlg ( hwnd, EXIT );
  75.            break;
  76.     } /* endswitch */
  77.  return ( FALSE );
  78.  
  79.  case WM_CONTROL:
  80.     switch ( SHORT2FROMMP ( mp1 ) )
  81.     {
  82.        case CBN_ENTER:
  83.          hwnd_temp = HWNDFROMMP ( mp2 );
  84.          updatecntrl ( hwnd, 1, hwnd_temp );
  85.        break;
  86.     }  /* endswitch */
  87.  return ( FALSE );
  88. } /* endswitch */
  89. return(WinDefDlgProc(hwnd, msg, mp1, mp2));
  90. }
  91. /*******************************************************************************
  92. *                                                                              *
  93. * Function Name: QInDevNDlgProc                                                *
  94. *                                                                              *
  95. * Description :                                                                *
  96. *                                                                              *
  97. *   Displays the Device names supported by each driver                         *
  98. *                                                                              *
  99. * Input:                                                                       *
  100. *                                                                              *
  101. * Output: Display the Device names supported by each driver.                   *
  102. *                                                                              *
  103. *******************************************************************************/
  104. MRESULT EXPENTRY QInDevNDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  105. {
  106.   APIRET irc;
  107.   CHAR cbuffer[MAXCBUFFER];
  108.   ULONG aDeviceType[10];
  109.   ULONG aDeviceID[10];
  110.   HWND hwnd_temp;
  111.   WNDPARAMS comboprams;
  112.   INT i;
  113.  
  114. switch(msg)
  115. {
  116.  case WM_INITDLG:
  117.   /****************************************************************************/
  118.   /* Find out how many input driver there are                                 */
  119.   /****************************************************************************/
  120.   ulNumDrivers = 0L;
  121.   irc = WrtEnumInputDrivers ( &ulNumDrivers, NULL );
  122.   if ( irc != WRT_NO_ERROR )
  123.   {
  124.     DisplayError ( hwnd, irc );
  125.   } else
  126.   {
  127.     if ( ulNumDrivers > 10L )
  128.     {
  129.       sprintf(cbuffer,"Too many drivers[%ld] for my ARRAY", ulNumDrivers );
  130.       WinMessageBox( HWND_DESKTOP,
  131.                      hwnd,
  132.                      cbuffer,
  133.                      NULL, 1, MB_OK );
  134.     } else
  135.     {
  136.       if ( ulNumDrivers == 0L )
  137.       {
  138.         sprintf(cbuffer,"No drivers found" );
  139.         WinMessageBox( HWND_DESKTOP,
  140.                        hwnd,
  141.                        cbuffer,
  142.                        NULL, 1, MB_OK );
  143.       } else
  144.       {
  145.         /**********************************************************************/
  146.         /* get array of driver names                                          */
  147.         /**********************************************************************/
  148.         irc = WrtEnumInputDrivers ( &ulNumDrivers, szDriverName );
  149.         if ( irc != WRT_NO_ERROR )
  150.         {
  151.           DisplayError ( hwnd, irc );
  152.         } else
  153.         {
  154.           /********************************************************************/
  155.           /* initialize the entries in the Drivers list box                   */
  156.           /********************************************************************/
  157.           hwndCombo1 = WinWindowFromID ( hwnd , wrtelc01 );
  158.  
  159.           for ( i= 0; i < ulNumDrivers ; i++ )
  160.           {
  161.             index1 = (SHORT) WinSendMsg ( hwndCombo1, LM_INSERTITEM,
  162.                                  MPFROMSHORT ( LIT_END ),
  163.                                  MPFROMP ( szDriverName[i] ) );
  164.           } /* endfor */
  165.           /********************************************************************/
  166.           /* Set the first item on the list at the top.                       */
  167.           /********************************************************************/
  168.           index1 = 0;                         /* intialize the index to zeror */
  169.           WinSendMsg ( hwndCombo1, LM_SETTOPINDEX, MPFROMSHORT ( index1 ), 0 );
  170.  
  171.           comboprams.fsStatus = WPM_TEXT;      /* change window text          */
  172.           comboprams.cchText = sizeof ( szDriverName[index1] );  /* text size */
  173.           comboprams.pszText = szDriverName[index1];         /*text to display*/
  174.           WinSendMsg ( hwndCombo1, WM_SETWINDOWPARAMS,
  175.                        &comboprams, 0 );
  176.  
  177.           /********************************************************************/
  178.           /* Find out how many input device there are                         */
  179.           /********************************************************************/
  180.           ulNumDevices = 0L;
  181.           irc = WrtQueryInputDeviceNames ( szDriverName[index1], &ulNumDevices,
  182.                                            NULL, NULL, NULL );
  183.           if ( irc != WRT_NO_ERROR )
  184.           {
  185.             DisplayError ( hwnd, irc );
  186.           } else
  187.           {
  188.             if ( ulNumDevices > 10L )
  189.             {
  190.               sprintf(cbuffer,"Too many devices[%ld] Driver[%s] for my ARRAY",
  191.                       ulNumDevices, szDriverName[index1] );
  192.               WinMessageBox( HWND_DESKTOP,
  193.                              hwnd,
  194.                              cbuffer,
  195.                              NULL, 1, MB_OK );
  196.             } else
  197.             {
  198.               /****************************************************************/
  199.               /* Get array of device names                                    */
  200.               /****************************************************************/
  201.               irc = WrtQueryInputDeviceNames ( szDriverName[index1],
  202.                                                &ulNumDevices, aDeviceName,
  203.                                                aDeviceType, aDeviceID );
  204.               if ( irc != WRT_NO_ERROR )
  205.               {
  206.                 DisplayError ( hwnd, irc );
  207.               } else
  208.               {
  209.                 /**************************************************************/
  210.                 /* initialize the entries in the list box                     */
  211.                 /**************************************************************/
  212.                 hwndCombo2 = WinWindowFromID ( hwnd , wrtelc02 );
  213.  
  214.                 for ( i= 0; i < ulNumDevices ; i++ )
  215.                 {
  216.                   index2 = (SHORT) WinSendMsg ( hwndCombo2, LM_INSERTITEM,
  217.                                        MPFROMSHORT ( LIT_END ),
  218.                                        MPFROMP ( aDeviceName[i] ) );
  219.                 } /* endfor */
  220.                 /**************************************************************/
  221.                 /* Set the first item on the list at the top.                 */
  222.                 /**************************************************************/
  223.                 index2 = 0;                     /* intialize the index to zeror */
  224.                 WinSendMsg ( hwndCombo2, LM_SETTOPINDEX,
  225.                              MPFROMSHORT ( index2 ), 0 );
  226.  
  227.                 comboprams.fsStatus = WPM_TEXT;      /* change window text    */
  228.                 comboprams.cchText = sizeof( aDeviceName[index2] );/*text size*/
  229.                 comboprams.pszText = aDeviceName[index2];    /*text to display*/
  230.                 WinSendMsg ( hwndCombo2, WM_SETWINDOWPARAMS,
  231.                              &comboprams, 0 );
  232.               } /* endif */
  233.             } /* endif */
  234.           } /* endif */
  235.         } /* endif */
  236.       } /* endif */
  237.     } /* endif */
  238.   } /* endif */
  239.   return(FALSE);
  240.  
  241.  case WM_COMMAND:
  242.          switch ( SHORT1FROMMP ( mp1 ) )
  243.          {
  244.             case EXIT:
  245.                 WinDismissDlg ( hwnd, EXIT );
  246.                 break;
  247.          } /* endswitch */
  248.  return ( FALSE );
  249.  
  250.  case WM_CONTROL:
  251.     switch ( SHORT2FROMMP ( mp1 ) )
  252.     {
  253.        case CBN_ENTER:
  254.          hwnd_temp = HWNDFROMMP ( mp2 );
  255.          if ( hwnd_temp == hwndCombo1 )
  256.          {
  257.            /*******************************************************************/
  258.            /* Get the Driver selected and find:                               */
  259.            /* 1: devices supported by the driver                              */
  260.            /*******************************************************************/
  261.            /*******************************************************************/
  262.            /* find the index of the selected item                             */
  263.            /*******************************************************************/
  264.            index1 = (SHORT)WinSendMsg ( hwndCombo1, LM_QUERYSELECTION, 0L, 0L );
  265.            if ( index1 != LIT_NONE )
  266.            {
  267.              /*****************************************************************/
  268.              /* get the name of the driver choosen.                           */
  269.              /*****************************************************************/
  270.              WinSendMsg ( hwndCombo1, LM_QUERYITEMTEXT,
  271.                                   MPFROM2SHORT ( index1, 32 ),
  272.                                   MPFROMP ( szDriverName[index1] ) );
  273.              /*****************************************************************/
  274.              /* Clear out the Devices list box and get the devices for the    */
  275.              /* driver.                                                       */
  276.              /*****************************************************************/
  277.              WinSendMsg ( hwndCombo2, LM_DELETEALL,
  278.                                   0L,
  279.                                   0L );
  280.              /*****************************************************************/
  281.              /* Find out how many input device there are                      */
  282.              /*****************************************************************/
  283.              ulNumDevices = 0L;
  284.              irc = WrtQueryInputDeviceNames ( szDriverName[index1],
  285.                                               &ulNumDevices,
  286.                                               NULL, NULL, NULL );
  287.              if ( irc != WRT_NO_ERROR )
  288.              {
  289.                sprintf(cbuffer,"FAIL getting # Device Name Driver[%s] RET= %#x",
  290.                     szDriverName[index1], irc );
  291.                WinMessageBox( HWND_DESKTOP,
  292.                               hwnd,
  293.                               cbuffer,
  294.                               NULL, 1, MB_OK );
  295.              } else
  296.              {
  297.                if ( ulNumDevices > 10L )
  298.                {
  299.                  sprintf(cbuffer,"Too many devices[%ld] Driver[%s] for my ARRAY",
  300.                          ulNumDevices, szDriverName[index1] );
  301.                  WinMessageBox( HWND_DESKTOP,
  302.                                 hwnd,
  303.                                 cbuffer,
  304.                                 NULL, 1, MB_OK );
  305.                } else
  306.                {
  307.                  /*************************************************************/
  308.                  /* Get array of device names                                 */
  309.                  /*************************************************************/
  310.                  irc = WrtQueryInputDeviceNames ( szDriverName[index1],
  311.                                                   &ulNumDevices, aDeviceName,
  312.                                                   aDeviceType, aDeviceID );
  313.                  if ( irc != WRT_NO_ERROR )
  314.                  {
  315.                    sprintf(cbuffer,"FAIL Device Name Driver[%s] RET= %#x",
  316.                            szDriverName[i], irc );
  317.                    WinMessageBox( HWND_DESKTOP,
  318.                                   hwnd,
  319.                                   cbuffer,
  320.                                   NULL, 1, MB_OK );
  321.                  } else
  322.                  {
  323.                    /***********************************************************/
  324.                    /* initialize the entries in the list box                  */
  325.                    /***********************************************************/
  326.                    hwndCombo2 = WinWindowFromID ( hwnd , wrtelc02 );
  327.  
  328.                    for ( i= 0; i < ulNumDevices ; i++ )
  329.                    {
  330.                      index2 = (SHORT) WinSendMsg ( hwndCombo2, LM_INSERTITEM,
  331.                                           MPFROMSHORT ( LIT_END ),
  332.                                           MPFROMP ( aDeviceName[i] ) );
  333.                    } /* endfor */
  334.                    /***********************************************************/
  335.                    /* Set the first item on the list at the top.              */
  336.                    /***********************************************************/
  337.                    index2 = 0;                /* intialize the index to zeror */
  338.                    WinSendMsg ( hwndCombo2, LM_SETTOPINDEX,
  339.                                 MPFROMSHORT ( index2 ), 0 );
  340.  
  341.                    comboprams.fsStatus = WPM_TEXT;      /* change window text */
  342.                    comboprams.cchText = sizeof ( aDeviceName[index2] );
  343.                    /*text size*/
  344.                    comboprams.pszText = aDeviceName[index2]; /*text to display*/
  345.                    WinSendMsg ( hwndCombo2, WM_SETWINDOWPARAMS,
  346.                                 &comboprams, 0 );
  347.  
  348.                  } /* endif */
  349.                } /* endif */
  350.              } /* endif */
  351.            } /* endif */
  352.          } /* endif */
  353.        break;
  354.     }  /* endswitch */
  355.  return ( FALSE );
  356. } /* endswitch */
  357. return(WinDefDlgProc(hwnd, msg, mp1, mp2));
  358. }
  359. /*******************************************************************************
  360. *                                                                              *
  361. * Function Name: SInpDevDlgProc                                                *
  362. *                                                                              *
  363. * Description :                                                                *
  364. *                                                                              *
  365. *   Set the Input Device variable Pen for OS/2                                 *
  366. *                                                                              *
  367. * Input:                                                                       *
  368. *                                                                              *
  369. * Output: Set the Input variable.                                              *
  370. *                                                                              *
  371. ******************************************************************************/
  372. MRESULT EXPENTRY SInpDevDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  373. {
  374.   APIRET irc;
  375.   CHAR cbuffer[MAXCBUFFER];
  376.   HWND hwnd_temp;
  377.   INT i;
  378.   INT cbox;
  379.  
  380. switch(msg)
  381. {
  382.  case WM_INITDLG:
  383.          init_invar ( hwnd, 0 );
  384.  return(FALSE);
  385.  
  386.  case WM_COMMAND:
  387.          switch ( SHORT1FROMMP ( mp1 ) )
  388.          {
  389.            case EXIT:
  390.              WinDismissDlg ( hwnd, EXIT );
  391.              break;
  392.            case SET:
  393.              if ( index1 == LIT_NONE )
  394.              {
  395.                sprintf(cbuffer,"INDEX1 == LIT_NONE can not set value");
  396.                WinMessageBox( HWND_DESKTOP,
  397.                               hwnd,
  398.                               cbuffer,
  399.                               NULL, 1, MB_OK );
  400.              } else
  401.              {
  402.                if ( index2 == LIT_NONE )
  403.                {
  404.                  sprintf(cbuffer,"INDEX2 == LIT_NONE can not set value");
  405.                  WinMessageBox( HWND_DESKTOP,
  406.                                hwnd,
  407.                                cbuffer,
  408.                                NULL, 1, MB_OK );
  409.                } else
  410.                {
  411.                  if ( index3 == LIT_NONE )
  412.                  {
  413.                    sprintf(cbuffer,"INDEX3 == LIT_NONE can not set value");
  414.                    WinMessageBox( HWND_DESKTOP,
  415.                                   hwnd,
  416.                                   cbuffer,
  417.                                   NULL, 1, MB_OK );
  418.                  } else
  419.                  {
  420.                    /*********************************************************/
  421.                    /*Find the ID coresponding to the index                  */
  422.                    /*********************************************************/
  423.                    cbox = -1;
  424.                    for ( i= 0; i < (PPMIDSIZE - 1); i++)
  425.                    {
  426.                      if ( ppmid[i].active )
  427.                      {
  428.                        if ( ++cbox == index3  )
  429.                        {
  430.                           break;
  431.                        } /* endif */
  432.                      } /* endif */
  433.                    } /* endfor */
  434.                    /*********************************************************/
  435.                    /* Query the value of the spin button and put it in      */
  436.                    /* ppmid[].value                                         */
  437.                    /*********************************************************/
  438.                    WinSendMsg ( WinWindowFromID ( hwnd, wrtelc04 )
  439.                                ,SPBM_QUERYVALUE
  440.                                ,MPFROMLONG ( &ppmid[i].value )
  441.                                ,MPFROM2SHORT ( NULL, SPBQ_DONOTUPDATE )
  442.                                );
  443.  
  444.                    /*********************************************************/
  445.                    /* Write the Device ID value in to memory                */
  446.                    /*********************************************************/
  447.                    irc = WrtSetInputDeviceVariable ( szDriverName[index1],
  448.                                                      aDeviceName[index2],
  449.                                                      ppmid[i].ValueID,
  450.                                                      ppmid[i].value,
  451.                                                      0L,
  452.                                                      NULL
  453.                                                    );
  454.                    if ( irc == WRT_NO_ERROR )
  455.                    {
  456.                      /*******************************************************/
  457.                      /* Broadcast a post message to all descendants of      */
  458.                      /* HWND_DESKTOP notifying which device variable got    */
  459.                      /* changed so they can update if need be               */
  460.                      /*******************************************************/
  461.                      WinBroadcastMsg (
  462.                                   HWND_DESKTOP,
  463.                                   WM_WRT_SYSVALUECHANGED,
  464.                                   (MPARAM)VT_PPMID,
  465.                                   (MPARAM)ppmid[i].ValueID,
  466.                                   BMSG_DESCENDANTS | BMSG_POST
  467.                                   );
  468.                    } /* endif */
  469.                  } /* endif */
  470.                } /* endif */
  471.              } /* endif */
  472.            break;
  473.          } /* endswitch */
  474.  return ( FALSE );
  475.  
  476.  case WM_CONTROL:
  477.     switch ( SHORT2FROMMP ( mp1 ) )
  478.     {
  479.        case SPBN_UPARROW:
  480.        case SPBN_DOWNARROW:
  481.           /*********************************************************/
  482.           /*Find the ID coresponding to the index                  */
  483.           /*********************************************************/
  484.           cbox = -1;
  485.           for ( i= 0; i < (PPMIDSIZE - 1); i++)
  486.           {
  487.             if ( ppmid[i].active )
  488.             {
  489.               if ( ++cbox == index3  )
  490.               {
  491.                  break;
  492.               } /* endif */
  493.             } /* endif */
  494.           } /* endfor */
  495.           if ( ppmid[i].disable == 1 )
  496.           {
  497.              /*********************************************************/
  498.              /* Query the value of the spin button and put it in      */
  499.              /* ppmid[].value                                         */
  500.              /*********************************************************/
  501.              WinSendMsg ( WinWindowFromID ( hwnd, wrtelc04 )
  502.                          ,SPBM_QUERYVALUE
  503.                          ,MPFROMLONG ( &ppmid[i].value )
  504.                          ,MPFROM2SHORT ( NULL, SPBQ_DONOTUPDATE )
  505.                          );
  506.              if ( ppmid[i].value == ppmid[i].minval ||
  507.                   ppmid[i].value == ppmid[i].maxval  )
  508.              {
  509.                WinSendMsg ( WinWindowFromID ( hwnd, wrtelc04 ),
  510.                            SPBM_OVERRIDESETLIMITS,
  511.                            MPFROMLONG ( ppmid[i].maxval ),/* MAX*/
  512.                            MPFROMLONG ( 0L ) /* MIN*/
  513.                            );
  514.              } else
  515.              {
  516.                if ( ppmid[i].value < ppmid[i].minval )
  517.                {
  518.                  WinSendMsg ( WinWindowFromID ( hwnd, wrtelc04 ),
  519.                              SPBM_SETCURRENTVALUE,
  520.                              MPFROMLONG ( 0L ),
  521.                              0L
  522.                              );
  523.                  WinSendMsg ( WinWindowFromID ( hwnd, wrtelc04 ),
  524.                              SPBM_OVERRIDESETLIMITS,
  525.                              MPFROMLONG ( ppmid[i].maxval ),/* MAX*/
  526.                              MPFROMLONG ( ppmid[i].minval ) /* MIN*/
  527.                              );
  528.                } /* endif */
  529.              } /* endif */
  530.           } /* endif */
  531.           break;
  532.        case CBN_ENTER:
  533.          hwnd_temp = HWNDFROMMP ( mp2 );
  534.          updatecntrl ( hwnd, 0, hwnd_temp );
  535.        break;
  536.     }  /* endswitch */
  537.  return ( FALSE );
  538. } /* endswitch */
  539. return(WinDefDlgProc(hwnd, msg, mp1, mp2));
  540. }
  541. /*******************************************************************************
  542. *                                                                              *
  543. * Function Name: EnumDrvDlgProc                                                *
  544. *                                                                              *
  545. * Description :                                                                *
  546. *                                                                              *
  547. *   Displays the Enumiration of the Pen for OS/2 input drivers.                *
  548. *                                                                              *
  549. * Input:                                                                       *
  550. *                                                                              *
  551. * Output: Display the Enumiration of the Pen for OS/2 drivers.                 *
  552. *                                                                              *
  553. *******************************************************************************/
  554. MRESULT EXPENTRY EnumDrvDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  555. {
  556.    INT i;
  557.  
  558.    switch(msg)
  559.    {
  560.       case WM_INITDLG:
  561.         WinSendDlgItemMsg(hwnd,          /* Delete all items in the list box */
  562.                           wrtelc01,
  563.                           LM_DELETEALL,
  564.                           0UL,
  565.                           0UL);
  566.  
  567.         for ( i = 0; i < ulNumDrivers; i++ )
  568.         {
  569.               WinSendDlgItemMsg(hwnd,   /* put the Driver name to listbox */
  570.                                 wrtelc01,
  571.                                 LM_INSERTITEM,
  572.                                 MPFROM2SHORT( LIT_END, 0 ),
  573.                                 MPFROMP( szDriverName[i] )
  574.                                 );
  575.         } /* endfor */
  576.         return(FALSE);
  577.  
  578.       case WM_COMMAND:
  579.          switch ( SHORT1FROMMP ( mp1 ) )
  580.          {
  581.             case EXIT:
  582.                 WinDismissDlg ( hwnd, EXIT );
  583.          } /* endswitch */
  584.          return ( FALSE );
  585.    } /* endswitch */
  586.    return(WinDefDlgProc(hwnd, msg, mp1, mp2));
  587. }
  588. /*******************************************************************************
  589. *                                                                              *
  590. * Function Name: RSysVlDlgProc                                                 *
  591. *                                                                              *
  592. * Description :                                                                *
  593. *                                                                              *
  594. *   Read a System values.                                                      *
  595. *                                                                              *
  596. * Input:                                                                       *
  597. *                                                                              *
  598. * Output: Read system values                                                   *
  599. *                                                                              *
  600. *******************************************************************************/
  601. MRESULT EXPENTRY RSysVlDlgProc ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
  602. {
  603.   CHAR cbuffer[MAXCBUFFER];
  604.   APIRET irc;
  605.    switch(msg)
  606.    {
  607.      case WM_INITDLG:
  608.         init_sysval( hwnd, 1 );
  609.         return(FALSE);
  610.  
  611.      case WM_CONTROL:
  612.         switch ( SHORT2FROMMP ( mp1 ) )
  613.         {
  614.            case CBN_ENTER:
  615.             enter_sysval( hwnd, 1 );
  616.             return ( FALSE );
  617.         } /* endswitch */
  618.      case WM_COMMAND:
  619.         switch ( SHORT1FROMMP ( mp1 ) )
  620.         {
  621.             case EXIT:
  622.                /***************************************************************/
  623.                /* exit the dialog with out writing any system values.         */
  624.                /***************************************************************/
  625.                WinDismissDlg ( hwnd, EXIT );
  626.                break;
  627.  
  628.             case READ:
  629.                /***************************************************************/
  630.                /* Read  the system value from Pen for OS/2 profile set memory */
  631.                /***************************************************************/
  632.                irc = WrtReadSysValue ( HWND_DESKTOP,
  633.                                         qsvalue[index+1].valueid );
  634.                if ( irc == WRT_NO_ERROR )
  635.                {
  636.                  /**********************************************************/
  637.                  /* Broadcast a post message to all descendants of         */
  638.                  /* HWND_DESKTOP notifying which system value got changed  */
  639.                  /* so they can update if need be                          */
  640.                  /**********************************************************/
  641.                  WinBroadcastMsg (
  642.                               HWND_DESKTOP,
  643.                               WM_WRT_SYSVALUECHANGED,
  644.                               (MPARAM)VT_PPMSV,
  645.                               (MPARAM)qsvalue[index+1].valueid,
  646.                               BMSG_DESCENDANTS | BMSG_POST
  647.                               );
  648.                } else
  649.                {
  650.                  DisplayError ( hwnd, irc );
  651.                } /* endif */
  652.                /***************************************************************/
  653.                /* get the sytem value to change                               */
  654.                /***************************************************************/
  655.                startvalue = WrtQuerySysValue ( HWND_DESKTOP,
  656.                                           qsvalue[index+1].valueid );
  657.  
  658.                /***************************************************************/
  659.                /* initialize all the entry field to the system value that was */
  660.                /* query. If the query reutrn an error (WRTERR_INVALID_PARM)   */
  661.                /* set the entry field to zerro.                               */
  662.                /***************************************************************/
  663.                if ( startvalue == WRTERR_INVALID_PARM )
  664.                {
  665.                  startvalue = 0L;
  666.                } /* endif */
  667.  
  668.                /***************************************************************/
  669.                /* Set the entry field value to the value that was query from  */
  670.                /* the system.                                                 */
  671.                /***************************************************************/
  672.                sprintf ( cbuffer, "%li", startvalue);
  673.                WinSetDlgItemText ( hwnd, wrtelc02, cbuffer );
  674.                break;
  675.         } /* endswitch */
  676.         return ( FALSE );
  677.    } /* endswitch */
  678.    return ( WinDefDlgProc(hwnd, msg, mp1, mp2) );
  679. }
  680. /*******************************************************************************
  681. *                                                                              *
  682. * Function Name: WSysVlDlgProc                                                 *
  683. *                                                                              *
  684. * Description :                                                                *
  685. *                                                                              *
  686. *   Displays and Write   System values.                                        *
  687. *                                                                              *
  688. * Input:                                                                       *
  689. *                                                                              *
  690. * Output: Write a     system values                                            *
  691. *                                                                              *
  692. *******************************************************************************/
  693. MRESULT EXPENTRY WSysVlDlgProc ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
  694. {
  695.   APIRET irc;
  696.    switch(msg)
  697.    {
  698.      case WM_INITDLG:
  699.         init_sysval( hwnd, 0 );
  700.         return(FALSE);
  701.  
  702.      case WM_CONTROL:
  703.         switch ( SHORT2FROMMP ( mp1 ) )
  704.         {
  705.            case SPBN_UPARROW:
  706.            case SPBN_DOWNARROW:
  707.               updwn_sysval ( hwnd );
  708.            break;
  709.            case CBN_ENTER:
  710.             enter_sysval( hwnd, 0 );
  711.             return ( FALSE );
  712.         } /* endswitch */
  713.      case WM_COMMAND:
  714.         switch ( SHORT1FROMMP ( mp1 ) )
  715.         {
  716.             case EXIT:
  717.                /***************************************************************/
  718.                /* exit the dialog with out writing any system values.         */
  719.                /***************************************************************/
  720.                WinDismissDlg ( hwnd, EXIT );
  721.                break;
  722.             case SET:
  723.                set_sysval ( hwnd );
  724.  
  725.                /***************************************************************/
  726.                /* Write the system value from memory to Pen for OS/2 profile  */
  727.                /***************************************************************/
  728.                irc = WrtWriteSysValue ( HWND_DESKTOP,
  729.                                         qsvalue[index+1].valueid );
  730.                DisplayError ( hwnd, irc );
  731.  
  732.                break;
  733.         } /* endswitch */
  734.         return ( FALSE );
  735.    } /* endswitch */
  736.    return ( WinDefDlgProc(hwnd, msg, mp1, mp2) );
  737. }
  738. /*******************************************************************************
  739. *                                                                              *
  740. * Function Name: SSysVlDlgProc                                                 *
  741. *                                                                              *
  742. * Description :                                                                *
  743. *                                                                              *
  744. *   Displays and set the System values.                                        *
  745. *                                                                              *
  746. * Input:                                                                       *
  747. *                                                                              *
  748. * Output: Set     the system values                                            *
  749. *                                                                              *
  750. *******************************************************************************/
  751. MRESULT EXPENTRY SSysVlDlgProc ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
  752. {
  753.    switch(msg)
  754.    {
  755.       case WM_INITDLG:
  756.         init_sysval( hwnd, 0 );
  757.         return(FALSE);
  758.  
  759.      case WM_CONTROL:
  760.         switch ( SHORT2FROMMP ( mp1 ) )
  761.         {
  762.            case SPBN_UPARROW:
  763.            case SPBN_DOWNARROW:
  764.               updwn_sysval ( hwnd );
  765.            break;
  766.            case CBN_ENTER:
  767.             enter_sysval( hwnd, 0 );
  768.             return ( FALSE );
  769.         } /* endswitch */
  770.      case WM_COMMAND:
  771.         switch ( SHORT1FROMMP ( mp1 ) )
  772.         {
  773.             case EXIT:
  774.                /***************************************************************/
  775.                /* exit the dialog with out writing any system values.         */
  776.                /***************************************************************/
  777.                WinDismissDlg ( hwnd, EXIT );
  778.                break;
  779.             case SET:
  780.                set_sysval ( hwnd );
  781.                break;
  782.         } /* endswitch */
  783.         return ( FALSE );
  784.    } /* endswitch */
  785.    return ( WinDefDlgProc(hwnd, msg, mp1, mp2) );
  786. }
  787.  
  788. /******************************************************************************
  789. *                                                                             *
  790. * Function Name: SysValDlgProc                                                *
  791. *                                                                             *
  792. * Description :                                                               *
  793. *                                                                             *
  794. *   Displays the System Values                                                *
  795. *                                                                             *
  796. * Input:                                                                      *
  797. *                                                                             *
  798. * Output: Display the system values                                           *
  799. *                                                                             *
  800. ******************************************************************************/
  801. MRESULT EXPENTRY SysValDlgProc ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
  802. {
  803.   CHAR cbuffer[MAXCBUFFER];
  804.   CHAR cname[30], cvalue[15];
  805.   INT i;
  806.    switch(msg)
  807.    {
  808.         case WM_INITDLG:
  809.             for (i=0; i< QSVALUESIZE ; i++)
  810.             {
  811.               qsvalue[i].value = WrtQuerySysValue ( HWND_DESKTOP,
  812.                                          qsvalue[i].valueid );
  813.  
  814.               if ( qsvalue[i].value == WRTERR_INVALID_PARM )
  815.               {
  816.                 sprintf ( cvalue, "%15s","Invalid Parm" );
  817.               } else
  818.               {
  819.                 sprintf ( cvalue, "%05li", qsvalue[i].value );
  820.               } /* endif */
  821.  
  822.               sprintf ( cname, "%-30s", qsvalue[i].valname );
  823.               sprintf ( cbuffer, "%-30.30s%-15.15s", cname, cvalue );
  824.               WinSendDlgItemMsg(hwnd,
  825.                                 wrtelc01,
  826.                                 LM_INSERTITEM,
  827.                                 MPFROM2SHORT(LIT_END, 0),
  828.                                 MPFROMP( cbuffer ) );
  829.             } /* endfor */
  830.         return(FALSE);
  831.      case WM_COMMAND:
  832.         switch ( SHORT1FROMMP ( mp1 ) )
  833.         {
  834.            case EXIT:
  835.                WinDismissDlg ( hwnd, EXIT );
  836.         } /* endswitch */
  837.         return ( FALSE );
  838.    }
  839.    return(WinDefDlgProc(hwnd, msg, mp1, mp2));
  840. }
  841.  
  842. /*******************************************************************************
  843. *                                                                              *
  844. * Function Name: ButCapDlgProc                                                 *
  845. *                                                                              *
  846. * Description :                                                                *
  847. *                                                                              *
  848. *   Displays the capabilities of the Buttons                                   *
  849. *                                                                              *
  850. * Input:                                                                       *
  851. *                                                                              *
  852. * Output: Display the capabilities of the system                               *
  853. *                                                                              *
  854. *******************************************************************************/
  855. MRESULT EXPENTRY ButCapDlgProc ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
  856. {
  857.   CHAR cbuffer[MAXCBUFFER];
  858.   WRTBUTTONDEVINFO bcInfo;
  859.   ULONG ulButtonID;
  860.   ULONG ulButTmp;
  861.   WNDPARAMS comboprams;
  862.   APIRET irc;
  863.    switch(msg)
  864.    {
  865.         case WM_INITDLG:
  866.           /********************************************************************/
  867.           /*  Find out how many buttons the system has by querying the        */
  868.           /*  button capabilities API with ulButtonID = 0L.                   */
  869.           /*  The API will write the number of button IDs in the system in    */
  870.           /*  the variable ulButtonID.                                        */
  871.           /********************************************************************/
  872.           ulButtonID = 0L;
  873.           irc = WrtQueryButtonCaps ( &ulButtonID, NULL );
  874.           if ( irc != WRT_NO_ERROR )
  875.           {
  876.             /******************************************************************/
  877.             /* ERROR from API                                                 */
  878.             /******************************************************************/
  879.             DisplayError ( hwnd, irc );
  880.           } else
  881.           {
  882.             /******************************************************************/
  883.             /* Find out if return greater than zero buttons                   */
  884.             /******************************************************************/
  885.             if ( ulButtonID == 0L )
  886.             {
  887.               WinMessageBox( HWND_DESKTOP,
  888.                               hwnd,
  889.                               "WrtQueryButtonCaps return 0 buttons",
  890.                               NULL, 1, MB_OK );
  891.             } else
  892.             {
  893.               /****************************************************************/
  894.               /* Got some locator to display                                  */
  895.               /****************************************************************/
  896.               hwndCombo1 = WinWindowFromID ( hwnd, wrtelc05 );
  897.               for ( ulButTmp = 1L; ulButTmp <= ulButtonID; ulButTmp++ )
  898.               {
  899.                 /**************************************************************/
  900.                 /* The cbStructureSize variable in the WRTBUTTONDEVINFO       */
  901.                 /* structure must be initialize to the size of the            */
  902.                 /* WRTBUTTONDEVINFO structure before querying the button      */
  903.                 /* capabilities.                                              */
  904.                 /**************************************************************/
  905.                 bcInfo.cbStructSize = sizeof ( bcInfo );
  906.  
  907.                 /**************************************************************/
  908.                 /* ulButTmp   variable has the ID of the button that you      */
  909.                 /* want to query                                              */
  910.                 /**************************************************************/
  911.                 irc = WrtQueryButtonCaps ( &ulButTmp, &bcInfo );
  912.  
  913.                 if ( irc == WRT_NO_ERROR )
  914.                 {
  915.                   /************************************************************/
  916.                   /*  good return from API                                    */
  917.                   /************************************************************/
  918.                   sprintf ( cbuffer, "%s %s",
  919.                             bcInfo.pszDriverName, bcInfo.pszDeviceName );
  920.                   index1 = (SHORT) WinSendMsg ( hwndCombo1, LM_INSERTITEM,
  921.                                     MPFROMSHORT ( LIT_END ),
  922.                                     MPFROMP ( cbuffer ) );
  923.                 } else
  924.                 {
  925.                   /************************************************************/
  926.                   /* ERROR from API                                           */
  927.                   /************************************************************/
  928.                   DisplayError ( hwnd, irc );
  929.                 } /* endif */
  930.               } /* endfor */
  931.               /****************************************************************/
  932.               /* Set the last  item on the list at the top.                   */
  933.               /****************************************************************/
  934.               WinSendMsg ( hwndCombo1, LM_SETTOPINDEX,
  935.                            MPFROMSHORT ( index1 ), 0 );
  936.  
  937.               comboprams.fsStatus = WPM_TEXT;           /* change window text */
  938.               comboprams.cchText = sizeof ( cbuffer );  /* text size          */
  939.               comboprams.pszText = cbuffer ;            /* text to display    */
  940.               WinSendMsg ( hwndCombo1, WM_SETWINDOWPARAMS, &comboprams, 0 );
  941.  
  942.               disp_butcaps ( hwnd, &bcInfo );
  943.  
  944.             } /* endif */
  945.           } /* endif */
  946.  
  947.         return(FALSE);
  948.      case WM_CONTROL:
  949.         switch ( SHORT2FROMMP (mp1) )
  950.         {
  951.            case CBN_ENTER:
  952.              /*****************************************************************/
  953.              /* find the index of the selected item                           */
  954.              /*****************************************************************/
  955.              index1 = (SHORT)WinSendMsg ( hwndCombo1, LM_QUERYSELECTION, 0L, 0L );
  956.              if ( index1 != LIT_NONE )
  957.              {
  958.                ulButTmp = (ULONG)(index1 + 1L);
  959.                bcInfo.cbStructSize = sizeof ( bcInfo );
  960.                irc = WrtQueryButtonCaps ( &ulButTmp, &bcInfo );
  961.                if ( irc == WRT_NO_ERROR )
  962.                {
  963.                  disp_butcaps (hwnd, &bcInfo );
  964.                } /* endif */
  965.              } /* endif */
  966.         } /* endswitch */
  967.         return ( FALSE );
  968.      case WM_COMMAND:
  969.         switch ( SHORT1FROMMP ( mp1 ) )
  970.         {
  971.            case EXIT:
  972.                WinDismissDlg ( hwnd, EXIT );
  973.         } /* endswitch */
  974.         return ( FALSE );
  975.    }
  976.    return(WinDefDlgProc(hwnd, msg, mp1, mp2));
  977. }
  978.  
  979. /*******************************************************************************
  980. *                                                                              *
  981. * Function Name: LocCapDlgProc                                                 *
  982. *                                                                              *
  983. * Description :                                                                *
  984. *                                                                              *
  985. *   Displays the capabilities of the Locaotors                                 *
  986. *                                                                              *
  987. * Input:                                                                       *
  988. *                                                                              *
  989. * Output: Display the capabilities of the system                               *
  990. *                                                                              *
  991. *******************************************************************************/
  992. MRESULT EXPENTRY LocCapDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  993. {
  994.   WRTLOCATORDEVINFO lcInfo;
  995.   CHAR cbuffer[MAXCBUFFER];
  996.   ULONG ulLocatorID;
  997.   ULONG ulLocTmp;
  998.   WNDPARAMS comboprams;
  999.   APIRET irc;
  1000.    switch(msg)
  1001.    {
  1002.       case WM_INITDLG:
  1003.  
  1004.             /******************************************************************/
  1005.             /*  Find out how many locators the system has by querying the     */
  1006.             /*  locator capabilities API with ulLocatorID = 0L.               */
  1007.             /*  The API will write the number of locator IDs in the system in */
  1008.             /*  the variable ulLocatorID.                                     */
  1009.             /******************************************************************/
  1010.             ulLocatorID = 0L;
  1011.             irc = WrtQueryLocatorCaps ( &ulLocatorID, NULL );
  1012.             if ( irc != WRT_NO_ERROR )
  1013.             {
  1014.               /****************************************************************/
  1015.               /* ERROR from API                                               */
  1016.               /****************************************************************/
  1017.               DisplayError ( hwnd, irc );
  1018.             } else
  1019.             {
  1020.               /****************************************************************/
  1021.               /* Find out if locator are greater than zero                    */
  1022.               /****************************************************************/
  1023.               if ( ulLocatorID == 0L )
  1024.               {
  1025.                 WinMessageBox( HWND_DESKTOP,
  1026.                                 hwnd,
  1027.                                 "WrtQueryLocatorCaps return 0 locators",
  1028.                                 NULL, 1, MB_OK );
  1029.               } else
  1030.               {
  1031.                 /* Got some locator to display */
  1032.                 hwndCombo1 = WinWindowFromID ( hwnd, wrtelc23 );
  1033.                 /**************************************************************/
  1034.                 /* Display the Capabilities for all the locator in the system */
  1035.                 /**************************************************************/
  1036.  
  1037.                 for ( ulLocTmp = 1L ; ulLocTmp <= ulLocatorID ; ulLocTmp++ )
  1038.                 {
  1039.                   /************************************************************/
  1040.                   /* The cbStructureSize variable in the WRTLOCATORDEVINFO    */
  1041.                   /* structure must be initialize to the size of the          */
  1042.                   /* WRTLOCATORDEVINFO structure before querying the locator  */
  1043.                   /* capabilities.                                            */
  1044.                   /************************************************************/
  1045.                   lcInfo.cbStructSize = sizeof ( lcInfo );
  1046.  
  1047.                   /************************************************************/
  1048.                   /* ulLocTmp    variable has the ID of the locator that you  */
  1049.                   /* want to query                                            */
  1050.                   /************************************************************/
  1051.                   irc = WrtQueryLocatorCaps ( &ulLocTmp, &lcInfo );
  1052.  
  1053.                   if ( irc == WRT_NO_ERROR )
  1054.                   {
  1055.                     /**********************************************************/
  1056.                     /*  good return from API                                  */
  1057.                     /**********************************************************/
  1058.                     sprintf ( cbuffer, "%s %s",
  1059.                               lcInfo.pszDriverName, lcInfo.pszDeviceName );
  1060.                     index1 = (SHORT) WinSendMsg ( hwndCombo1, LM_INSERTITEM,
  1061.                                       MPFROMSHORT ( LIT_END ),
  1062.                                       MPFROMP ( cbuffer ) );
  1063.                   } else
  1064.                   {
  1065.                     /**********************************************************/
  1066.                     /* ERROR from API                                         */
  1067.                     /**********************************************************/
  1068.                     DisplayError ( hwnd, irc );
  1069.                   } /* endif */
  1070.                 } /* endfor */
  1071.                 /**************************************************************/
  1072.                 /* Set the last  item on the list at the top.                 */
  1073.                 /**************************************************************/
  1074.                 WinSendMsg ( hwndCombo1, LM_SETTOPINDEX,
  1075.                              MPFROMSHORT ( index1 ), 0 );
  1076.  
  1077.                 comboprams.fsStatus = WPM_TEXT;               /* change window text */
  1078.                 comboprams.cchText = sizeof ( cbuffer );      /* text size          */
  1079.                 comboprams.pszText = cbuffer ;                /* text to display    */
  1080.                 WinSendMsg ( hwndCombo1, WM_SETWINDOWPARAMS, &comboprams, 0 );
  1081.  
  1082.                 disp_loccaps ( hwnd, &lcInfo );
  1083.  
  1084.               } /* endif */ /* end of display locator information */
  1085.             } /* endif */
  1086.           /******************************************************************/
  1087.  
  1088.         return(FALSE);
  1089.      case WM_CONTROL:
  1090.         switch ( SHORT2FROMMP (mp1) )
  1091.         {
  1092.            case CBN_ENTER:
  1093.              /*****************************************************************/
  1094.              /* find the index of the selected item                           */
  1095.              /*****************************************************************/
  1096.              index1 = (SHORT)WinSendMsg ( hwndCombo1, LM_QUERYSELECTION, 0L, 0L );
  1097.              if ( index1 != LIT_NONE )
  1098.              {
  1099.                ulLocTmp = (ULONG)(index1 + 1L);
  1100.                lcInfo.cbStructSize = sizeof ( lcInfo );
  1101.                irc = WrtQueryLocatorCaps ( &ulLocTmp, &lcInfo );
  1102.                if ( irc == WRT_NO_ERROR )
  1103.                {
  1104.                  disp_loccaps ( hwnd, &lcInfo );
  1105.                } /* endif */
  1106.              } /* endif */
  1107.         } /* endswitch */
  1108.         return ( FALSE );
  1109.      case WM_COMMAND:
  1110.         switch ( SHORT1FROMMP ( mp1 ) )
  1111.         {
  1112.            case EXIT:
  1113.                WinDismissDlg ( hwnd, EXIT );
  1114.         } /* endswitch */
  1115.         return ( FALSE );
  1116.    }
  1117.    return(WinDefDlgProc(hwnd, msg, mp1, mp2));
  1118. }
  1119. /*******************************************************************************
  1120. *                                                                              *
  1121. * Function Name: DisCapDlgProc                                                 *
  1122. *                                                                              *
  1123. * Description :                                                                *
  1124. *                                                                              *
  1125. *   Displays the capabilities of the Displays                                  *
  1126. *                                                                              *
  1127. * Input:                                                                       *
  1128. *                                                                              *
  1129. * Output: Display the capabilities of the system                               *
  1130. *                                                                              *
  1131. *******************************************************************************/
  1132. MRESULT EXPENTRY DisCapDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  1133. {
  1134.   WRTDISPLAYDEVINFO dcInfo;
  1135.   CHAR cbuffer[MAXCBUFFER];
  1136.   ULONG ulDisplayID;
  1137.   ULONG ulDisTmp;
  1138.   WNDPARAMS comboprams;
  1139.   APIRET irc;
  1140.    switch(msg)
  1141.    {
  1142.         case WM_INITDLG:
  1143.           /******************************************************************/
  1144.           /*  Find out how many Displays the system has by querying the     */
  1145.           /*  Display capabilities API with ulDisplayID = 0L.               */
  1146.           /*  The API will write the number of Display IDs in the system in */
  1147.           /*  the variable ulDisplayID.                                     */
  1148.           /******************************************************************/
  1149.           ulDisplayID = 0L;
  1150.           irc = WrtQueryDisplayCaps ( &ulDisplayID, NULL );
  1151.           if ( irc != WRT_NO_ERROR )
  1152.           {
  1153.             /****************************************************************/
  1154.             /* ERROR from API                                               */
  1155.             /****************************************************************/
  1156.             DisplayError ( hwnd, irc );
  1157.           } else
  1158.           {
  1159.             /****************************************************************/
  1160.             /* Find out if there are greater than zero display.             */
  1161.             /****************************************************************/
  1162.             if ( ulDisplayID == 0L)
  1163.             {
  1164.               WinMessageBox( HWND_DESKTOP,
  1165.                               hwnd,
  1166.                               "WrtQueryDisplayCaps return 0 displays",
  1167.                               NULL, 1, MB_OK );
  1168.             } else
  1169.             {
  1170.               /**************************************************************/
  1171.               /* Got some locator to display                                */
  1172.               /**************************************************************/
  1173.               hwndCombo1 = WinWindowFromID ( hwnd, wrtelc10 );
  1174.               for ( ulDisTmp= 1L; ulDisTmp <= ulDisplayID; ulDisTmp++ )
  1175.               {
  1176.                 /************************************************************/
  1177.                 /* The cbStructureSize variable in the WRTDISPLAYDEVINFO    */
  1178.                 /* structure must be initialize to the size of the          */
  1179.                 /* WRTDISPLAYDEVINFO structure before querying the Display  */
  1180.                 /* capabilities.                                            */
  1181.                 /************************************************************/
  1182.                 dcInfo.cbStructSize = sizeof ( dcInfo );
  1183.  
  1184.                 /************************************************************/
  1185.                 /* ulDisTmp    variable has the ID of the Display that you  */
  1186.                 /* want to query                                            */
  1187.                 /************************************************************/
  1188.                 irc = WrtQueryDisplayCaps ( &ulDisTmp, &dcInfo );
  1189.  
  1190.                 if ( irc == WRT_NO_ERROR )
  1191.                 {
  1192.                   /**********************************************************/
  1193.                   /*  good return from API                                  */
  1194.                   /**********************************************************/
  1195.                   sprintf ( cbuffer, "%s %s",
  1196.                             dcInfo.pszDriverName, dcInfo.pszDeviceName );
  1197.                   index1 = (SHORT) WinSendMsg ( hwndCombo1, LM_INSERTITEM,
  1198.                                     MPFROMSHORT ( LIT_END ),
  1199.                                     MPFROMP ( cbuffer ) );
  1200.                 } else
  1201.                 {
  1202.                   /**********************************************************/
  1203.                   /* ERROR from API                                         */
  1204.                   /**********************************************************/
  1205.                   DisplayError ( hwnd, irc );
  1206.                 } /* endif */
  1207.               } /* endfor */
  1208.               /**************************************************************/
  1209.               /* Set the last  item on the list at the top.                 */
  1210.               /**************************************************************/
  1211.               WinSendMsg ( hwndCombo1, LM_SETTOPINDEX,
  1212.                            MPFROMSHORT ( index1 ), 0 );
  1213.  
  1214.               comboprams.fsStatus = WPM_TEXT;               /* change window text */
  1215.               comboprams.cchText = sizeof ( cbuffer );      /* text size          */
  1216.               comboprams.pszText = cbuffer ;                /* text to display    */
  1217.               WinSendMsg ( hwndCombo1, WM_SETWINDOWPARAMS, &comboprams, 0 );
  1218.  
  1219.               disp_discaps ( hwnd, &dcInfo  );
  1220.             } /* endif */
  1221.           } /* endif */
  1222.  
  1223.         return(FALSE);
  1224.      case WM_CONTROL:
  1225.         switch ( SHORT2FROMMP (mp1) )
  1226.         {
  1227.            case CBN_ENTER:
  1228.              /*****************************************************************/
  1229.              /* find the index of the selected item                           */
  1230.              /*****************************************************************/
  1231.              index1 = (SHORT)WinSendMsg ( hwndCombo1, LM_QUERYSELECTION, 0L, 0L );
  1232.              if ( index1 != LIT_NONE )
  1233.              {
  1234.                ulDisTmp = (ULONG)(index1 + 1L);
  1235.                dcInfo.cbStructSize = sizeof ( dcInfo );
  1236.                irc = WrtQueryDisplayCaps ( &ulDisTmp, &dcInfo );
  1237.                if ( irc == WRT_NO_ERROR )
  1238.                {
  1239.                  disp_discaps ( hwnd, &dcInfo );
  1240.                } /* endif */
  1241.              } /* endif */
  1242.         } /* endswitch */
  1243.         return ( FALSE );
  1244.      case WM_COMMAND:
  1245.         switch ( SHORT1FROMMP ( mp1 ) )
  1246.         {
  1247.            case EXIT:
  1248.                WinDismissDlg ( hwnd, EXIT );
  1249.         } /* endswitch */
  1250.         return ( FALSE );
  1251.    }
  1252.    return(WinDefDlgProc(hwnd, msg, mp1, mp2));
  1253. }
  1254. /*******************************************************************************
  1255. *                                                                              *
  1256. * Function Name: SysCapDlgProc                                                 *
  1257. *                                                                              *
  1258. * Description :                                                                *
  1259. *                                                                              *
  1260. *   Displays the capabilities of the system.                                   *
  1261. *                                                                              *
  1262. * Input:                                                                       *
  1263. *                                                                              *
  1264. * Output: Display the capabilities of the system                               *
  1265. *                                                                              *
  1266. *******************************************************************************/
  1267. MRESULT EXPENTRY SysCapDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  1268. {
  1269.   PWRTSYSTEMINFO pscInfo;
  1270.   CHAR cbuffer[MAXCBUFFER];
  1271.  
  1272.    switch(msg)
  1273.    {
  1274.         case WM_INITDLG:
  1275.           pscInfo = PVOIDFROMMP ( mp2 );
  1276.  
  1277.           sprintf ( cbuffer, "%ld", pscInfo->cbStructSize );
  1278.           WinSetDlgItemText ( hwnd, wrtelc01, cbuffer );
  1279.  
  1280.           sprintf ( cbuffer, "%ld", pscInfo->ulDisplayXPels );
  1281.           WinSetDlgItemText ( hwnd, wrtelc02, cbuffer );
  1282.  
  1283.           sprintf ( cbuffer, "%ld", pscInfo->ulDisplayYPels );
  1284.           WinSetDlgItemText ( hwnd, wrtelc03, cbuffer );
  1285.  
  1286.           sprintf ( cbuffer, "%ld", pscInfo->ulDisplayXRes );
  1287.           WinSetDlgItemText ( hwnd, wrtelc04, cbuffer );
  1288.  
  1289.           sprintf ( cbuffer, "%ld", pscInfo->ulDisplayYRes );
  1290.           WinSetDlgItemText ( hwnd, wrtelc05, cbuffer );
  1291.  
  1292.           sprintf ( cbuffer, "%ld", pscInfo->ulNumDrivers );
  1293.           WinSetDlgItemText ( hwnd, wrtelc06, cbuffer );
  1294.  
  1295.           sprintf ( cbuffer, "%ld", pscInfo->ulNumLocators );
  1296.           WinSetDlgItemText ( hwnd, wrtelc07, cbuffer );
  1297.  
  1298.           sprintf ( cbuffer, "%ld", pscInfo->ulNumButtons );
  1299.           WinSetDlgItemText ( hwnd, wrtelc08, cbuffer );
  1300.  
  1301.           sprintf ( cbuffer, "%ld", pscInfo->ulNumDisplays );
  1302.           WinSetDlgItemText ( hwnd, wrtelc09, cbuffer );
  1303.  
  1304.         return(FALSE);
  1305.      case WM_COMMAND:
  1306.         switch ( SHORT1FROMMP ( mp1 ) )
  1307.         {
  1308.            case EXIT:
  1309.                WinDismissDlg ( hwnd, EXIT );
  1310.         } /* endswitch */
  1311.         return ( FALSE );
  1312.    }
  1313.    return(WinDefDlgProc(hwnd, msg, mp1, mp2));
  1314. }
  1315.  
  1316. /*******************************************************************************
  1317. *                                                                              *
  1318. * Function Name: AUXPNTDlgProc                                                 *
  1319. *                                                                              *
  1320. * Description :                                                                *
  1321. *                                                                              *
  1322. *   Displays the AUX. Point Data.                                              *
  1323. *                                                                              *
  1324. * Input:                                                                       *
  1325. *                                                                              *
  1326. * Output: Display the AUX. Point Data                                          *
  1327. *                                                                              *
  1328. *******************************************************************************/
  1329. MRESULT EXPENTRY AUXPNTDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  1330. {
  1331.   CHAR cbuffer[MAXCBUFFER];
  1332.   INT i;
  1333.  
  1334.    switch(msg)
  1335.    {
  1336.           case WM_INITDLG:
  1337.              sprintf ( cbuffer, "%d", apdExtra.cbStructSize );
  1338.              WinSetDlgItemText ( hwnd, wrtelc01, cbuffer );
  1339.  
  1340.               /****************************************************************/
  1341.               /* The display information is being done first to test what the */
  1342.               /* dirver is returning. On a real application you would not     */
  1343.               /* care to look at the variable if the ValidityFlags bit was    */
  1344.               /* off. The driver should be returning 0 on unsed variables.    */
  1345.               /****************************************************************/
  1346.               sprintf ( cbuffer, "%ld", apdExtra.ulTimestamp );
  1347.               WinSetDlgItemText ( hwnd, wrtelc02, cbuffer );
  1348.             if ( !(ldiarr[ulocindx].ulValidityFlags & ADF_TIMESTAMP) )
  1349.             {
  1350.                WinEnableWindow ( (WinWindowFromID ( hwnd , wrtlc02 )), FALSE );
  1351.                WinEnableWindow ( (WinWindowFromID ( hwnd , wrtelc02 )), FALSE );
  1352.             } /* endif */
  1353.  
  1354.              sprintf ( cbuffer, "%#x", apdExtra.usFlags );
  1355.              WinSetDlgItemText ( hwnd, wrtelc03, cbuffer );
  1356.             if ( !(ldiarr[ulocindx].ulValidityFlags & ADF_FLAGS) )
  1357.             {
  1358.                WinEnableWindow ( (WinWindowFromID ( hwnd , wrtlc03 )), FALSE );
  1359.                WinEnableWindow ( (WinWindowFromID ( hwnd , wrtelc03 )), FALSE );
  1360.             } /* endif */
  1361.  
  1362.              sprintf ( cbuffer, "%d", apdExtra.usUser );
  1363.              WinSetDlgItemText ( hwnd, wrtelc04, cbuffer );
  1364.             if ( !(ldiarr[ulocindx].ulValidityFlags & ADF_USER) )
  1365.             {
  1366.                WinEnableWindow ( (WinWindowFromID ( hwnd , wrtlc04 )), FALSE );
  1367.                WinEnableWindow ( (WinWindowFromID ( hwnd , wrtelc04 )), FALSE );
  1368.             } /* endif */
  1369.  
  1370.              sprintf ( cbuffer, "%d", apdExtra.sScrZ );
  1371.              WinSetDlgItemText ( hwnd, wrtelc05, cbuffer );
  1372.             if ( !(ldiarr[ulocindx].ulValidityFlags & ADF_SCREENZ) )
  1373.             {
  1374.                WinEnableWindow ( (WinWindowFromID ( hwnd , wrtlc05 )), FALSE );
  1375.                WinEnableWindow ( (WinWindowFromID ( hwnd , wrtelc05 )), FALSE );
  1376.             } /* endif */
  1377.  
  1378.              sprintf ( cbuffer, "%d", apdExtra.sDevZ );
  1379.              WinSetDlgItemText ( hwnd, wrtelc06, cbuffer );
  1380.             if ( !(ldiarr[ulocindx].ulValidityFlags & ADF_DEVZ) )
  1381.             {
  1382.                WinEnableWindow ( (WinWindowFromID ( hwnd , wrtlc06 )), FALSE );
  1383.                WinEnableWindow ( (WinWindowFromID ( hwnd , wrtelc06 )), FALSE );
  1384.             } /* endif */
  1385.  
  1386.              sprintf ( cbuffer, "%d", apdExtra.sAngle );
  1387.              WinSetDlgItemText ( hwnd, wrtelc07, cbuffer );
  1388.             if ( !(ldiarr[ulocindx].ulValidityFlags & ADF_ANGLE) )
  1389.             {
  1390.                WinEnableWindow ( (WinWindowFromID ( hwnd , wrtlc07 )), FALSE );
  1391.                WinEnableWindow ( (WinWindowFromID ( hwnd , wrtelc07 )), FALSE );
  1392.             } /* endif */
  1393.  
  1394.              sprintf ( cbuffer, "%d", apdExtra.sRotation );
  1395.              WinSetDlgItemText ( hwnd, wrtelc08, cbuffer );
  1396.             if ( !(ldiarr[ulocindx].ulValidityFlags & ADF_ROTATION) )
  1397.             {
  1398.                WinEnableWindow ( (WinWindowFromID ( hwnd , wrtlc08 )), FALSE );
  1399.                WinEnableWindow ( (WinWindowFromID ( hwnd , wrtelc08 )), FALSE );
  1400.             } /* endif */
  1401.  
  1402.              sprintf ( cbuffer, "%#x", apdExtra.usButton );
  1403.              WinSetDlgItemText ( hwnd, wrtelc09, cbuffer );
  1404.             if ( !(ldiarr[ulocindx].ulValidityFlags & ADF_BUTTON) )
  1405.             {
  1406.                WinEnableWindow ( (WinWindowFromID ( hwnd , wrtlc09 )), FALSE );
  1407.                WinEnableWindow ( (WinWindowFromID ( hwnd , wrtelc09 )), FALSE );
  1408.             } /* endif */
  1409.  
  1410.             if ( ldiarr[ulocindx].ulValidityFlags & ADF_OEM )
  1411.             {
  1412.              /* adf_oem_count_mask is not supported in release 1 */
  1413.              for ( i= 0; i < ldiarr[ulocindx].ulOEMValidityCnt; i++ )
  1414.              {
  1415.                 sprintf ( cbuffer, "OEM[%i]= %li", i, apdExtra.OEM[i] );
  1416.                 WinSendDlgItemMsg(hwnd,
  1417.                                    wrtelc10,
  1418.                                    LM_INSERTITEM,
  1419.                                    MPFROM2SHORT(LIT_END, 0),
  1420.                                    MPFROMP( cbuffer ) );
  1421.  
  1422.              } /* endfor */
  1423.             } else
  1424.             {
  1425.                WinEnableWindow ( (WinWindowFromID ( hwnd , wrtlc10 )), FALSE );
  1426.             } /* endif */
  1427.         return(FALSE);
  1428.      case WM_COMMAND:
  1429.         switch ( SHORT1FROMMP ( mp1 ) )
  1430.         {
  1431.            case EXIT:
  1432.                btoggle_aux = FALSE;
  1433.                WinSendDlgItemMsg (
  1434.                                  hwndFrame
  1435.                                 ,(ULONG) FID_MENU
  1436.                                 ,(ULONG) MM_SETITEMATTR
  1437.                                 ,MPFROM2SHORT ( ID_AUX, TRUE )
  1438.                                 ,MPFROM2SHORT ( MIA_CHECKED, 0 )
  1439.                                 );
  1440.                AUXTEST = 0;
  1441.                WinDismissDlg ( hwnd, EXIT );
  1442.         } /* endswitch */
  1443.         return ( FALSE );
  1444.    }
  1445.    return(WinDefDlgProc(hwnd, msg, mp1, mp2));
  1446. }
  1447.  
  1448. /*******************************************************************************
  1449. *                                                                              *
  1450. * Function Name: EVNTDTDlgProc                                                 *
  1451. *                                                                              *
  1452. * Description :                                                                *
  1453. *                                                                              *
  1454. *   Displays the Event Data.                                                   *
  1455. *                                                                              *
  1456. * Input:                                                                       *
  1457. *                                                                              *
  1458. * Output: Display the Event Data                                               *
  1459. *                                                                              *
  1460. *******************************************************************************/
  1461. MRESULT EXPENTRY EVNTDTDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  1462. {
  1463.   CHAR cbuffer[MAXCBUFFER];
  1464.  
  1465.    switch(msg)
  1466.    {
  1467.         case WM_INITDLG:
  1468.              sprintf ( cbuffer, "%d", edInfo.cbStructSize );
  1469.              WinSetDlgItemText ( hwnd, wrtelc01, cbuffer );
  1470.  
  1471.              sprintf ( cbuffer, "%#x", edInfo.usKCFlags );
  1472.              WinSetDlgItemText ( hwnd, wrtelc02, cbuffer );
  1473.  
  1474.              sprintf ( cbuffer, "%#x", edInfo.usHitTest );
  1475.              WinSetDlgItemText ( hwnd, wrtelc03, cbuffer );
  1476.  
  1477.              sprintf ( cbuffer, "%#x", edInfo.flEventStatus );
  1478.              WinSetDlgItemText ( hwnd, wrtelc04, cbuffer );
  1479.  
  1480.              sprintf ( cbuffer, "%ld", edInfo.ptlDisplay.x );
  1481.              WinSetDlgItemText ( hwnd, wrtelc05, cbuffer );
  1482.              sprintf ( cbuffer, "%ld", edInfo.ptlDisplay.y );
  1483.              WinSetDlgItemText ( hwnd, wrtelc06, cbuffer );
  1484.  
  1485.              sprintf ( cbuffer, "%ld", edInfo.ptlSensor.x );
  1486.              WinSetDlgItemText ( hwnd, wrtelc07, cbuffer );
  1487.              sprintf ( cbuffer, "%ld", edInfo.ptlSensor.y  );
  1488.              WinSetDlgItemText ( hwnd, wrtelc08, cbuffer );
  1489.  
  1490.              sprintf ( cbuffer, "%ld", edInfo.ptlStandard.x );
  1491.              WinSetDlgItemText ( hwnd, wrtelc09, cbuffer );
  1492.              sprintf ( cbuffer, "%ld", edInfo.ptlStandard.y  );
  1493.              WinSetDlgItemText ( hwnd, wrtelc10, cbuffer );
  1494.  
  1495.              sprintf ( cbuffer, "%ld", edInfo.ulStrokeSeq  );
  1496.              WinSetDlgItemText ( hwnd, wrtelc11, cbuffer );
  1497.  
  1498.              sprintf ( cbuffer, "%ld", edInfo.ulStrokeSize );
  1499.              WinSetDlgItemText ( hwnd, wrtelc12, cbuffer );
  1500.  
  1501.              sprintf ( cbuffer, "%ld", edInfo.ulLocatorID  );
  1502.              WinSetDlgItemText ( hwnd, wrtelc13, cbuffer );
  1503.  
  1504.              sprintf ( cbuffer, "%ld", edInfo.ulLocatorType  );
  1505.              WinSetDlgItemText ( hwnd, wrtelc14, cbuffer );
  1506.  
  1507.              sprintf ( cbuffer, "%#lx", edInfo.ulLocatorFlags  );
  1508.              WinSetDlgItemText ( hwnd, wrtelc15, cbuffer );
  1509.  
  1510.              sprintf ( cbuffer, "%#lx", edInfo.ulValidityFlags );
  1511.              WinSetDlgItemText ( hwnd, wrtelc16, cbuffer );
  1512.  
  1513.              sprintf ( cbuffer, "%#lx", edInfo.ulButtonStatus  );
  1514.              WinSetDlgItemText ( hwnd, wrtelc17, cbuffer );
  1515.  
  1516.              sprintf ( cbuffer, "%ld", edInfo.hwndUnderPtr );
  1517.              WinSetDlgItemText ( hwnd, wrtelc18, cbuffer );
  1518.         return(FALSE);
  1519.      case WM_COMMAND:
  1520.         switch ( SHORT1FROMMP ( mp1 ) )
  1521.         {
  1522.            case EXIT:
  1523.                btoggle_event = FALSE;
  1524.                WinSendDlgItemMsg (
  1525.                                  hwndFrame
  1526.                                 ,(ULONG) FID_MENU
  1527.                                 ,(ULONG) MM_SETITEMATTR
  1528.                                 ,MPFROM2SHORT ( ID_EVENT, TRUE )
  1529.                                 ,MPFROM2SHORT ( MIA_CHECKED, 0 )
  1530.                                 );
  1531.                EVENTTEST = 0;
  1532.                WinDismissDlg ( hwnd, EXIT );
  1533.         } /* endswitch */
  1534.         return ( FALSE );
  1535.    }
  1536.    return(WinDefDlgProc(hwnd, msg, mp1, mp2));
  1537. }
  1538.  
  1539. /*******************************************************************************
  1540. *                                                                              *
  1541. * Function Name: BACKLTDlgProc                                                 *
  1542. *                                                                              *
  1543. * Description :                                                                *
  1544. *                                                                              *
  1545. *   Let the user turn ON or OFF the backlight of a specific display.           *
  1546. *                                                                              *
  1547. * Input:                                                                       *
  1548. *                                                                              *
  1549. * Output: Let the user turn ON or OFF the backlight of a specific display.     *
  1550. *                                                                              *
  1551. *******************************************************************************/
  1552. MRESULT EXPENTRY BACKLTDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  1553. {
  1554.   CHAR cbuffer[MAXCBUFFER];
  1555.   WRTDISPLAYDEVINFO dcInfo;            /* Display capabilities structure      */
  1556.   WNDPARAMS comboprams;
  1557.   INT i;
  1558.   APIRET irc;
  1559.  
  1560.    switch(msg)
  1561.    {
  1562.      case WM_INITDLG:
  1563.           /********************************************************************/
  1564.           /* There should be a valid display with a backlight support since   */
  1565.           /* the backlight menu option would be disable at program srart up   */
  1566.           /* you would not be here.                                           */
  1567.           /********************************************************************/
  1568.           i = 0;
  1569.           hwndCombo1 = WinWindowFromID ( hwnd , wrtelc03 );
  1570.           for ( ; ulbacklight_displayID[i] != 0L; i++ )
  1571.           {
  1572.             dcInfo.cbStructSize = sizeof ( dcInfo );
  1573.  
  1574.             /******************************************************************/
  1575.             /* ulbacklight_displayID[i] variable has the ID of the            */
  1576.             /* Display that you want to query                                 */
  1577.             /******************************************************************/
  1578.             irc = WrtQueryDisplayCaps ( &ulbacklight_displayID[i], &dcInfo );
  1579.  
  1580.             if ( irc == WRT_NO_ERROR )
  1581.             {
  1582.               sprintf ( cbuffer, "%s %s",
  1583.                         dcInfo.pszDriverName, dcInfo.pszDeviceName );
  1584.               /****************************************************************/
  1585.               /* initialize the entries in the list box                       */
  1586.               /****************************************************************/
  1587.               index1 = (SHORT) WinSendMsg ( hwndCombo1, LM_INSERTITEM,
  1588.                                      MPFROMSHORT ( LIT_END ),
  1589.                                      MPFROMP ( cbuffer ) );
  1590.             } /* endif */
  1591.           } /* endfor */
  1592.           /********************************************************************/
  1593.           /* Set the last  item on the list at the top.                       */
  1594.           /********************************************************************/
  1595.           WinSendMsg ( hwndCombo1, LM_SETTOPINDEX, MPFROMSHORT ( index1 ), 0 );
  1596.  
  1597.           comboprams.fsStatus = WPM_TEXT;               /* change window text */
  1598.           comboprams.cchText = sizeof ( cbuffer );      /* text size          */
  1599.           comboprams.pszText = cbuffer ;                /* text to display    */
  1600.           WinSendMsg ( hwndCombo1, WM_SETWINDOWPARAMS, &comboprams, 0 );
  1601.  
  1602.           /********************************************************************/
  1603.           /* Turn the backlight on and mark the ON radio button               */
  1604.           /********************************************************************/
  1605.           WinSendMsg ( WinWindowFromID( hwnd, wrtelc01), BM_CLICK, 0L, 0L );
  1606.         return ( FALSE );
  1607.      case WM_CONTROL:
  1608.        switch ( SHORT2FROMMP ( mp1 ) )
  1609.        {
  1610.          case CBN_ENTER:
  1611.            /*******************************************************************/
  1612.            /* find the index of the selected item                             */
  1613.            /*******************************************************************/
  1614.            index1 = (SHORT)WinSendMsg ( hwndCombo1, LM_QUERYSELECTION, 0L, 0L );
  1615.            if ( index1 != LIT_NONE )
  1616.            {
  1617.              dcInfo.cbStructSize = sizeof ( dcInfo );
  1618.              irc = WrtQueryDisplayCaps ( &ulbacklight_displayID[index1],
  1619.                                          &dcInfo );
  1620.              if ( irc == WRT_NO_ERROR )
  1621.              {
  1622.                WinSendMsg ( WinWindowFromID( hwnd, wrtelc01),
  1623.                             BM_CLICK, 0L, 0L );
  1624.              } /* endif */
  1625.            } /* endif */
  1626.          break;
  1627.          case BN_CLICKED:
  1628.               switch ( SHORT1FROMMP(mp1) )
  1629.               {
  1630.            case wrtelc01:
  1631.                     irc = WrtControlDisplayBacklight ( CDB_LIGHT_ON,
  1632.                                                ulbacklight_displayID[index1] );
  1633.                     if ( irc != WRT_NO_ERROR )
  1634.                     {
  1635.                       DisplayError ( hwnd, irc );
  1636.                     } /* endif */
  1637.                 break;
  1638.                 case wrtelc02:
  1639.                     irc = WrtControlDisplayBacklight ( CDB_LIGHT_OFF,
  1640.                                                ulbacklight_displayID[index1] );
  1641.                     if ( irc != WRT_NO_ERROR )
  1642.                     {
  1643.                       DisplayError ( hwnd, irc );
  1644.                     } /* endif */
  1645.                 break;
  1646.               } /* endswitch */
  1647.          break;
  1648.        } /* endswitch */
  1649.        return ( FALSE );
  1650.      case WM_COMMAND:
  1651.         switch ( SHORT1FROMMP ( mp1 ) )
  1652.         {
  1653.            case EXIT:
  1654.                WinDismissDlg ( hwnd, EXIT );
  1655.         } /* endswitch */
  1656.         return ( FALSE );
  1657.    } /* endswitch */
  1658.    return(WinDefDlgProc(hwnd, msg, mp1, mp2));
  1659. }
  1660. /******************************************************************************/
  1661. /*  Error reporting functions                                                 */
  1662. /******************************************************************************/
  1663. VOID DisplayError ( HWND hwnd, APIRET errcode )
  1664. {
  1665.    CHAR errbuff[MAXCBUFFER];
  1666.    CHAR loadbuff[MAXCBUFFER];
  1667.  
  1668.    if ( errcode != WRT_NO_ERROR )
  1669.    {
  1670.      switch ( errcode ) {
  1671.      case WRTERR_INVALID_BUTTON_ID:
  1672.      case WRTERR_INVALID_POINTER:
  1673.      case WRTERR_INVALID_BUFFER:
  1674.      case WRTERR_STRUCT_NOT_INIT:
  1675.      case WRTERR_NOT_ACTIVE:
  1676.      case WRTERR_INVALID_LOCATOR_ID:
  1677.      case WRTERR_INVALID_DISPLAY_ID:
  1678.      case WRTERR_INVALID_HWND:
  1679.      case WRTERR_WRITE_FAILED:
  1680.      case WRTERR_INVALID_PARM:
  1681.      case WRTERR_INVALID_ID:
  1682.      case WRTERR_PARM_OUT_OF_RANGE:
  1683.      case WRTERR_MORE_NAMES_AVAIL:
  1684.      case WRTERR_STROKE_INVALID:
  1685.         WinLoadString (
  1686.                         habMain,
  1687.                         NULLHANDLE,
  1688.                         errcode,
  1689.                         MAXCBUFFER,
  1690.                         errbuff
  1691.                         );
  1692.         break;
  1693.      default:
  1694.         WinLoadString (
  1695.                         habMain,
  1696.                         NULLHANDLE,
  1697.                         IDMSG_UNKOWN,
  1698.                         MAXCBUFFER,
  1699.                         loadbuff
  1700.                         );
  1701.         sprintf ( errbuff, loadbuff, errcode );
  1702.        break;
  1703.      } /* endswitch */
  1704.  
  1705.      WinMessageBox( HWND_DESKTOP,
  1706.                     hwnd,
  1707.                     errbuff,
  1708.                     NULL, 1, MB_OK );
  1709.    } /* endif */
  1710. }
  1711.  
  1712. VOID init_sysval( HWND hwnd, INT r_sw )
  1713. {
  1714.   CHAR cbuffer[MAXCBUFFER];
  1715.   WNDPARAMS comboprams;
  1716.   INT       i;
  1717.  
  1718.   /**********************************************************************/
  1719.   /* initialize the entries in the list box                             */
  1720.   /**********************************************************************/
  1721.   hwndCombo1 = WinWindowFromID ( hwnd , wrtelc01 );
  1722.  
  1723.   for ( i= 1; i < (QSVALUESIZE - 2); i++ )
  1724.   {
  1725.         index = (SHORT) WinSendMsg ( hwndCombo1, LM_INSERTITEM,
  1726.                        MPFROMSHORT ( LIT_END ),
  1727.                        MPFROMP ( qsvalue[i].valname ) );
  1728.   }
  1729.   /**********************************************************************/
  1730.   /* Set the first item on the list at the top.                         */
  1731.   /**********************************************************************/
  1732.   index = 0;                            /* intialize the index to zeror */
  1733.   WinSendMsg ( hwndCombo1, LM_SETTOPINDEX, MPFROMSHORT ( index ), 0 );
  1734.  
  1735.   comboprams.fsStatus = WPM_TEXT;      /* change window text            */
  1736.   comboprams.cchText = sizeof ( qsvalue[index+1].valname );/* text size*/
  1737.   comboprams.pszText = qsvalue[index+1].valname;  /* text to display   */
  1738.   WinSendMsg ( hwndCombo1, WM_SETWINDOWPARAMS,
  1739.                &comboprams, 0 );
  1740.   /**********************************************************************/
  1741.   /* query the system value to set the spin box.                        */
  1742.   /**********************************************************************/
  1743.   startvalue = WrtQuerySysValue ( HWND_DESKTOP,
  1744.                              qsvalue[index+1].valueid );
  1745.  
  1746.   /**********************************************************************/
  1747.   /* initialize all the spin button to the system value that where      */
  1748.   /* query. If the query reutrn an error (WRTERR_INVALID_PARM) SET      */
  1749.   /* the spin button to zerro.                                          */
  1750.   /**********************************************************************/
  1751.   if ( startvalue == WRTERR_INVALID_PARM )
  1752.   {
  1753.     startvalue = 0L;
  1754.   } /* endif */
  1755.   if ( r_sw )
  1756.   {            /* r-sw == 1 is a read */
  1757.     /**********************************************************************/
  1758.     /* Set the entry field value to the value that was query from         */
  1759.     /* the system.                                                        */
  1760.     /**********************************************************************/
  1761.     sprintf ( cbuffer, "%li", startvalue);
  1762.     WinSetDlgItemText ( hwnd, wrtelc02, cbuffer );
  1763.   } else       /* r_sw == 0is a set or write */
  1764.   {
  1765.     /************************************************************/
  1766.     /* check to see if the value can be set to 0 (disabled)     */
  1767.     /************************************************************/
  1768.     if ( qsvalue[index+1].disable == 1 )
  1769.     {
  1770.       WinSendMsg ( WinWindowFromID ( hwnd, wrtelc02 ),
  1771.                   SPBM_SETLIMITS,
  1772.                   MPFROMLONG ( qsvalue[index+1].valuemax ),/* MAX*/
  1773.                   MPFROMLONG ( 0L ) /* MIN*/
  1774.                   );
  1775.     } else
  1776.     {
  1777.       WinSendMsg ( WinWindowFromID ( hwnd, wrtelc02 ),
  1778.                   SPBM_SETLIMITS,
  1779.                   MPFROMLONG ( qsvalue[index+1].valuemax ),      /* MAX    */
  1780.                   MPFROMLONG ( qsvalue[index+1].valuemin )       /* MIN    */
  1781.                   );
  1782.     } /* endif */
  1783.     /**********************************************************************/
  1784.     /* Set the spin button value to the value that was query from         */
  1785.     /* the system.                                                        */
  1786.     /**********************************************************************/
  1787.     WinSendMsg ( WinWindowFromID ( hwnd, wrtelc02 ),
  1788.                 SPBM_SETCURRENTVALUE,
  1789.                 MPFROMLONG ( startvalue ),
  1790.                 0L
  1791.                 );
  1792.   } /* endif */
  1793. }
  1794.  
  1795. VOID enter_sysval( HWND hwnd, INT r_sw )
  1796. {
  1797.   CHAR cbuffer[MAXCBUFFER];
  1798.  
  1799.   /******************************************************************/
  1800.   /* find the index of the selected item                            */
  1801.   /******************************************************************/
  1802.   index = (SHORT) WinSendMsg ( hwndCombo1, LM_QUERYSELECTION, 0L, 0L );
  1803.   if ( index != LIT_NONE )
  1804.   {
  1805.     /****************************************************************/
  1806.     /* get the sytem value to change                                */
  1807.     /****************************************************************/
  1808.     startvalue = WrtQuerySysValue ( HWND_DESKTOP,
  1809.                                qsvalue[index+1].valueid );
  1810.  
  1811.     /****************************************************************/
  1812.     /* initialize all the spin button to the system value that where*/
  1813.     /* query. If the query reutrn an error (WRTERR_INVALID_PARM) SET*/
  1814.     /* the spin button to zerro.                                    */
  1815.     /****************************************************************/
  1816.     if ( startvalue == WRTERR_INVALID_PARM )
  1817.     {
  1818.       startvalue = 0L;
  1819.     } /* endif */
  1820.  
  1821.     if ( r_sw )
  1822.     {             /* if r_sw == 1 is read */
  1823.       /****************************************************************/
  1824.       /* Set the entry field value to the value that was query from   */
  1825.       /* the system.                                                  */
  1826.       /****************************************************************/
  1827.       sprintf ( cbuffer, "%li", startvalue);
  1828.       WinSetDlgItemText ( hwnd, wrtelc02, cbuffer );
  1829.     } else
  1830.     {             /* if r_sw == 0 is set or write */
  1831.       /************************************************************/
  1832.       /* check to see if the value can be set to 0 (disabled)     */
  1833.       /************************************************************/
  1834.       if ( qsvalue[index+1].disable == 1 )
  1835.       {
  1836.         WinSendMsg ( WinWindowFromID ( hwnd, wrtelc02 ),
  1837.                     SPBM_SETLIMITS,
  1838.                     MPFROMLONG ( qsvalue[index+1].valuemax ),/* MAX    */
  1839.                     MPFROMLONG ( 0L ) /* MIN*/
  1840.                     );
  1841.       } else
  1842.       {
  1843.         WinSendMsg ( WinWindowFromID ( hwnd, wrtelc02 ),
  1844.                     SPBM_SETLIMITS,
  1845.                     MPFROMLONG ( qsvalue[index+1].valuemax ),/* MAX    */
  1846.                     MPFROMLONG ( qsvalue[index+1].valuemin ) /* MIN    */
  1847.                     );
  1848.       } /* endif */
  1849.       /****************************************************************/
  1850.       /* Set the spin button value to the value that was query from   */
  1851.       /* the system.                                                  */
  1852.       /****************************************************************/
  1853.       WinSendMsg ( WinWindowFromID ( hwnd, wrtelc02 ),
  1854.                   SPBM_SETCURRENTVALUE,
  1855.                   MPFROMLONG ( startvalue ),
  1856.                   0L
  1857.                   );
  1858.       /****************************************************************/
  1859.       /* set the spin button's maximum and minimum values for the     */
  1860.       /* users to choose from.                                        */
  1861.       /****************************************************************/
  1862.       WinSendMsg ( WinWindowFromID ( hwnd, wrtelc02 ),
  1863.                   SPBM_OVERRIDESETLIMITS,
  1864.                   MPFROMLONG ( qsvalue[index+1].valuemax ),/* MAX    */
  1865.                   MPFROMLONG ( qsvalue[index+1].valuemin ) /* MIN    */
  1866.                   );
  1867.  
  1868.     } /* endif */
  1869.   } /* endif */
  1870. }
  1871.  
  1872. VOID updwn_sysval ( HWND hwnd )
  1873. {
  1874.   if ( qsvalue[index+1].disable == 1 )
  1875.   {
  1876.      /*********************************************************/
  1877.      /* Query the value of the spin button and put it in      */
  1878.      /* ppmid[].value                                         */
  1879.      /*********************************************************/
  1880.      WinSendMsg ( WinWindowFromID ( hwnd, wrtelc02 )
  1881.                  ,SPBM_QUERYVALUE
  1882.                  ,MPFROMLONG ( &startvalue )
  1883.                  ,MPFROM2SHORT ( NULL, SPBQ_DONOTUPDATE )
  1884.                  );
  1885.      if ( startvalue == qsvalue[index+1].valuemin ||
  1886.           startvalue == qsvalue[index+1].valuemax  )
  1887.      {
  1888.        WinSendMsg ( WinWindowFromID ( hwnd, wrtelc02 ),
  1889.                    SPBM_OVERRIDESETLIMITS,
  1890.                    MPFROMLONG ( qsvalue[index+1].valuemax ),/* MAX*/
  1891.                    MPFROMLONG ( 0L ) /* MIN*/
  1892.                    );
  1893.      } else
  1894.      {
  1895.        if ( startvalue < qsvalue[index+1].valuemin )
  1896.        {
  1897.          WinSendMsg ( WinWindowFromID ( hwnd, wrtelc02 ),
  1898.                      SPBM_SETCURRENTVALUE,
  1899.                      MPFROMLONG ( 0L ),
  1900.                      0L
  1901.                      );
  1902.          WinSendMsg ( WinWindowFromID ( hwnd, wrtelc02 ),
  1903.                      SPBM_OVERRIDESETLIMITS,
  1904.                      MPFROMLONG ( qsvalue[index+1].valuemax ),/* MAX*/
  1905.                      MPFROMLONG ( qsvalue[index+1].valuemin ) /* MIN*/
  1906.                      );
  1907.        } /* endif */
  1908.      } /* endif */
  1909.   } /* endif */
  1910. }
  1911.  
  1912. VOID set_sysval ( HWND hwnd )
  1913. {
  1914.   LONG value;
  1915.   APIRET irc;
  1916.  
  1917.   /***************************************************************/
  1918.   /* Query the value of the spin button and if the value got     */
  1919.   /* change set the new system value.                            */
  1920.   /***************************************************************/
  1921.   WinSendMsg ( WinWindowFromID ( hwnd, wrtelc02 )
  1922.               ,SPBM_QUERYVALUE
  1923.               ,MPFROMLONG ( &value )
  1924.               ,MPFROM2SHORT ( NULL, SPBQ_DONOTUPDATE )
  1925.               );
  1926.   if ( startvalue != value )
  1927.   {
  1928.      /************************************************************/
  1929.      /* value got change must set the value                      */
  1930.      /************************************************************/
  1931.      irc = WrtSetSysValue ( HWND_DESKTOP,
  1932.                             qsvalue[index+1].valueid, value );
  1933.      if ( irc == WRT_NO_ERROR )
  1934.      {
  1935.        /**********************************************************/
  1936.        /* Broadcast a post message to all descendants of         */
  1937.        /* HWND_DESKTOP notifying which system value got changed  */
  1938.        /* so they can update if need be                          */
  1939.        /**********************************************************/
  1940.        WinBroadcastMsg (
  1941.                     HWND_DESKTOP,
  1942.                     WM_WRT_SYSVALUECHANGED,
  1943.                     (MPARAM)VT_PPMSV,
  1944.                     (MPARAM)qsvalue[index+1].valueid,
  1945.                     BMSG_DESCENDANTS | BMSG_POST
  1946.                     );
  1947.      } else
  1948.      {
  1949.         DisplayError ( hwnd, irc );
  1950.      } /* endif */
  1951.   } /* endif */
  1952. }
  1953.  
  1954. VOID disp_loccaps ( HWND hwnd, PWRTLOCATORDEVINFO lcInfo )
  1955. {
  1956.   CHAR cbuffer[MAXCBUFFER];
  1957.  
  1958.    sprintf ( cbuffer, "%ld", lcInfo->cbStructSize );
  1959.    WinSetDlgItemText ( hwnd, wrtelc01, cbuffer );
  1960.  
  1961.    sprintf ( cbuffer, "%ld", lcInfo->ulLocatorID );
  1962.    WinSetDlgItemText ( hwnd, wrtelc02, cbuffer );
  1963.  
  1964.    sprintf ( cbuffer, "%ld", lcInfo->ulLocatorType );
  1965.    WinSetDlgItemText ( hwnd, wrtelc03, cbuffer );
  1966.  
  1967.    sprintf ( cbuffer, "%#lx", lcInfo->ulLocatorFlags );
  1968.    WinSetDlgItemText ( hwnd, wrtelc04, cbuffer );
  1969.  
  1970.    sprintf ( cbuffer, "%#lx", lcInfo->ulValidityFlags );
  1971.    WinSetDlgItemText ( hwnd, wrtelc05, cbuffer );
  1972.  
  1973.    sprintf ( cbuffer, "%#lx", lcInfo->ulOEMValidityCnt );
  1974.    WinSetDlgItemText ( hwnd, wrtelc06, cbuffer );
  1975.  
  1976.    sprintf ( cbuffer, "%ld", lcInfo->ulSensorHeight );
  1977.    WinSetDlgItemText ( hwnd, wrtelc07, cbuffer );
  1978.  
  1979.    sprintf ( cbuffer, "%ld", lcInfo->ulSensorWidth );
  1980.    WinSetDlgItemText ( hwnd, wrtelc08, cbuffer );
  1981.  
  1982.    sprintf ( cbuffer, "%ld", lcInfo->ulNumMouButtons );
  1983.    WinSetDlgItemText ( hwnd, wrtelc09, cbuffer );
  1984.  
  1985.    sprintf ( cbuffer, "%ld", lcInfo->ulNumButtons );
  1986.    WinSetDlgItemText ( hwnd, wrtelc10, cbuffer );
  1987.  
  1988.    sprintf ( cbuffer, "%ld", lcInfo->ulButtonMask );
  1989.    WinSetDlgItemText ( hwnd, wrtelc22, cbuffer );
  1990.  
  1991.    sprintf ( cbuffer, "%ld", lcInfo->ulSensorXpts );
  1992.    WinSetDlgItemText ( hwnd, wrtelc11, cbuffer );
  1993.  
  1994.    sprintf ( cbuffer, "%ld", lcInfo->ulSensorYpts );
  1995.    WinSetDlgItemText ( hwnd, wrtelc12, cbuffer );
  1996.  
  1997.    sprintf ( cbuffer, "%ld", lcInfo->lSensorZptsP );
  1998.    WinSetDlgItemText ( hwnd, wrtelc13, cbuffer );
  1999.  
  2000.    sprintf ( cbuffer, "%ld", lcInfo->ulSensorZptsH );
  2001.    WinSetDlgItemText ( hwnd, wrtelc14, cbuffer );
  2002.  
  2003.    sprintf ( cbuffer, "%ld", lcInfo->ulSensorXres );
  2004.    WinSetDlgItemText ( hwnd, wrtelc15, cbuffer );
  2005.  
  2006.    sprintf ( cbuffer, "%ld", lcInfo->ulSensorYres );
  2007.    WinSetDlgItemText ( hwnd, wrtelc16, cbuffer );
  2008.  
  2009.    sprintf ( cbuffer, "%ld", lcInfo->ulStandardXpts );
  2010.    WinSetDlgItemText ( hwnd, wrtelc17, cbuffer );
  2011.  
  2012.    sprintf ( cbuffer, "%ld", lcInfo->ulStandardYpts );
  2013.    WinSetDlgItemText ( hwnd, wrtelc18, cbuffer );
  2014.  
  2015.    sprintf ( cbuffer, "%ld", lcInfo->ulSampleRate );
  2016.    WinSetDlgItemText ( hwnd, wrtelc19, cbuffer );
  2017.  
  2018.    sprintf ( cbuffer, "%ld", lcInfo->ulMaxSampleRate );
  2019.    WinSetDlgItemText ( hwnd, wrtelc20, cbuffer );
  2020.  
  2021.    sprintf ( cbuffer, "%ld", lcInfo->ulTimestampRes );
  2022.    WinSetDlgItemText ( hwnd, wrtelc21, cbuffer );
  2023. }
  2024.  
  2025. VOID disp_butcaps ( HWND hwnd, PWRTBUTTONDEVINFO bcInfo )
  2026. {
  2027.   CHAR cbuffer[MAXCBUFFER];
  2028.  
  2029.    sprintf ( cbuffer, "%ld", bcInfo->cbStructSize );
  2030.    WinSetDlgItemText ( hwnd, wrtelc01, cbuffer );
  2031.  
  2032.    sprintf ( cbuffer, "%ld", bcInfo->ulButtonID );
  2033.    WinSetDlgItemText ( hwnd, wrtelc02, cbuffer );
  2034.  
  2035.    sprintf ( cbuffer, "%ld", bcInfo->ulNumButtons );
  2036.    WinSetDlgItemText ( hwnd, wrtelc03, cbuffer );
  2037.  
  2038.    sprintf ( cbuffer, "%#lx", bcInfo->ulButtonMask );
  2039.    WinSetDlgItemText ( hwnd, wrtelc04, cbuffer );
  2040. }
  2041.  
  2042. VOID disp_discaps ( HWND hwnd, PWRTDISPLAYDEVINFO dcInfo )
  2043. {
  2044.   CHAR cbuffer[MAXCBUFFER];
  2045.  
  2046.    sprintf ( cbuffer, "%ld", dcInfo->cbStructSize );
  2047.    WinSetDlgItemText ( hwnd, wrtelc01, cbuffer );
  2048.  
  2049.    sprintf ( cbuffer, "%ld", dcInfo->ulDisplayID );
  2050.    WinSetDlgItemText ( hwnd, wrtelc02, cbuffer );
  2051.  
  2052.    sprintf ( cbuffer, "%ld", dcInfo->ulDisplayType );
  2053.    WinSetDlgItemText ( hwnd, wrtelc03, cbuffer );
  2054.  
  2055.    sprintf ( cbuffer, "%ld", dcInfo->ulDisplayXPels );
  2056.    WinSetDlgItemText ( hwnd, wrtelc04, cbuffer );
  2057.  
  2058.    sprintf ( cbuffer, "%ld", dcInfo->ulDisplayYPels );
  2059.    WinSetDlgItemText ( hwnd, wrtelc05, cbuffer );
  2060.  
  2061.    sprintf ( cbuffer, "%ld", dcInfo->ulDisplayXRes );
  2062.    WinSetDlgItemText ( hwnd, wrtelc06, cbuffer );
  2063.  
  2064.    sprintf ( cbuffer, "%ld", dcInfo->ulDisplayYRes );
  2065.    WinSetDlgItemText ( hwnd, wrtelc07, cbuffer );
  2066.  
  2067.    sprintf ( cbuffer, "%ld", dcInfo->ulDisplayHeight );
  2068.    WinSetDlgItemText ( hwnd, wrtelc08, cbuffer );
  2069.  
  2070.    sprintf ( cbuffer, "%ld", dcInfo->ulDisplayWidth );
  2071.    WinSetDlgItemText ( hwnd, wrtelc09, cbuffer );
  2072. }
  2073.  
  2074. VOID init_invar ( HWND hwnd, INT q_s )
  2075. {
  2076.   APIRET irc;
  2077.   ULONG aDeviceType[10];
  2078.   ULONG aDeviceID[10];
  2079.   ULONG ulDatalen;
  2080.   CHAR Data[512];
  2081.   WNDPARAMS comboprams;
  2082.   INT i;
  2083.   INT cbox;
  2084.   CHAR cbuffer[MAXCBUFFER];
  2085.   /****************************************************************************/
  2086.   /* Find out how many input driver there are       *                         */
  2087.   /****************************************************************************/
  2088.   ulNumDrivers = 0L;
  2089.   irc = WrtEnumInputDrivers ( &ulNumDrivers, NULL );
  2090.   if ( irc != WRT_NO_ERROR )
  2091.   {
  2092.     DisplayError ( hwnd, irc );
  2093.   } else
  2094.   {
  2095.     if ( ulNumDrivers > 10L )
  2096.     {
  2097.       sprintf(cbuffer,"Too many drivers[%ld] for my ARRAY", ulNumDrivers );
  2098.       WinMessageBox( HWND_DESKTOP,
  2099.                      hwnd,
  2100.                      cbuffer,
  2101.                      NULL, 1, MB_OK );
  2102.     } else
  2103.     {
  2104.       if ( ulNumDrivers == 0L )
  2105.       {
  2106.         sprintf(cbuffer,"No drivers found" );
  2107.         WinMessageBox( HWND_DESKTOP,
  2108.                        hwnd,
  2109.                        cbuffer,
  2110.                        NULL, 1, MB_OK );
  2111.       } else
  2112.       {
  2113.         /**********************************************************************/
  2114.         /* get array of driver names                                          */
  2115.         /**********************************************************************/
  2116.         irc = WrtEnumInputDrivers ( &ulNumDrivers, szDriverName );
  2117.         if ( irc != WRT_NO_ERROR )
  2118.         {
  2119.           DisplayError ( hwnd, irc );
  2120.         } else
  2121.         {
  2122.           /********************************************************************/
  2123.           /* initialize the entries in the Drivers list box                   */
  2124.           /********************************************************************/
  2125.           hwndCombo1 = WinWindowFromID ( hwnd , wrtelc01 );
  2126.  
  2127.           for ( i= 0; i < ulNumDrivers ; i++ )
  2128.           {
  2129.             index1 = (SHORT) WinSendMsg ( hwndCombo1, LM_INSERTITEM,
  2130.                                  MPFROMSHORT ( LIT_END ),
  2131.                                  MPFROMP ( szDriverName[i] ) );
  2132.           } /* endfor */
  2133.           /********************************************************************/
  2134.           /* Set the first item on the list at the top.                       */
  2135.           /********************************************************************/
  2136.           index1 = 0;                         /* intialize the index to zeror */
  2137.           WinSendMsg ( hwndCombo1, LM_SETTOPINDEX, MPFROMSHORT ( index1 ), 0 );
  2138.  
  2139.           comboprams.fsStatus = WPM_TEXT;      /* change window text          */
  2140.           comboprams.cchText = sizeof ( szDriverName[index1] );  /* text size */
  2141.           comboprams.pszText = szDriverName[index1];         /*text to display*/
  2142.           WinSendMsg ( hwndCombo1, WM_SETWINDOWPARAMS,
  2143.                        &comboprams, 0 );
  2144.  
  2145.           /********************************************************************/
  2146.           /* Find out how many input device there are                         */
  2147.           /********************************************************************/
  2148.           ulNumDevices = 0L;
  2149.           irc = WrtQueryInputDeviceNames ( szDriverName[index1], &ulNumDevices,
  2150.                                            NULL, NULL, NULL );
  2151.           if ( irc != WRT_NO_ERROR )
  2152.           {
  2153.             DisplayError ( hwnd, irc );
  2154.           } else
  2155.           {
  2156.             if ( ulNumDevices > 10L )
  2157.             {
  2158.               sprintf(cbuffer,"Too many devices[%ld] Driver[%s] for my ARRAY",
  2159.                       ulNumDevices, szDriverName[index1] );
  2160.               WinMessageBox( HWND_DESKTOP,
  2161.                              hwnd,
  2162.                              cbuffer,
  2163.                              NULL, 1, MB_OK );
  2164.             } else
  2165.             {
  2166.               /****************************************************************/
  2167.               /* Get array of device names                                    */
  2168.               /****************************************************************/
  2169.               irc = WrtQueryInputDeviceNames ( szDriverName[index1],
  2170.                                                &ulNumDevices, aDeviceName,
  2171.                                                aDeviceType, aDeviceID );
  2172.               if ( irc != WRT_NO_ERROR )
  2173.               {
  2174.                 DisplayError ( hwnd, irc );
  2175.               } else
  2176.               {
  2177.                 /**************************************************************/
  2178.                 /* initialize the entries in the list box                     */
  2179.                 /**************************************************************/
  2180.                 hwndCombo2 = WinWindowFromID ( hwnd , wrtelc02 );
  2181.  
  2182.                 for ( i= 0; i < ulNumDevices ; i++ )
  2183.                 {
  2184.                   index2 = (SHORT) WinSendMsg ( hwndCombo2, LM_INSERTITEM,
  2185.                                        MPFROMSHORT ( LIT_END ),
  2186.                                        MPFROMP ( aDeviceName[i] ) );
  2187.                 } /* endfor */
  2188.                 /**************************************************************/
  2189.                 /* Set the first item on the list at the top.                 */
  2190.                 /**************************************************************/
  2191.                 index2 = 0;                     /* intialize the index to zeror */
  2192.                 WinSendMsg ( hwndCombo2, LM_SETTOPINDEX,
  2193.                              MPFROMSHORT ( index2 ), 0 );
  2194.  
  2195.                 comboprams.fsStatus = WPM_TEXT;      /* change window text    */
  2196.                 comboprams.cchText = sizeof ( aDeviceName[index2] );/*text size*/
  2197.                 comboprams.pszText = aDeviceName[index2];    /*text to display*/
  2198.                 WinSendMsg ( hwndCombo2, WM_SETWINDOWPARAMS,
  2199.                              &comboprams, 0 );
  2200.  
  2201.                 /**************************************************************/
  2202.                 /* initialize the entries in the Value ID list box            */
  2203.                 /**************************************************************/
  2204.                 hwndCombo3 = WinWindowFromID ( hwnd , wrtelc03 );
  2205.  
  2206.                 /**************************************************************/
  2207.                 /* initialize the value ID valid for this driver and device   */
  2208.                 /**************************************************************/
  2209.                 cbox = 0;
  2210.                 for ( i=0; i < (PPMIDSIZE - 1); i++ )
  2211.                 {
  2212.                   irc = WrtQueryInputDeviceVariable ( szDriverName[index1],
  2213.                                                       aDeviceName[index2],
  2214.                                                       ppmid[i].ValueID,
  2215.                                                       &ppmid[i].value,
  2216.                                                       NULL,
  2217.                                                       NULL
  2218.                                                      );
  2219.                   if ( irc == WRT_NO_ERROR )
  2220.                   {
  2221.                     /**********************************************************/
  2222.                     /* Mark the input device variable as suported.            */
  2223.                     /**********************************************************/
  2224.                     ppmid[i].active = 1;
  2225.                     cbox++;
  2226.  
  2227.                     /**********************************************************/
  2228.                     /*Set the input device variable in the list to choose from*/
  2229.                     /**********************************************************/
  2230.                     index3 = (SHORT) WinSendMsg ( hwndCombo3, LM_INSERTITEM,
  2231.                                            MPFROMSHORT ( LIT_END ),
  2232.                                            MPFROMP ( ppmid[i].name ) );
  2233.  
  2234.                   } else
  2235.                   {
  2236.                     /**********************************************************/
  2237.                     /* Mark the input device variable as not active.          */
  2238.                     /**********************************************************/
  2239.                     ppmid[i].active = 0;
  2240.                   } /* endif */
  2241.                 } /* endfor */
  2242.                 if ( cbox == 0 )
  2243.                 {
  2244.                   WinEnableWindow ( (WinWindowFromID ( hwnd , wrtlc03 )), FALSE );
  2245.                   WinEnableWindow ( (WinWindowFromID ( hwnd , wrtelc03 )), FALSE );
  2246.                   WinEnableWindow ( (WinWindowFromID ( hwnd , wrtlc04 )), FALSE );
  2247.                   WinEnableWindow ( (WinWindowFromID ( hwnd , wrtelc04 )), FALSE );
  2248.                   sprintf(cbuffer,"No active variables Drv[%s] Name[%s]",
  2249.                   szDriverName[index1], aDeviceName[index2] );
  2250.                   WinMessageBox( HWND_DESKTOP,
  2251.                                  hwnd,
  2252.                                  cbuffer,
  2253.                                  NULL, 1, MB_OK );
  2254.                 } else
  2255.                 {
  2256.                   /************************************************************/
  2257.                   /*Find the first active input device variable to gets       */
  2258.                   /* its name                                                 */
  2259.                   /************************************************************/
  2260.                   for ( i= 0; i < (PPMIDSIZE - 1); i++)
  2261.                   {
  2262.                     if ( ppmid[i].active )
  2263.                     {
  2264.                        break;
  2265.                     } /* endif */
  2266.                   } /* endfor */
  2267.                   /************************************************************/
  2268.                   /* Set the first item on the list at the top.               */
  2269.                   /************************************************************/
  2270.                   index3 = 0;                 /* intialize the index to zeror */
  2271.                   WinSendMsg ( hwndCombo3, LM_SETTOPINDEX,
  2272.                                MPFROMSHORT ( index3 ), 0 );
  2273.  
  2274.                   comboprams.fsStatus = WPM_TEXT;       /* change window text */
  2275.                   comboprams.cchText = sizeof ( ppmid[i].name ); /* text size */
  2276.                   comboprams.pszText = ppmid[i].name;      /* text to display */
  2277.                   WinSendMsg ( hwndCombo3, WM_SETWINDOWPARAMS,
  2278.                                &comboprams, 0 );
  2279.  
  2280.                   if ( q_s )
  2281.                   {                 /* q_s == 1 then query */
  2282.                     sprintf ( cbuffer, "%li", ppmid[i].value );
  2283.                     WinSendDlgItemMsg(hwnd,
  2284.                                       wrtelc04,
  2285.                                       LM_INSERTITEM,
  2286.                                       MPFROM2SHORT(LIT_END, 0),
  2287.                                       MPFROMP( cbuffer ) );
  2288.  
  2289.                   } else
  2290.                   {                 /* q_s == 0 then set   */
  2291.                     /************************************************************/
  2292.                     /* check to see if the value can be set to 0 (disabled)     */
  2293.                     /************************************************************/
  2294.                     if (ppmid[i].disable == 1 )
  2295.                     {
  2296.                       WinSendMsg ( WinWindowFromID ( hwnd, wrtelc04 ),
  2297.                                   SPBM_SETLIMITS,
  2298.                                   MPFROMLONG ( ppmid[i].maxval ),/* MAX*/
  2299.                                   MPFROMLONG ( 0L ) /* MIN*/
  2300.                                   );
  2301.                     } else
  2302.                     {
  2303.                       WinSendMsg ( WinWindowFromID ( hwnd, wrtelc04 ),
  2304.                                   SPBM_SETLIMITS,
  2305.                                   MPFROMLONG ( ppmid[i].maxval ),/* MAX*/
  2306.                                   MPFROMLONG ( ppmid[i].minval ) /* MIN*/
  2307.                                   );
  2308.                     } /* endif */
  2309.                     /************************************************************/
  2310.                     /* Set the spin button value to the value that was query    */
  2311.                     /* from the system.                                         */
  2312.                     /************************************************************/
  2313.                     WinSendMsg ( WinWindowFromID ( hwnd, wrtelc04 ),
  2314.                                 SPBM_SETCURRENTVALUE,
  2315.                                 MPFROMLONG ( ppmid[i].value ),
  2316.                                 0L
  2317.                                 );
  2318.                     /************************************************************/
  2319.                     /* set the spin button's maximum and minimum values for the */
  2320.                     /* users to choose from.                                    */
  2321.                     /************************************************************/
  2322.                     WinSendMsg ( WinWindowFromID ( hwnd, wrtelc04 ),
  2323.                                 SPBM_OVERRIDESETLIMITS,
  2324.                                 MPFROMLONG ( ppmid[i].maxval ),/* MAX*/
  2325.                                 MPFROMLONG ( ppmid[i].minval ) /* MIN*/
  2326.                                 );
  2327.                   } /* endif */
  2328.                 } /* endif */
  2329.                 if ( q_s )
  2330.                 {                /* q_s == 1 then query */
  2331.                   /**************************************************************/
  2332.                   /* Find out if the "Driver" is supported.                     */
  2333.                   /* If it is set "Driver as a choice in combo 2                */
  2334.                   /**************************************************************/
  2335.                   ulDatalen = 512;
  2336.                   irc = WrtQueryInputDeviceVariable ( szDriverName[index1],
  2337.                                                       "Driver",
  2338.                                                       ppmid[ PPMIDSIZE - 1 ].ValueID,
  2339.                                                       &ppmid[ PPMIDSIZE - 1 ].value,
  2340.                                                       &ulDatalen,
  2341.                                                       Data
  2342.                                                      );
  2343.                   if ( irc == WRT_NO_ERROR )
  2344.                   {
  2345.                     ppmid[ PPMIDSIZE - 1 ].active = 1;
  2346.                     WinSendMsg ( hwndCombo2, LM_INSERTITEM,
  2347.                                  MPFROMSHORT ( LIT_END ),
  2348.                                  MPFROMP ( "Driver" ) );
  2349.                   } else
  2350.                   {
  2351.                     ppmid[ PPMIDSIZE - 1 ].active = 0;
  2352.                   }  /* endif */
  2353.                 } /* endif */
  2354.               } /* endif */
  2355.             } /* endif */
  2356.           } /* endif */
  2357.         } /* endif */
  2358.       } /* endif */
  2359.     } /* endif */
  2360.   } /* endif */
  2361. }
  2362.  
  2363. VOID updatecntrl ( HWND hwnd, INT q_s, HWND hwnd_temp )
  2364. {
  2365.   APIRET irc;
  2366.   CHAR szDrvName[32];
  2367.   ULONG aDeviceType[10];
  2368.   ULONG aDeviceID[10];
  2369.   ULONG ulDatalen;
  2370.   CHAR Data[512];
  2371.   WNDPARAMS comboprams;
  2372.   INT i;
  2373.   INT cbox;
  2374.   CHAR cbuffer[MAXCBUFFER];
  2375.  
  2376.   WinEnableWindow ( (WinWindowFromID ( hwnd , wrtlc04 )), TRUE );
  2377.   WinEnableWindow ( (WinWindowFromID ( hwnd , wrtelc04 )), TRUE );
  2378.   WinEnableWindow ( (WinWindowFromID ( hwnd , wrtlc03 )), TRUE );
  2379.   WinEnableWindow ( (WinWindowFromID ( hwnd , wrtelc03 )), TRUE );
  2380.   if ( hwnd_temp == hwndCombo1 )
  2381.   {
  2382.     /*******************************************************************/
  2383.     /* Get the Driver selected and find:                               */
  2384.     /* 1: devices supported by the driver                              */
  2385.     /* 2: ValueID supported by the 1st device                          */
  2386.     /* 3: Value of the 1st ValueID                                     */
  2387.     /*******************************************************************/
  2388.     /*******************************************************************/
  2389.     /* find the index of the selected item                             */
  2390.     /*******************************************************************/
  2391.     index1 = (SHORT)WinSendMsg ( hwndCombo1, LM_QUERYSELECTION, 0L, 0L );
  2392.     if ( index1 != LIT_NONE )
  2393.     {
  2394.       /*****************************************************************/
  2395.       /* get the name of the driver choosen.                           */
  2396.       /*****************************************************************/
  2397.       WinSendMsg ( hwndCombo1, LM_QUERYITEMTEXT,
  2398.                            MPFROM2SHORT ( index1, 32 ),
  2399.                            MPFROMP ( szDriverName[index1] ) );
  2400.       /*****************************************************************/
  2401.       /* Clear out the Devices list box and get the devices for the    */
  2402.       /* driver.                                                       */
  2403.       /*****************************************************************/
  2404.       WinSendMsg ( hwndCombo2, EM_CLEAR,
  2405.                              0L,
  2406.                              0L );
  2407.       WinSendMsg ( hwndCombo2, LM_DELETEALL,
  2408.                            0L,
  2409.                            0L );
  2410.       WinSendMsg ( hwndCombo3, EM_CLEAR,
  2411.                              0L,
  2412.                              0L );
  2413.       WinSendMsg ( hwndCombo3, LM_DELETEALL,
  2414.                            0L,
  2415.                            0L );
  2416.       index3 = 0;                /* intialize the index to zero */
  2417.       WinSendMsg ( hwndCombo3, LM_SETTOPINDEX,
  2418.                   MPFROMSHORT ( index3 ), 0 );
  2419.  
  2420.       comboprams.fsStatus = WPM_TEXT;    /* change window text */
  2421.       comboprams.cchText = sizeof ( "     " );/*text size*/
  2422.       comboprams.pszText = "     ";   /* text to display */
  2423.       WinSendMsg ( hwndCombo3, WM_SETWINDOWPARAMS,
  2424.                    &comboprams, 0 );
  2425.       WinSendDlgItemMsg(hwnd,
  2426.                             wrtelc04,
  2427.                             LM_DELETEALL,
  2428.                             0L,
  2429.                             0L );
  2430.       /*****************************************************************/
  2431.       /* Find out how many input device there are                      */
  2432.       /*****************************************************************/
  2433.       ulNumDevices = 0L;
  2434.       irc = WrtQueryInputDeviceNames ( szDriverName[index1],
  2435.                                        &ulNumDevices,
  2436.                                        NULL, NULL, NULL );
  2437.       if ( irc != WRT_NO_ERROR )
  2438.       {
  2439.          DisplayError ( hwnd, irc );
  2440.       } else
  2441.       {
  2442.         if ( ulNumDevices > 10L )
  2443.         {
  2444.           sprintf(cbuffer,"Too many devices[%ld] Driver[%s] for my ARRAY",
  2445.                   ulNumDevices, szDriverName[index1] );
  2446.           WinMessageBox( HWND_DESKTOP,
  2447.                          hwnd,
  2448.                          cbuffer,
  2449.                          NULL, 1, MB_OK );
  2450.         } else
  2451.         {
  2452.           /*************************************************************/
  2453.           /* Get array of device names                                 */
  2454.           /*************************************************************/
  2455.           irc = WrtQueryInputDeviceNames ( szDriverName[index1],
  2456.                                            &ulNumDevices, aDeviceName,
  2457.                                            aDeviceType, aDeviceID );
  2458.           if ( irc != WRT_NO_ERROR )
  2459.           {
  2460.             DisplayError ( hwnd, irc );
  2461.           } else
  2462.           {
  2463.             /***********************************************************/
  2464.             /* initialize the entries in the list box                  */
  2465.             /***********************************************************/
  2466.             hwndCombo2 = WinWindowFromID ( hwnd , wrtelc02 );
  2467.  
  2468.             for ( i= 0; i < ulNumDevices ; i++ )
  2469.             {
  2470.               index2 = (SHORT) WinSendMsg ( hwndCombo2, LM_INSERTITEM,
  2471.                                    MPFROMSHORT ( LIT_END ),
  2472.                                    MPFROMP ( aDeviceName[i] ) );
  2473.             } /* endfor */
  2474.             /***********************************************************/
  2475.             /* Set the first item on the list at the top.              */
  2476.             /***********************************************************/
  2477.             index2 = 0;                /* intialize the index to zeror */
  2478.             WinSendMsg ( hwndCombo2, LM_SETTOPINDEX,
  2479.                          MPFROMSHORT ( index2 ), 0 );
  2480.  
  2481.             comboprams.fsStatus = WPM_TEXT;      /* change window text */
  2482.             comboprams.cchText = sizeof ( aDeviceName[index2] );
  2483.             /*text size*/
  2484.             comboprams.pszText = aDeviceName[index2]; /*text to display*/
  2485.             WinSendMsg ( hwndCombo2, WM_SETWINDOWPARAMS,
  2486.                          &comboprams, 0 );
  2487.  
  2488.             /*************************************************************/
  2489.             /* initialize the entries in the Value ID list box           */
  2490.             /*************************************************************/
  2491.             hwndCombo3 = WinWindowFromID ( hwnd , wrtelc03 );
  2492.  
  2493.             update3 ( hwnd, q_s );
  2494.             if ( q_s )
  2495.             {            /* q_s == 1 is a query */
  2496.               /***********************************************************/
  2497.               /* Find out if the "Driver" is supported.                  */
  2498.               /* If it is set "Driver as a choice in combo 2             */
  2499.               /***********************************************************/
  2500.               ulDatalen = 512;
  2501.               irc = WrtQueryInputDeviceVariable ( szDriverName[index1],
  2502.                                                   "Driver",
  2503.                                                   ppmid[ PPMIDSIZE - 1 ].ValueID,
  2504.                                                   &ppmid[ PPMIDSIZE - 1 ].value,
  2505.                                                   &ulDatalen,
  2506.                                                   Data
  2507.                                                  );
  2508.               if ( irc == WRT_NO_ERROR )
  2509.               {
  2510.                 ppmid[ PPMIDSIZE - 1 ].active = 1;
  2511.                 WinSendMsg ( hwndCombo2, LM_INSERTITEM,
  2512.                              MPFROMSHORT ( LIT_END ),
  2513.                              MPFROMP ( "Driver" ) );
  2514.               } else
  2515.               {
  2516.                 ppmid[ PPMIDSIZE - 1 ].active = 0;
  2517.               }  /* endif */
  2518.             } /* endif */
  2519.           } /* endif */
  2520.         } /* endif */
  2521.       } /* endif */
  2522.     } /* endif */
  2523.   } else
  2524.   {
  2525.     if ( hwnd_temp == hwndCombo2 )
  2526.     {
  2527.       /*****************************************************************/
  2528.       /* Get the Device selected and find:                             */
  2529.       /* 1: ValueID supported by the 1st device                        */
  2530.       /* 2: Value of the 1st ValueID                                   */
  2531.       /*******************************************************************/
  2532.       /*****************************************************************/
  2533.       /* get the name of the driver choosen.                           */
  2534.       /*****************************************************************/
  2535.  
  2536.       comboprams.fsStatus = WPM_TEXT;            /* get window text    */
  2537.       comboprams.cchText = sizeof ( szDrvName ); /* text size          */
  2538.       comboprams.pszText = szDrvName;            /* buffer to put text */
  2539.       WinSendMsg ( hwndCombo1, WM_QUERYWINDOWPARAMS, &comboprams, 0 );
  2540.       /*****************************************************************/
  2541.       /* find the index of the selected item                           */
  2542.       /*****************************************************************/
  2543.       index2 = (SHORT)WinSendMsg( hwndCombo2, LM_QUERYSELECTION, 0L, 0L);
  2544.       if ( index2 != LIT_NONE )
  2545.       {
  2546.         /***************************************************************/
  2547.         /* get the name of the device choosen.                         */
  2548.         /***************************************************************/
  2549.         WinSendMsg ( hwndCombo2, LM_QUERYITEMTEXT,
  2550.                              MPFROM2SHORT ( index2, 32 ),
  2551.                              MPFROMP ( aDeviceName[index2] ) );
  2552.  
  2553.         /***************************************************************/
  2554.         /* Clear out the ValueID list box and get the devices for the  */
  2555.         /* driver.                                                     */
  2556.         /***************************************************************/
  2557.         WinSendMsg ( hwndCombo3, EM_CLEAR,
  2558.                              0L,
  2559.                              0L );
  2560.         WinSendMsg ( hwndCombo3, LM_DELETEALL,
  2561.                              0L,
  2562.                              0L );
  2563.         index3 = 0;                     /* intialize the index to zero */
  2564.         WinSendMsg ( hwndCombo3, LM_SETTOPINDEX,
  2565.                      MPFROMSHORT ( index3 ), 0 );
  2566.  
  2567.         comboprams.fsStatus = WPM_TEXT;          /* change window text */
  2568.         comboprams.cchText = sizeof ( "       " );/*text size          */
  2569.         comboprams.pszText = "       ";           /* text to display   */
  2570.         WinSendMsg ( hwndCombo3, WM_SETWINDOWPARAMS,
  2571.                      &comboprams, 0 );
  2572.         if ( q_s )
  2573.         {
  2574.           WinSendDlgItemMsg(hwnd,
  2575.                                wrtelc04,
  2576.                                LM_DELETEALL,
  2577.                                0L,
  2578.                                0L );
  2579.         } else
  2580.         {
  2581.           WinSendMsg ( WinWindowFromID ( hwnd, wrtelc04 ),
  2582.                       SPBM_SETLIMITS,
  2583.                       MPFROMLONG ( 0L ),/* MAX*/
  2584.                       MPFROMLONG ( 0L ) /* MIN*/
  2585.                       );
  2586.           WinSendMsg ( WinWindowFromID ( hwnd, wrtelc04 ),
  2587.                       SPBM_SETCURRENTVALUE,
  2588.                       MPFROMLONG ( 0L ),
  2589.                       0L
  2590.                       );
  2591.         } /* endif */
  2592.         /***************************************************************/
  2593.         /* if the device name is "Driver" then only do driver          */
  2594.         /* else do all variables                                       */
  2595.         /***************************************************************/
  2596.         if ( strcmp ( "Driver", aDeviceName[index2] )  == 0 )
  2597.         {
  2598.           ulDatalen = 512;
  2599.           for ( i=0; i < ulDatalen ; i++)
  2600.           {
  2601.             Data[i] = 0;                         /* clear out old data */
  2602.           } /* endfor */
  2603.           irc = WrtQueryInputDeviceVariable ( szDrvName,
  2604.                                                "Driver",
  2605.                                                ppmid[ PPMIDSIZE - 1 ].ValueID,
  2606.                                                &ppmid[ PPMIDSIZE - 1 ].value,
  2607.                                                &ulDatalen,
  2608.                                                Data
  2609.                                               );
  2610.           if ( irc == WRT_NO_ERROR )
  2611.           {
  2612.             sprintf ( cbuffer, "Data length is %i", ulDatalen );
  2613.             WinSendDlgItemMsg(hwnd,
  2614.                                wrtelc04,
  2615.                                LM_INSERTITEM,
  2616.                                MPFROM2SHORT(LIT_END, 0),
  2617.                                MPFROMP( cbuffer ) );
  2618.             for ( i= 0; i < ulDatalen ; i++ )
  2619.             {
  2620.                sprintf ( cbuffer, "Data[%i] =%i", i, Data[i] );
  2621.                WinSendDlgItemMsg(hwnd,
  2622.                                   wrtelc04,
  2623.                                   LM_INSERTITEM,
  2624.                                   MPFROM2SHORT(LIT_END, 0),
  2625.                                   MPFROMP( cbuffer ) );
  2626.             } /* endfor */
  2627.             if ( ulDatalen == 0L)
  2628.             {
  2629.               WinEnableWindow ( (WinWindowFromID ( hwnd , wrtlc03 )),
  2630.                                     FALSE );
  2631.               WinEnableWindow ( (WinWindowFromID ( hwnd , wrtelc03 )),
  2632.                                     FALSE );
  2633.               WinEnableWindow ( (WinWindowFromID ( hwnd , wrtlc04 )),
  2634.                                     FALSE );
  2635.               WinEnableWindow ( (WinWindowFromID ( hwnd , wrtelc04 )),
  2636.                                     FALSE );
  2637.             } /* endif */
  2638.           } else
  2639.           {
  2640.             sprintf(cbuffer,"WrtQueryInputDeviceVariable with Driver Failed");
  2641.             WinMessageBox( HWND_DESKTOP,
  2642.                            hwnd,
  2643.                            cbuffer,
  2644.                            NULL, 1, MB_OK );
  2645.           } /* endif */
  2646.         } else
  2647.         {
  2648.           update3 ( hwnd, q_s );
  2649.         } /* endif */
  2650.       } /* endif */
  2651.     } else
  2652.     {
  2653.       if ( hwnd_temp == hwndCombo3 )
  2654.       {
  2655.         /***************************************************************/
  2656.         /* Get the valueID selected and find:                          */
  2657.         /* 2: Value of the ValueID                                     */
  2658.         /***************************************************************/
  2659.         /***************************************************************/
  2660.         /* find the index of the selected item                         */
  2661.         /***************************************************************/
  2662.         index3 = (SHORT)WinSendMsg( hwndCombo3,
  2663.                                     LM_QUERYSELECTION, 0L, 0L);
  2664.         if ( index3 != LIT_NONE )
  2665.         {
  2666.           if ( q_s )
  2667.           {
  2668.             /*************************************************************/
  2669.             /* Clear out the Value list box                              */
  2670.             /*************************************************************/
  2671.             WinSendDlgItemMsg(hwnd,
  2672.                                  wrtelc04,
  2673.                                  LM_DELETEALL,
  2674.                                  0L,
  2675.                                  0L );
  2676.           } else
  2677.           {
  2678.             /*************************************************************/
  2679.             /* Clear out the Value list box                              */
  2680.             /*************************************************************/
  2681.             WinSendMsg ( WinWindowFromID ( hwnd, wrtelc04 ),
  2682.                         SPBM_SETLIMITS,
  2683.                         MPFROMLONG ( 0L ),/* MAX*/
  2684.                         MPFROMLONG ( 0L ) /* MIN*/
  2685.                         );
  2686.             WinSendMsg ( WinWindowFromID ( hwnd, wrtelc04 ),
  2687.                         SPBM_SETCURRENTVALUE,
  2688.                         MPFROMLONG ( 0L ),
  2689.                         0L
  2690.                         );
  2691.           } /* endif */
  2692.           /*************************************************************/
  2693.           /*Find the ID coresponding to the index                      */
  2694.           /*************************************************************/
  2695.           cbox = -1;
  2696.           for ( i= 0; i< (PPMIDSIZE - 1); i++)
  2697.           {
  2698.             if ( ppmid[i].active )
  2699.             {
  2700.               if ( ++cbox == index3  )
  2701.               {
  2702.                  break;
  2703.               } /* endif */
  2704.             } /* endif */
  2705.           } /* endfor */
  2706.           if ( q_s )
  2707.           {
  2708.             sprintf ( cbuffer, "%li", ppmid[i].value );
  2709.             WinSendDlgItemMsg(hwnd,
  2710.                                wrtelc04,
  2711.                                LM_INSERTITEM,
  2712.                                MPFROM2SHORT(LIT_END, 0),
  2713.                                MPFROMP( cbuffer ) );
  2714.           } else
  2715.           {
  2716.             /************************************************************/
  2717.             /* check to see if the value can be set to 0 (disabled)     */
  2718.             /************************************************************/
  2719.             if (ppmid[i].disable == 1 )
  2720.             {
  2721.               WinSendMsg ( WinWindowFromID ( hwnd, wrtelc04 ),
  2722.                           SPBM_SETLIMITS,
  2723.                           MPFROMLONG ( ppmid[i].maxval ),/* MAX*/
  2724.                           MPFROMLONG ( 0L ) /* MIN*/
  2725.                           );
  2726.             } else
  2727.             {
  2728.               WinSendMsg ( WinWindowFromID ( hwnd, wrtelc04 ),
  2729.                           SPBM_SETLIMITS,
  2730.                           MPFROMLONG ( ppmid[i].maxval ),/* MAX*/
  2731.                           MPFROMLONG ( ppmid[i].minval ) /* MIN*/
  2732.                           );
  2733.             } /* endif */
  2734.             /*************************************************************/
  2735.             /* Set the spin button value to the value that was query     */
  2736.             /* from the system.                                          */
  2737.             /*************************************************************/
  2738.             WinSendMsg ( WinWindowFromID ( hwnd, wrtelc04 ),
  2739.                         SPBM_SETCURRENTVALUE,
  2740.                         MPFROMLONG ( ppmid[i].value ),
  2741.                         0L
  2742.                         );
  2743.             /*************************************************************/
  2744.             /* set the spin button's maximum and minimum values for      */
  2745.             /* the users to choose from.                                 */
  2746.             /*************************************************************/
  2747.             WinSendMsg ( WinWindowFromID ( hwnd, wrtelc04 ),
  2748.                         SPBM_OVERRIDESETLIMITS,
  2749.                         MPFROMLONG ( ppmid[i].maxval ),/* MAX            */
  2750.                         MPFROMLONG ( ppmid[i].minval ) /* MIN            */
  2751.                         );
  2752.           } /* endif */
  2753.         } /* endif */
  2754.       } else
  2755.       {
  2756.        sprintf(cbuffer,"No MATCH mp2[%ld] 1[%ld]2[%ld]3[%ld]",
  2757.                hwnd_temp, hwndCombo1, hwndCombo2, hwndCombo3 );
  2758.        WinMessageBox( HWND_DESKTOP,
  2759.                       hwnd,
  2760.                       cbuffer,
  2761.                       NULL, 1, MB_OK );
  2762.       } /* endif */
  2763.     } /* endif */
  2764.   } /* endif */
  2765. }
  2766.  
  2767. VOID update3 (HWND hwnd, INT q_s )
  2768. {
  2769.   APIRET irc;
  2770.   WNDPARAMS comboprams;
  2771.   INT i;
  2772.   INT cbox;
  2773.   CHAR cbuffer[MAXCBUFFER];
  2774.   /*************************************************************/
  2775.   /* initialize the value ID valid for this driver and device  */
  2776.   /*************************************************************/
  2777.   cbox = 0;
  2778.     for ( i=0; i < (PPMIDSIZE - 1) ; i++ )
  2779.     {
  2780.       irc = WrtQueryInputDeviceVariable ( szDriverName[index1],
  2781.                                           aDeviceName[index2],
  2782.                                           ppmid[i].ValueID,
  2783.                                           &ppmid[i].value,
  2784.                                           NULL,
  2785.                                           NULL
  2786.                                          );
  2787.       if ( irc == WRT_NO_ERROR )
  2788.       {
  2789.         /*******************************************************/
  2790.         /* Mark the input device variable as suported.         */
  2791.         /*******************************************************/
  2792.         ppmid[i].active = 1;
  2793.         cbox++;
  2794.  
  2795.         /*******************************************************/
  2796.         /* Set the input device variable in the list to choose */
  2797.         /* from                                                */
  2798.         /*******************************************************/
  2799.         index3 = (SHORT) WinSendMsg ( hwndCombo3, LM_INSERTITEM,
  2800.                                MPFROMSHORT ( LIT_END ),
  2801.                                MPFROMP ( ppmid[i].name ) );
  2802.  
  2803.       } else
  2804.       {
  2805.         /*******************************************************/
  2806.         /* Mark the input device variable as not active.       */
  2807.         /*******************************************************/
  2808.         ppmid[i].active = 0;
  2809.       } /* endif */
  2810.     } /* endfor */
  2811.     if ( cbox == 0)
  2812.     {
  2813.       WinEnableWindow ( (WinWindowFromID ( hwnd , wrtlc03 )), FALSE );
  2814.       WinEnableWindow ( (WinWindowFromID ( hwnd , wrtelc03 )), FALSE );
  2815.       WinEnableWindow ( (WinWindowFromID ( hwnd , wrtlc04 )), FALSE );
  2816.       WinEnableWindow ( (WinWindowFromID ( hwnd , wrtelc04 )), FALSE );
  2817.       sprintf(cbuffer,"No active variables Drv[%s] Name[%s]",
  2818.       szDriverName[index1], aDeviceName[index2] );
  2819.       WinMessageBox( HWND_DESKTOP,
  2820.                      hwnd,
  2821.                      cbuffer,
  2822.                      NULL, 1, MB_OK );
  2823.     } else
  2824.     {
  2825.       /*********************************************************/
  2826.       /* Find the first active input device variable to gets   */
  2827.       /* its name                                              */
  2828.       /*********************************************************/
  2829.       for ( i= 0; i < (PPMIDSIZE - 1); i++)
  2830.       {
  2831.         if ( ppmid[i].active )
  2832.         {
  2833.            break;
  2834.         } /* endif */
  2835.       } /* endfor */
  2836.       /*********************************************************/
  2837.       /* Set the first item on the list at the top.            */
  2838.       /*********************************************************/
  2839.       index3 = 0;                /* intialize the index to zero */
  2840.       WinSendMsg ( hwndCombo3, LM_SETTOPINDEX,
  2841.                    MPFROMSHORT ( index3 ), 0 );
  2842.  
  2843.       comboprams.fsStatus = WPM_TEXT;    /* change window text */
  2844.       comboprams.cchText = sizeof ( ppmid[i].name );/*text size*/
  2845.       comboprams.pszText = ppmid[i].name;   /* text to display */
  2846.       WinSendMsg ( hwndCombo3, WM_SETWINDOWPARAMS,
  2847.                    &comboprams, 0 );
  2848.  
  2849.       if ( q_s )
  2850.       {
  2851.         sprintf ( cbuffer, "%li", ppmid[i].value );
  2852.         WinSendDlgItemMsg(hwnd,
  2853.                           wrtelc04,
  2854.                           LM_INSERTITEM,
  2855.                           MPFROM2SHORT(LIT_END, 0),
  2856.                           MPFROMP( cbuffer ) );
  2857.       } else
  2858.       {
  2859.         /************************************************************/
  2860.         /* check to see if the value can be set to 0 (disabled)     */
  2861.         /************************************************************/
  2862.         if (ppmid[i].disable == 1 )
  2863.         {
  2864.           WinSendMsg ( WinWindowFromID ( hwnd, wrtelc04 ),
  2865.                       SPBM_SETLIMITS,
  2866.                       MPFROMLONG ( ppmid[i].maxval ),/* MAX*/
  2867.                       MPFROMLONG ( 0L ) /* MIN*/
  2868.                       );
  2869.         } else
  2870.         {
  2871.           WinSendMsg ( WinWindowFromID ( hwnd, wrtelc04 ),
  2872.                       SPBM_SETLIMITS,
  2873.                       MPFROMLONG ( ppmid[i].maxval ),/* MAX*/
  2874.                       MPFROMLONG ( ppmid[i].minval ) /* MIN*/
  2875.                       );
  2876.         } /* endif */
  2877.         /*********************************************************/
  2878.         /* Set the spin button value to the value that was query */
  2879.         /* from the system.                                      */
  2880.         /*********************************************************/
  2881.         WinSendMsg ( WinWindowFromID ( hwnd, wrtelc04 ),
  2882.                     SPBM_SETCURRENTVALUE,
  2883.                     MPFROMLONG ( ppmid[i].value ),
  2884.                     0L
  2885.                     );
  2886.         /*********************************************************/
  2887.         /* set the spin button's maximum and minimum values for  */
  2888.         /* the users to choose from.                             */
  2889.         /*********************************************************/
  2890.         WinSendMsg ( WinWindowFromID ( hwnd, wrtelc04 ),
  2891.                     SPBM_OVERRIDESETLIMITS,
  2892.                     MPFROMLONG ( ppmid[i].maxval ),/* MAX*/
  2893.                     MPFROMLONG ( ppmid[i].minval ) /* MIN*/
  2894.                     );
  2895.       } /* endif */
  2896.     } /* endif */
  2897. }
  2898.