home *** CD-ROM | disk | FTP | other *** search
/ MORE WinGames / WINGAMES.iso / chess / timecnt.c < prev    next >
C/C++ Source or Header  |  1991-06-16  |  4KB  |  118 lines

  1. /*
  2.   C source for GNU CHESS
  3.  
  4.   Revision: 1990-09-30
  5.  
  6.   Modified by Daryl Baker for use in MS WINDOWS environment
  7.  
  8.   This file is part of CHESS.
  9.  
  10.   CHESS is distributed in the hope that it will be useful, but WITHOUT ANY
  11.   WARRANTY.  No author or distributor accepts responsibility to anyone for
  12.   the consequences of using it or for whether it serves any particular
  13.   purpose or works at all, unless he says so in writing.  Refer to the CHESS
  14.   General Public License for full details.
  15.  
  16.   Everyone is granted permission to copy, modify and redistribute CHESS, but
  17.   only under the conditions described in the CHESS General Public License.
  18.   A copy of this license is supposed to have been given to you along with
  19.   CHESS so you can know your rights and responsibilities.  It should be in a
  20.   file named COPYING.  Among other things, the copyright notice and this
  21.   notice must be preserved on all copies.
  22. */
  23.  
  24. #define NOATOM 
  25. #define NOCLIPBOARD
  26. #define NOCREATESTRUCT
  27. #define NOFONT
  28. #define NOREGION
  29. #define NOSOUND
  30. #define NOWH
  31. #define NOWINOFFSETS
  32. #define NOCOMM
  33. #define NOKANJI
  34.  
  35. #include <windows.h>
  36. #include "timecnt.h"
  37. #include "chess.h"
  38.  
  39. extern int TCmoves, TCminutes, TCflag;
  40.  
  41. BOOL FAR PASCAL TimeControlDlgProc ( HWND hDlg, unsigned message,
  42.                                WORD wParam, LONG lParam);
  43.  
  44.  
  45. int TimeControlDialog ( HWND hWnd, HANDLE hInst, DWORD Param )
  46. {
  47.    FARPROC lpProcTime;
  48.    int status;
  49.  
  50.    lpProcTime = MakeProcInstance(TimeControlDlgProc, hInst);
  51.     status = DialogBoxParam (hInst, MAKEINTRESOURCE(TIMECONTROL),   hWnd,  lpProcTime, Param);
  52.    FreeProcInstance(lpProcTime);
  53.    return status;
  54. }
  55.  
  56. static int tmpTCmoves;
  57. static int tmpTCminutes;
  58.  
  59. BOOL FAR PASCAL TimeControlDlgProc ( HWND hDlg, unsigned message,
  60.                                WORD wParam, LONG lParam)
  61. {
  62.  
  63.    switch (message) {
  64.        case WM_INITDIALOG:           /* message: initialize dialog box */
  65.  
  66.          CheckRadioButton ( hDlg, TMDLG_1MOV, TMDLG_60MOV, TCmoves+TMDLG_MOV);
  67.          CheckRadioButton ( hDlg, TMDLG_5MIN, TMDLG_600MIN, TCminutes+TMDLG_MIN);
  68.          tmpTCminutes = TCminutes;
  69.          tmpTCmoves   = TCmoves;
  70.          return (TRUE);
  71.  
  72.       case WM_SYSCOMMAND:
  73.          if ( (wParam&0xfff0) == SC_CLOSE ) {
  74.                  EndDialog(hDlg, NULL);
  75.                  return TRUE;
  76.          }
  77.          break;
  78.  
  79.  
  80.        case WM_COMMAND:              /* message: received a command */
  81.          switch (wParam) {
  82.          
  83.             case IDOK:
  84.                TCminutes = tmpTCminutes;
  85.                TCmoves   = tmpTCmoves;
  86.                  EndDialog(hDlg, 1);
  87.                  return TRUE;
  88.                break;
  89.  
  90.              case IDCANCEL:
  91.                  EndDialog(hDlg, NULL);
  92.                  return TRUE;
  93.                break;
  94.  
  95.             case TMDLG_1MOV:
  96.             case TMDLG_10MOV:
  97.             case TMDLG_20MOV:
  98.             case TMDLG_40MOV:
  99.             case TMDLG_60MOV:
  100.                   tmpTCmoves = wParam - TMDLG_MOV;       
  101.                   CheckRadioButton ( hDlg, TMDLG_1MOV, TMDLG_60MOV, wParam);
  102.                   break;
  103.  
  104.             case TMDLG_5MIN:
  105.             case TMDLG_15MIN:
  106.             case TMDLG_30MIN:
  107.             case TMDLG_60MIN:
  108.             case TMDLG_600MIN:
  109.                   tmpTCminutes = wParam - TMDLG_MIN;
  110.                   CheckRadioButton ( hDlg, TMDLG_5MIN, TMDLG_600MIN, wParam);
  111.                   break;
  112.          }
  113.           break;
  114.     }
  115.  
  116.     return (FALSE);                  /* Didn't process a message    */
  117. }
  118.