home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: InfoMgt / InfoMgt.zip / TIMELINE.ZIP / TIMELINE.SUB < prev   
Text File  |  1989-04-13  |  4KB  |  112 lines

  1. /*---------------------------------------------------------------------------
  2.    TIMELINE.SUB -- Substitute window procedure and new function for TIMELINE
  3.                    (c) 1989, Ziff Communications Co.
  4.                    PC Magazine * Charles Petzold, November 1988
  5.   ---------------------------------------------------------------------------*/
  6.  
  7. BOOL MoveWindow (HWND hwndFrame, POINTL *pptlPosition, BOOL fKeyboard)
  8.      {
  9.      TRACKINFO ti ;
  10.  
  11.      WinQueryWindowRect (hwndFrame, &ti.rclTrack) ;
  12.      WinMapWindowPoints (hwndFrame, HWND_DESKTOP, (PPOINTL) &ti.rclTrack, 2) ;
  13.  
  14.      ti.fs = TF_MOVE | TF_STANDARD | TF_ALLINBOUNDARY |
  15.                         (fKeyboard ? TF_SETPOINTERPOS : 0) ;
  16.      ti.cxBorder   = 1 ;
  17.      ti.cyBorder   = 1 ;
  18.      ti.cxKeyboard = 8 ;
  19.      ti.cyKeyboard = 8 ;
  20.  
  21.      ti.ptlMinTrackSize.x = 0 ;
  22.      ti.ptlMinTrackSize.y = 0 ;
  23.      ti.ptlMaxTrackSize.x = ti.rclTrack.xRight - ti.rclTrack.xLeft ;
  24.      ti.ptlMaxTrackSize.y = ti.rclTrack.yTop   - ti.rclTrack.yBottom ;
  25.  
  26.      ti.rclBoundary.xLeft   = 0 ;
  27.      ti.rclBoundary.yBottom = 0 ;
  28.      ti.rclBoundary.xRight  = WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN) ;
  29.      ti.rclBoundary.yTop    = WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN) ;
  30.  
  31.      if (WinTrackRect (HWND_DESKTOP, NULL, &ti))
  32.           {
  33.           pptlPosition->x = ti.rclTrack.xLeft ;
  34.           pptlPosition->y = ti.rclTrack.yBottom ;
  35.  
  36.           return TRUE ;
  37.           }
  38.      return FALSE ;
  39.      }
  40.  
  41. MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
  42.      {
  43.      static CHAR szAppName[] = "TIMELINE",
  44.                  szKeyName[] = "POSITION" ;
  45.      static HWND hwndFrame ;
  46.      HPS         hps;
  47.      POINTL      ptlPosition ;
  48.      SHORT       sDataSize ;
  49.  
  50.      switch (msg)
  51.           {
  52.           case WM_CREATE:
  53.                SizeWindow (hwnd) ;
  54.  
  55.                hwndFrame = WinQueryWindow (hwnd, QW_PARENT, FALSE) ;
  56.                sDataSize = sizeof ptlPosition ;
  57.  
  58.                if (WinQueryProfileData (hab, szAppName, szKeyName,
  59.                                              &ptlPosition, &sDataSize))
  60.  
  61.                     WinSetWindowPos (hwndFrame, NULL, (SHORT) ptlPosition.x,
  62.                                                       (SHORT) ptlPosition.y,
  63.                                                 0, 0, SWP_MOVE) ;
  64.  
  65.                WinStartTimer (hab, hwnd, ID_TIMER, 1000) ;
  66.                return 0 ;
  67.  
  68.           case WM_TIMER:
  69.                hps = WinGetPS (hwnd) ;
  70.  
  71.                UpdateTime (hwnd, hps) ;
  72.  
  73.                WinReleasePS (hps) ;
  74.                return 0 ;
  75.  
  76.           case WM_CHAR:
  77.                if (!(CHARMSG(&msg)->fs & KC_VIRTUALKEY) ||
  78.                    !(CHARMSG(&msg)->fs & KC_ALT)        ||
  79.                    !(CHARMSG(&msg)->fs & KC_KEYUP)      ||
  80.                      CHARMSG(&msg)->vkey != VK_F7)
  81.                          break ;
  82.                                              // fall through
  83.           case WM_BUTTON1DOWN:
  84.                WinSetActiveWindow (HWND_DESKTOP, hwnd) ;
  85.  
  86.                if (MoveWindow (hwndFrame, &ptlPosition, msg == WM_CHAR))
  87.                     {
  88.                     WinSetWindowPos (hwndFrame, NULL, (SHORT) ptlPosition.x,
  89.                                                       (SHORT) ptlPosition.y,
  90.                                                 0, 0, SWP_MOVE) ;
  91.  
  92.                     WinWriteProfileData (hab, szAppName, szKeyName,
  93.                                          &ptlPosition, sizeof ptlPosition) ;
  94.                     }
  95.                return 0 ;
  96.  
  97.           case WM_PAINT:
  98.                hps = WinBeginPaint (hwnd, NULL, NULL) ;
  99.                GpiErase (hps) ;
  100.  
  101.                UpdateTime (hwnd, hps) ;
  102.  
  103.                WinEndPaint (hps) ;
  104.                return 0 ;
  105.  
  106.           case WM_DESTROY:
  107.                WinStopTimer (hab, hwnd, ID_TIMER) ;
  108.                return 0 ;
  109.           }
  110.      return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
  111.      }
  112.