home *** CD-ROM | disk | FTP | other *** search
/ The Best of Select: Games 3 / cd.iso / os2 / pmgnuchs / numdlg.c < prev    next >
Text File  |  1994-01-05  |  2KB  |  78 lines

  1. //
  2. //  Copyright (C) 1986, 1987, 1988, 1989, 1990 Free Software Foundation, Inc.
  3. //  Copyright (c) 1988, 1989, 1990  John Stanback
  4. //
  5. //  Project:    OS/2 PM Port of GNU CHESS 3.1 (PmChess)
  6. //
  7. //  Version:    1990-11-17
  8. //
  9. //   Module:    Init/Update Menu Logic (MenuInit.c)
  10. //
  11. //   Porter:    Ported to Windows 3.0 by Darly Baker
  12. //
  13. //   Porter:    Ported to OS/2 1.2+ by Kent Cedola
  14. //
  15. //   System:    OS2 1.2 using Microsoft C 6.0
  16. //
  17. //  Remarks:    This code converted from Windows to PM using a straight port
  18. //              method with some editing improvements.
  19. //
  20.  
  21. #define INCL_DOS
  22. #define INCL_PM
  23. #include <os2.h>
  24. #include <string.h>
  25. #include "PmChess.h"
  26. #include "Resource.h"
  27.  
  28.  
  29. static short NumberDlgInt;
  30. static char  NumberDlgChar[80];
  31.  
  32. int DoGetNumberDlg (HWND hWnd, char * szPrompt, int def);
  33.  
  34. MRESULT EXPENTRY NumberProc(HWND hDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  35.   {
  36.   short temp, Ier;
  37.  
  38.  
  39.   switch (msg)
  40.     {
  41.     case WM_INITDLG:
  42.       WinSetDlgItemText(hDlg, IDC_NUMDLG_CHAR, NumberDlgChar);
  43.       WinSetDlgItemShort(hDlg, IDC_NUMDLG_INT, NumberDlgInt, TRUE);
  44.       return (FALSE);
  45.  
  46.     case WM_COMMAND:
  47.       switch (SHORT1FROMMP(mp1))
  48.         {
  49.         case IDC_OK:
  50.           if (WinQueryDlgItemShort(hDlg, IDC_NUMDLG_INT, &temp, TRUE))
  51.             {
  52.             NumberDlgInt = temp;
  53.             WinDismissDlg(hDlg, TRUE);
  54.             }
  55.           break;
  56.  
  57.         case IDC_CANCEL:
  58.           WinDismissDlg(hDlg, FALSE);
  59.           break;
  60.         }
  61.       return (0);
  62.     }
  63.  
  64.   return (WinDefDlgProc(hDlg, msg, mp1, mp2));
  65.   }
  66.  
  67.  
  68. int DoGetNumberDlg(HWND hWnd, char * szPrompt, int def)
  69. {
  70.  
  71.    strcpy ( NumberDlgChar, szPrompt);
  72.    NumberDlgInt = def;
  73.  
  74.    WinDlgBox(HWND_DESKTOP, hWnd, NumberProc, 0, IDD_NUMDLG, NULL);
  75.  
  76.    return NumberDlgInt;
  77. }
  78.