home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 7 Games / 07-Games.zip / 32PMCHES.ZIP / PROMOTE.C < prev    next >
Text File  |  1990-12-17  |  4KB  |  132 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:    1.02  1990-12-17
  8. //
  9. //   Module:    Promote User Query Dialog (Promote.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. //   Update:    Fixes and enhancements by Benny N. Ormson
  16. //
  17. //   System:    OS2 1.2 using Microsoft C 6.0
  18. //
  19. //  Remarks:    This code converted from Windows to PM using a straight port
  20. //              method with some editing improvements.
  21. //
  22. //  License:
  23. //
  24. //    CHESS is distributed in the hope that it will be useful, but WITHOUT ANY
  25. //    WARRANTY.  No author or distributor accepts responsibility to anyone for
  26. //    the consequences of using it or for whether it serves any particular
  27. //    purpose or works at all, unless he says so in writing.  Refer to the
  28. //    CHESS General Public License for full details.
  29. //
  30. //    Everyone is granted permission to copy, modify and redistribute CHESS,
  31. //    but only under the conditions described in the CHESS General Public
  32. //    License.  A copy of this license is supposed to have been given to you
  33. //    along with CHESS so you can know your rights and responsibilities.  It
  34. //    should be in a file named COPYING.  Among other things, the copyright
  35. //    notice and this notice must be preserved on all copies.
  36. //
  37.  
  38. #define INCL_DOS
  39. #define INCL_PM
  40. #include <os2.h>
  41. #include <stdio.h>
  42. #include <string.h>
  43. #include "PmChess.h"
  44. #include "GnuChess.h"
  45. #include "Resource.h"
  46.  
  47.  
  48. //
  49. //  Define dialog procedure's prototypes.
  50. //
  51. MRESULT EXPENTRY PromoteProc(HWND hWnd, USHORT msg, MPARAM mp1, MPARAM mp2);
  52.  
  53.  
  54. //***************************************************************************
  55. //
  56. //  Routine: PromoteDialog(In)
  57. //
  58. //  Remarks: This routine displays a dialog that queries the user of which
  59. //           type of piece to promote a pawn.
  60. //
  61. //  Returns: The piece selected.
  62. //
  63. SHORT PromoteDialog(HWND hWnd)
  64.   {
  65.   SHORT status;
  66.  
  67.  
  68.   status = (INT)(LONG)WinDlgBox(HWND_DESKTOP, hWnd, PromoteProc, 0,
  69.                                 IDD_PROMOTE, NULL);
  70.  
  71.   return (status);
  72.   }
  73.  
  74.  
  75. //***************************************************************************
  76. //
  77. //  Routine: PromoteProc(In, In, In, In)
  78. //
  79. //  Remarks: This routine displays a dialog that queries the user of which
  80. //           type of piece to promote a pawn.
  81. //
  82. //  Returns: Depends on the message.
  83. //
  84. MRESULT EXPENTRY PromoteProc(HWND hDlg, USHORT msg, MPARAM mp1, MPARAM mp2)
  85.   {
  86.   SHORT idItem;
  87.  
  88.  
  89.   switch (msg)
  90.     {
  91.     case WM_INITDLG:
  92.       WinSendDlgItemMsg(hDlg, IDC_PROMOTE_QUEEN, BM_SETCHECK, MPFROMSHORT(TRUE), NULL);
  93.       return (FALSE);
  94.  
  95.     case WM_COMMAND:
  96.       switch (SHORT1FROMMP(mp1))
  97.         {
  98.         case IDC_OK:
  99.           idItem = (SHORT)(LONG)WinSendDlgItemMsg(hDlg, IDC_PROMOTE_QUEEN,
  100.                                            BM_QUERYCHECKINDEX, NULL, NULL);
  101.           switch (idItem)
  102.             {
  103.             case 0:
  104.               idItem = queen;           /* Ormson 12/07/90           */
  105.               break;
  106.  
  107.             case 1:
  108.               idItem = rook;            /* Ormson 12/07/90           */
  109.               break;
  110.  
  111.             case 2:
  112.               idItem = bishop;          /* Ormson 12/07/90           */
  113.               break;
  114.  
  115.             default:
  116.               idItem = knight;          /* Ormson 12/07/90           */
  117.               break;
  118.             }
  119.  
  120.           WinDismissDlg(hDlg, idItem);
  121.           break;
  122.  
  123.         case IDC_CANCEL:
  124.           WinDismissDlg(hDlg, FALSE);
  125.           break;
  126.         }
  127.       return (0);
  128.     }
  129.  
  130.   return (WinDefDlgProc(hDlg, msg, mp1, mp2));
  131.   }
  132.