home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sniff16.zip / TESTAPP / WMOUSE.C < prev    next >
C/C++ Source or Header  |  1993-03-12  |  5KB  |  220 lines

  1. /*=========================================================================\
  2.  *                                                                         *
  3.  *       FILE:wmouse.c                                                     *
  4.  *                                                                         *
  5.  *       DESCRIPTION:                                                      *
  6.  *                                                                         *
  7.  *                                                                         *
  8.  *                                                                         *
  9.  *      Created 1991  IBM Corp.                                            *
  10.  *      DISCLAIMER OF WARRANTIES.  The following [enclosed] code is        *
  11.  *      sample code created by IBM Corporation. This sample code is not    *
  12.  *      part of any standard or IBM product and is provided to you solely  *
  13.  *      for  the purpose of assisting you in the development of your       *    *
  14.  *      applications.  The code is provided "AS IS", without               *
  15.  *      warranty of any kind.  IBM shall not be liable for any damages     *
  16.  *      arising out of your use of the sample code, even if they have been *
  17.  *      advised of the possibility of   such damages.                      *                               *
  18.  *                                                                         *
  19.  *-------------------------------------------------------------------------*
  20.  *
  21.  *
  22.  *
  23.  *
  24.  *
  25.  *
  26.  *
  27.  *
  28.  *
  29.  *
  30.  *
  31.  *--------------------------------------------------------------
  32.  *
  33.  *  This source file contains the following functions:
  34.  *
  35.  *
  36.  *
  37.  *
  38.  *
  39. \*==============================================================*/
  40.  
  41. /*--------------------------------------------------------------*\
  42.  *  Include files, macros, defined constants, and externs
  43. \*--------------------------------------------------------------*/
  44. #define  INCL_DOS
  45. #define  INCL_VIO
  46. #define  INCL_KBD
  47. #define  INCL_MOU
  48. #define  INCL_DOSPROCESS
  49.  
  50. #include <os2.h>
  51. #include <stdio.h>
  52. #include <string.h>
  53. #include <stddef.h>
  54. #include <string.h>
  55. #include <stdlib.h>
  56. #include "worms.h"
  57. #include "wrmthrd.h"
  58. #include "wrmhelp.h"
  59.  
  60.  
  61.  
  62. /*--------------------------------------------------------------*\
  63.  *  Global variables  and definitions for this file
  64. \*--------------------------------------------------------------*/
  65.  
  66. MOUEVENTINFO mouev;
  67. HMOU hmou;
  68. /*--------------------------------------------------------------*\
  69.  *  Entry point declarations
  70. \*--------------------------------------------------------------*/
  71. VOID WmouseFunctions(SHORT sCol);
  72. /****************************************************************\
  73.  *  Routine Name:
  74.  *--------------------------------------------------------------
  75.  *
  76.  *  Name:
  77.  *
  78.  *  Purpose:
  79.  *
  80.  *
  81.  *
  82.  *  Usage:
  83.  *
  84.  *  Method:
  85.  *          -
  86.  *
  87.  *          -
  88.  *          -
  89.  *
  90.  *          -
  91.  *          -
  92.  *
  93.  *  Returns:
  94.  *
  95.  *
  96. \****************************************************************/
  97. VOID WReadMouse(PVOID pvMessageData)
  98. {
  99.  
  100.      USHORT fWait = MOU_WAIT;
  101.      NOPTRRECT mourt = { 0,0,24,79 };
  102.  
  103.  
  104.      /*
  105.       *open the handle
  106.       *for the mouse
  107.       */
  108.      MouOpen(NULL,&hmou);
  109.      MouDrawPtr(hmou);
  110.  
  111.      do
  112.      {
  113.           /*
  114.            *sit and wait on
  115.            *the event queue
  116.            */
  117.           MouReadEventQue(&mouev,&fWait,hmou);
  118.  
  119.           if(mouev.time && !bHelpEnabled)
  120.           {
  121.                if(mouev.fs & MOUSE_BN1_DOWN )
  122.                {
  123.                     MouRemovePtr(&mourt,hmou);
  124.                     /*
  125.                      *if the button is clicked
  126.                      *on any of the available functions
  127.                      */
  128.                     if(mouev.row == (TOP_ROW + 2) )
  129.                     {
  130.                          WmouseFunctions(mouev.col);
  131.                     }
  132.  
  133.                }
  134.                MouDrawPtr(hmou);
  135.           }
  136.  
  137.      }while(!fQuit );
  138.  
  139.  
  140.      DosExit(EXIT_THREAD, 0L );
  141. }
  142.  
  143. /****************************************************************\
  144.  *
  145.  *--------------------------------------------------------------
  146.  *
  147.  *  Name:
  148.  *
  149.  *  Purpose:
  150.  *
  151.  *
  152.  *
  153.  *  Usage:
  154.  *
  155.  *  Method:
  156.  *          -
  157.  *
  158.  *          -
  159.  *          -
  160.  *
  161.  *          -
  162.  *          -
  163.  *
  164.  *  Returns:
  165.  *          VOID
  166.  *
  167. \****************************************************************/
  168. VOID WmouseFunctions(SHORT sCol)
  169. {
  170.  
  171.      /*
  172.       *the add selection
  173.       */
  174.      if(sCol >= 5  && sCol <= 7)
  175.      {
  176.           WormCreate();
  177.      }
  178.      /*
  179.       *the delete
  180.       *key
  181.       */
  182.      else if(sCol >= 22 && sCol  <=  27)
  183.      {
  184.           WormDelete();
  185.      }
  186.      /*
  187.       *exit the process
  188.       */
  189.      else if(sCol >= 47 && sCol  <=  50 )
  190.      {
  191.  
  192.          /*
  193.           *display hit any key to exit
  194.           */
  195.          fQuit = TRUE;
  196.          Message(ENTER_TO_EXIT,FALSE,FALSE,TRUE,TRUE);
  197.      }
  198.  
  199.      /*
  200.       *the help menu
  201.       */
  202.      else if(sCol >= 62 && sCol  <=  65 )
  203.      {
  204.  
  205.         if( WormHelp() )
  206.         {
  207.                ErrorMessage(ERROR_DISP_HELP,TRUE);
  208.         }
  209.      }
  210.      else
  211.      {
  212.           DosBeep(600,175);
  213.      }
  214.  
  215.  
  216. }
  217. /*--------------------------------------------------------------*\
  218.  *  End of file : wmouse.c
  219. \*--------------------------------------------------------------*/
  220.