home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / os2sdk / os2sdk11 / petzold / chap17 / bigjob.c next >
Encoding:
C/C++ Source or Header  |  1989-02-20  |  1.8 KB  |  52 lines

  1. /*--------------------------------------------------------------------
  2.    BIGJOB.C -- Common functions used in BIGJOB1, BIGJOB2, and BIGJOB3
  3.   --------------------------------------------------------------------*/
  4.  
  5. #define INCL_WIN
  6. #include <os2.h>
  7. #include <math.h>
  8. #include <stdio.h>
  9.  
  10. double Savage (double A)
  11.      {
  12.      return tan (atan (exp (log (sqrt (A * A))))) + 1.0 ;
  13.      }
  14.  
  15. VOID CheckMenuItem (HWND hwnd, SHORT sMenuItem, BOOL fCheck)
  16.      {
  17.      HWND  hwndParent = WinQueryWindow (hwnd, QW_PARENT, FALSE) ;
  18.      HWND  hwndMenu   = WinWindowFromID (hwndParent, FID_MENU) ;
  19.  
  20.      WinSendMsg (hwndMenu, MM_SETITEMATTR,
  21.                  MPFROM2SHORT (sMenuItem, TRUE),
  22.                  MPFROM2SHORT (MIA_CHECKED, fCheck ? MIA_CHECKED : 0)) ;
  23.      }
  24.  
  25. VOID EnableMenuItem (HWND hwnd, SHORT sMenuItem, BOOL fEnable)
  26.      {
  27.      HWND  hwndParent = WinQueryWindow (hwnd, QW_PARENT, FALSE) ;
  28.      HWND  hwndMenu   = WinWindowFromID (hwndParent, FID_MENU) ;
  29.  
  30.      WinSendMsg (hwndMenu, MM_SETITEMATTR,
  31.                  MPFROM2SHORT (sMenuItem, TRUE),
  32.                  MPFROM2SHORT (MIA_DISABLED, fEnable ? 0 : MIA_DISABLED)) ;
  33.      }
  34.  
  35. VOID PaintWindow (HWND hwnd, SHORT sStatus, LONG lCalcRep, ULONG ulTime)
  36.      {
  37.      static CHAR *szMessage [3] = { "Ready", "Working...",
  38.                                     "%ld repetitions in %lu msec." } ;
  39.      CHAR        szBuffer [60] ;
  40.      HPS         hps ;
  41.      RECTL       rcl ;
  42.  
  43.      hps = WinBeginPaint (hwnd, NULL, NULL) ;
  44.      WinQueryWindowRect (hwnd, &rcl) ;
  45.  
  46.      sprintf (szBuffer, szMessage [sStatus], lCalcRep, ulTime) ;
  47.      WinDrawText (hps, -1, szBuffer, &rcl, CLR_NEUTRAL, CLR_BACKGROUND,
  48.                   DT_CENTER | DT_VCENTER | DT_ERASERECT) ;
  49.  
  50.      WinEndPaint (hps) ;
  51.      }
  52.