home *** CD-ROM | disk | FTP | other *** search
/ PC Shareware 1996 December / PC_Shareware-1996-12.iso / windows / spectrum / sources / speed.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-16  |  2.6 KB  |  93 lines

  1.  
  2. /* Speed.c: Speed dialog interface implementation.
  3.  *
  4.  * Copyright 1996 Rui Fernando Ferreira Ribeiro.
  5.  *
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2 of the License, or
  9.  * (at your option) any later version.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program; if not, write to the Free Software
  18.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21. #include <windows.h>
  22. #include "wspecem.h"            // Local header
  23. #include "env.h"
  24.  
  25. //   determine wich value there's on the box, and if there is one, return
  26. // it
  27. static BOOL ReadInt(HWND hwnd,int Control,unsigned short Min,
  28.             unsigned short  Max, unsigned short *Val)
  29. {
  30.     BOOL fError;
  31.     int n;
  32.  
  33.     n=(int)GetDlgItemInt(hwnd,Control,&fError,FALSE);
  34.     if (!fError || (n < Min) || (n > Max))
  35.     return(TRUE);
  36.     else
  37.     *Val=n;
  38.     return(FALSE);
  39. }
  40.  
  41. // dispatcher : handle the dialog
  42. BOOL CALLBACK DoSpeed(HWND hwnd,UINT Message,WPARAM wParam,LPARAM lParam)
  43.     char szBuffer[7];
  44.  
  45.     switch(Message)
  46.     {
  47.        case WM_INITDIALOG:
  48.       wsprintf((LPSTR)szBuffer, "%u", DelayEmVal);
  49.       SendDlgItemMessage(hwnd,IDC_DELAY,WM_SETTEXT,
  50.             0,(LPARAM)(LPSTR)szBuffer);
  51.       wsprintf((LPSTR)szBuffer, "%u", ScreenUpdate);
  52.       SendDlgItemMessage(hwnd,IDC_FRAMES,WM_SETTEXT,
  53.             0,(LPARAM)(LPSTR)szBuffer);
  54.       return(TRUE);
  55.  
  56.        case WM_COMMAND:
  57.       switch(wParam)
  58.       {
  59.          unsigned short frames;
  60.  
  61.          case IDOK:
  62.         if(ReadInt(hwnd,IDC_DELAY,0,65535,&DelayEmVal))
  63.         {
  64.            MessageBeep(MB_ICONEXCLAMATION);
  65.            MessageBox(hwnd, "Address must be between 16384 and 65535.",
  66.               "Speed", MB_OK | MB_ICONEXCLAMATION);
  67.            SetFocus(GetDlgItem(hwnd, IDC_ADDRESS) );
  68.            return(TRUE);
  69.         }
  70.  
  71.         if(ReadInt(hwnd,IDC_FRAMES,1,127,&frames))
  72.         {
  73.            MessageBeep(MB_ICONEXCLAMATION);
  74.            MessageBox(hwnd, "Value must be between 1 and 127.",
  75.               "Speed", MB_OK | MB_ICONEXCLAMATION);
  76.            SetFocus(GetDlgItem(hwnd, IDC_VALUE) );
  77.            return(TRUE);
  78.         }
  79.         ScreenUpdate = frames;
  80.         EndDialog(hwnd,1);
  81.         return(TRUE);
  82.  
  83.          case IDCANCEL:
  84.         EndDialog(hwnd,0);
  85.         return(TRUE);
  86.       }
  87.     }
  88.     return(FALSE);
  89. }
  90.  
  91. /* EOF: Speed.c */
  92.