home *** CD-ROM | disk | FTP | other *** search
/ MORE WinGames / WINGAMES.iso / winpool / dlgs.c < prev    next >
C/C++ Source or Header  |  1992-07-21  |  7KB  |  374 lines

  1.  
  2. /*
  3.  * I. ARIT 1992 Hidirbeyli,AYDIN,TR.  09400 Golden,    CO,   USA. 80401 
  4.  *
  5.  *
  6.  * Copyright (C) 1992 Ismail ARIT 
  7.  *
  8.  * This file is distributed in the hope that it will be useful,but without any
  9.  * warranty.  No author or distributor accepts responsibility to anyone for
  10.  * the consequences of using it or for whether it serves any particular
  11.  * purpose or works at all. 
  12.  *
  13.  *
  14.  * Everyone is granted permission to copy, modify and redistribute this file
  15.  * under the following conditions: 
  16.  *
  17.  * Permission is granted to anyone to make or distribute copies of the source
  18.  * code, either as received or modified, in any medium, provided that all
  19.  * copyright notices, permission and nonwarranty notices are preserved, and
  20.  * that the distributor grants the recipient permission for further
  21.  * redistribution as permitted by this document.
  22.  *
  23.  * No part of this program can be used in any commercial product.
  24.  */
  25.  
  26.  
  27.  
  28. #include <windows.h>
  29. #include <stdlib.h>
  30. #include "definiti.h"
  31.  
  32.  
  33.  
  34. TwoPlayer       My;
  35.  
  36. extern HWND hWndMain;
  37. extern HWND DialogWinHandle ;
  38. extern int WantsTrajectory ;
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. BOOL FAR PASCAL
  46. PlayersHandleDlgProc(hDlg, iMessage, wParam, lParam)
  47.     HWND            hDlg;
  48.     WORD            iMessage;
  49.     WORD            wParam;
  50.     LONG            lParam;
  51. {
  52.  
  53.  
  54.  
  55.     switch (iMessage) {
  56.     case WM_INITDIALOG:
  57.  
  58.         SetDlgItemText(hDlg, PLAYER1, My.Player1String);
  59.         SetDlgItemText(hDlg, PLAYER2, My.Player2String);
  60.  
  61.         break;
  62.  
  63.  
  64.  
  65.     case WM_COMMAND:
  66.         switch (wParam) {
  67.         case PLAYER1:
  68.             if (HIWORD(lParam) == EN_CHANGE) {
  69.                 EnableWindow(GetDlgItem(hDlg, IDOK),
  70.                       (BOOL) SendMessage(LOWORD(lParam),
  71.                           WM_GETTEXTLENGTH, 0, 0L));
  72.             }
  73.             break;
  74.  
  75.         case PLAYER2:
  76.             if (HIWORD(lParam) == EN_CHANGE) {
  77.                 EnableWindow(GetDlgItem(hDlg, IDOK),
  78.                       (BOOL) SendMessage(LOWORD(lParam),
  79.                           WM_GETTEXTLENGTH, 0, 0L));
  80.             }
  81.             break;
  82.  
  83.  
  84.  
  85.  
  86.  
  87.         case PLAYER_OK:
  88.  
  89.             GetDlgItemText(hDlg, PLAYER1, My.Player1String, 30);
  90.             GetDlgItemText(hDlg, PLAYER2, My.Player2String, 30);
  91.             EndDialog(hDlg, TRUE);
  92.             break;
  93.  
  94.  
  95.  
  96.  
  97.         case PLAYER_CANSEL:
  98.             /* Terminate this dialog box. */
  99.             EndDialog(hDlg, FALSE);
  100.             break;
  101.  
  102.  
  103.  
  104.         default:
  105.             return (FALSE);
  106.         }        /* end of switch  wParam */
  107.         break;
  108.  
  109.     default:
  110.         return (FALSE);
  111.     }
  112.  
  113.     return (TRUE);
  114. }
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121. int 
  122. GetPlayersName(HANDLE hinst, HWND hwnd)
  123. {
  124.  
  125.     int             iReturn;
  126.     FARPROC         lpfnHandleDlgProc;
  127.  
  128.  
  129.  
  130.     lpfnHandleDlgProc = MakeProcInstance(PlayersHandleDlgProc, hinst);
  131.  
  132.     iReturn = DialogBox(hinst,
  133.                 MAKEINTRESOURCE(PLAYERS),
  134.                 hwnd,
  135.                 lpfnHandleDlgProc);
  136.  
  137.     FreeProcInstance(lpfnHandleDlgProc);
  138.  
  139.     return (iReturn);
  140. }
  141.  
  142.  
  143.  
  144.  
  145. BOOL FAR PASCAL 
  146. ScoresHandleDlgProc(hDlg, iMessage, wParam, lParam)
  147.     HWND            hDlg;
  148.     WORD            iMessage;
  149.     WORD            wParam;
  150.     LONG            lParam;
  151. {
  152.     char            temp[30];
  153.  
  154.  
  155.  
  156.     switch (iMessage) {
  157.     case WM_INITDIALOG:
  158.         wsprintf(temp, "%d", My.Player1Score);
  159.         SetDlgItemText(hDlg, PLAYER1_SCORE, temp);
  160.  
  161.         wsprintf(temp, "%d", My.Player2Score);
  162.         SetDlgItemText(hDlg, PLAYER2_SCORE, temp);
  163.  
  164.         break;
  165.  
  166.  
  167.  
  168.     case WM_COMMAND:
  169.         switch (wParam) {
  170.         case PLAYER1_SCORE:
  171.             if (HIWORD(lParam) == EN_CHANGE) {
  172.                 EnableWindow(GetDlgItem(hDlg, IDOK),
  173.                       (BOOL) SendMessage(LOWORD(lParam),
  174.                           WM_GETTEXTLENGTH, 0, 0L));
  175.             }
  176.             break;
  177.  
  178.         case PLAYER2_SCORE:
  179.             if (HIWORD(lParam) == EN_CHANGE) {
  180.                 EnableWindow(GetDlgItem(hDlg, IDOK),
  181.                       (BOOL) SendMessage(LOWORD(lParam),
  182.                           WM_GETTEXTLENGTH, 0, 0L));
  183.             }
  184.             break;
  185.  
  186.  
  187.  
  188.  
  189.         case PLAYER1_PLUS:
  190.             GetDlgItemText(hDlg, PLAYER1_SCORE, temp, 30);
  191.             My.Player1Score = atoi(temp);
  192.  
  193.             My.Player1Score += 1;
  194.             wsprintf(temp, "%d", My.Player1Score);
  195.             SetDlgItemText(hDlg, PLAYER1_SCORE, temp);
  196.             break;
  197.  
  198.  
  199.         case PLAYER1_MINUS:
  200.             GetDlgItemText(hDlg, PLAYER1_SCORE, temp, 30);
  201.             My.Player1Score = atoi(temp);
  202.  
  203.             My.Player1Score -= 1;
  204.             wsprintf(temp, "%d", My.Player1Score);
  205.             SetDlgItemText(hDlg, PLAYER1_SCORE, temp);
  206.             break;
  207.  
  208.  
  209.  
  210.  
  211.  
  212.         case PLAYER2_PLUS:
  213.             GetDlgItemText(hDlg, PLAYER2_SCORE, temp, 30);
  214.             My.Player2Score = atoi(temp);
  215.  
  216.             My.Player2Score += 1;
  217.             wsprintf(temp, "%d", My.Player2Score);
  218.             SetDlgItemText(hDlg, PLAYER2_SCORE, temp);
  219.             break;
  220.  
  221.         case PLAYER2_MINUS:
  222.             GetDlgItemText(hDlg, PLAYER2_SCORE, temp, 30);
  223.             My.Player2Score = atoi(temp);
  224.  
  225.             My.Player2Score -= 1;
  226.             wsprintf(temp, "%d", My.Player2Score);
  227.             SetDlgItemText(hDlg, PLAYER2_SCORE, temp);
  228.             break;
  229.  
  230.  
  231.  
  232.  
  233.         case SCORES_OK:
  234.  
  235.  
  236.             GetDlgItemText(hDlg, PLAYER1_SCORE, temp, 30);
  237.             My.Player1Score = atoi(temp);
  238.             GetDlgItemText(hDlg, PLAYER2_SCORE, temp, 30);
  239.             My.Player2Score = atoi(temp);
  240.             EndDialog(hDlg, TRUE);
  241.             break;
  242.  
  243.  
  244.  
  245.  
  246.         case SCORES_CANSEL:
  247.             /* Terminate this dialog box. */
  248.             EndDialog(hDlg, FALSE);
  249.             break;
  250.  
  251.  
  252.  
  253.         default:
  254.             return (FALSE);
  255.         }        /* end of switch  wParam */
  256.         break;
  257.  
  258.     default:
  259.         return (FALSE);
  260.     }
  261.  
  262.     return (TRUE);
  263. }
  264.  
  265.  
  266. int 
  267. GetScores(HANDLE hinst, HWND hwnd)
  268. {
  269.  
  270.     int             iReturn;
  271.     FARPROC         lpfnHandleDlgProc;
  272.  
  273.  
  274.  
  275.     lpfnHandleDlgProc = MakeProcInstance(ScoresHandleDlgProc, hinst);
  276.  
  277.     iReturn = DialogBox(hinst,
  278.                 MAKEINTRESOURCE(SCORES),
  279.                 hwnd,
  280.                 lpfnHandleDlgProc);
  281.  
  282.     FreeProcInstance(lpfnHandleDlgProc);
  283.  
  284.     return (iReturn);
  285. }
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293. BOOL FAR PASCAL
  294. FloatHandleDlgProc(hDlg, iMessage, wParam, lParam)
  295.     HWND            hDlg;
  296.     WORD            iMessage;
  297.     WORD            wParam;
  298.     LONG            lParam;
  299. {
  300.  
  301.  
  302.  
  303.     switch (iMessage) {
  304.  
  305.  
  306.     case WM_COMMAND:
  307.         switch (wParam) {
  308.  
  309.            case FNewGame :
  310.            SendMessage(hWndMain,WM_COMMAND,NewGame,0L);
  311.            break;
  312.  
  313.  
  314. case FLoadGame :
  315.            SendMessage(hWndMain,WM_COMMAND,LoadGame,0L);
  316.            break;
  317.  
  318.  
  319. case FPlayers   :
  320.            SendMessage(hWndMain,WM_COMMAND,Players,0L);
  321.            break;
  322.  
  323. case FScores    :
  324.            SendMessage(hWndMain,WM_COMMAND,Scores,0L);
  325.            break;
  326.  
  327. case FSaveIt     :
  328.            SendMessage(hWndMain,WM_COMMAND,SaveIt,0L);
  329.            break;
  330.  
  331.  
  332.  
  333. case FAboutBox     :
  334.            SendMessage(hWndMain,WM_COMMAND,AboutBox,0L);
  335.            break;
  336.  
  337. case FTrajectoryMode :
  338.             WantsTrajectory = !WantsTrajectory;
  339.  
  340.             if (WantsTrajectory == YES)
  341.                 SendDlgItemMessage(hDlg, FTrajectoryMode, BM_SETCHECK, TRUE, 0);
  342.             else
  343.                 SendDlgItemMessage(hDlg, FTrajectoryMode, BM_SETCHECK, FALSE, 0);
  344.  
  345.  
  346.            break;
  347.  
  348.  
  349.  
  350.  
  351.           case FExitThisApp :
  352.  
  353.             /* Terminate this dialog box. */
  354.             DestroyWindow(DialogWinHandle);
  355.             SendMessage(hWndMain,WM_CLOSE,0,0L);
  356.             break;
  357.  
  358.  
  359.  
  360.         default:
  361.             return (FALSE);
  362.         }        /* end of switch  wParam */
  363.         break;
  364.  
  365.     default:
  366.         return (FALSE);
  367.     }
  368.  
  369.     return (TRUE);
  370. }
  371.  
  372.  
  373.  
  374.