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