home *** CD-ROM | disk | FTP | other *** search
/ MORE WinGames / WINGAMES.iso / chess / numdlg.c < prev    next >
C/C++ Source or Header  |  1991-06-16  |  3KB  |  93 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 <string.h>
  37. #include "chess.h"
  38.  
  39. #define IDD_INT 0x10
  40. #define IDD_CHAR 0x11
  41.  
  42. static int   NumberDlgInt;
  43. static char  NumberDlgChar[80];
  44.  
  45. int FAR DoGetNumberDlg (HANDLE hInst, HWND hWnd, char * szPrompt, int def);
  46.  
  47. BOOL FAR PASCAL NumberDlgDlgProc (HWND hDlg, unsigned iMessage,
  48.                                   WORD wParam, LONG lParam)
  49. {
  50.    int temp, Ier;
  51.    switch ( iMessage ){
  52.       case WM_INITDIALOG:
  53.          SetDlgItemText (hDlg, IDD_CHAR, (LPSTR) NumberDlgChar);
  54.          SetDlgItemInt ( hDlg, IDD_INT, NumberDlgInt, TRUE);
  55.          return TRUE;
  56.  
  57.       case WM_COMMAND:
  58.          switch (wParam) {
  59.             case IDOK:
  60.                temp = GetDlgItemInt (hDlg, IDD_INT, &Ier, TRUE);
  61.                if ( Ier != 0 ) {
  62.                   NumberDlgInt = temp;
  63.                   EndDialog ( hDlg, TRUE);
  64.                }
  65.                break;
  66.  
  67.             case IDCANCEL:
  68.                EndDialog ( hDlg, TRUE);
  69.                break;
  70.  
  71.             default: return FALSE;
  72.  
  73.          }
  74.  
  75.       default: return FALSE;
  76.    }
  77.    return TRUE;
  78. }
  79.  
  80. int FAR DoGetNumberDlg (HANDLE hInst, HWND hWnd, char * szPrompt, int def)
  81. {
  82.    FARPROC lpfnNumberDlgProc;
  83.  
  84.    strcpy ( NumberDlgChar, szPrompt);
  85.    NumberDlgInt = def;
  86.  
  87.    lpfnNumberDlgProc = MakeProcInstance ( NumberDlgDlgProc, hInst);
  88.    DialogBox ( hInst, MAKEINTRESOURCE(NUMBERDLG), hWnd, lpfnNumberDlgProc);
  89.    FreeProcInstance ( lpfnNumberDlgProc);
  90.  
  91.    return NumberDlgInt;
  92. }
  93.