home *** CD-ROM | disk | FTP | other *** search
- /*---------------------------------------------------------------------------
- TIMELINE.SUB -- Substitute window procedure and new function for TIMELINE
- (c) 1989, Ziff Communications Co.
- PC Magazine * Charles Petzold, November 1988
- ---------------------------------------------------------------------------*/
-
- BOOL MoveWindow (HWND hwndFrame, POINTL *pptlPosition, BOOL fKeyboard)
- {
- TRACKINFO ti ;
-
- WinQueryWindowRect (hwndFrame, &ti.rclTrack) ;
- WinMapWindowPoints (hwndFrame, HWND_DESKTOP, (PPOINTL) &ti.rclTrack, 2) ;
-
- ti.fs = TF_MOVE | TF_STANDARD | TF_ALLINBOUNDARY |
- (fKeyboard ? TF_SETPOINTERPOS : 0) ;
- ti.cxBorder = 1 ;
- ti.cyBorder = 1 ;
- ti.cxKeyboard = 8 ;
- ti.cyKeyboard = 8 ;
-
- ti.ptlMinTrackSize.x = 0 ;
- ti.ptlMinTrackSize.y = 0 ;
- ti.ptlMaxTrackSize.x = ti.rclTrack.xRight - ti.rclTrack.xLeft ;
- ti.ptlMaxTrackSize.y = ti.rclTrack.yTop - ti.rclTrack.yBottom ;
-
- ti.rclBoundary.xLeft = 0 ;
- ti.rclBoundary.yBottom = 0 ;
- ti.rclBoundary.xRight = WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN) ;
- ti.rclBoundary.yTop = WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN) ;
-
- if (WinTrackRect (HWND_DESKTOP, NULL, &ti))
- {
- pptlPosition->x = ti.rclTrack.xLeft ;
- pptlPosition->y = ti.rclTrack.yBottom ;
-
- return TRUE ;
- }
- return FALSE ;
- }
-
- MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
- {
- static CHAR szAppName[] = "TIMELINE",
- szKeyName[] = "POSITION" ;
- static HWND hwndFrame ;
- HPS hps;
- POINTL ptlPosition ;
- SHORT sDataSize ;
-
- switch (msg)
- {
- case WM_CREATE:
- SizeWindow (hwnd) ;
-
- hwndFrame = WinQueryWindow (hwnd, QW_PARENT, FALSE) ;
- sDataSize = sizeof ptlPosition ;
-
- if (WinQueryProfileData (hab, szAppName, szKeyName,
- &ptlPosition, &sDataSize))
-
- WinSetWindowPos (hwndFrame, NULL, (SHORT) ptlPosition.x,
- (SHORT) ptlPosition.y,
- 0, 0, SWP_MOVE) ;
-
- WinStartTimer (hab, hwnd, ID_TIMER, 1000) ;
- return 0 ;
-
- case WM_TIMER:
- hps = WinGetPS (hwnd) ;
-
- UpdateTime (hwnd, hps) ;
-
- WinReleasePS (hps) ;
- return 0 ;
-
- case WM_CHAR:
- if (!(CHARMSG(&msg)->fs & KC_VIRTUALKEY) ||
- !(CHARMSG(&msg)->fs & KC_ALT) ||
- !(CHARMSG(&msg)->fs & KC_KEYUP) ||
- CHARMSG(&msg)->vkey != VK_F7)
- break ;
- // fall through
- case WM_BUTTON1DOWN:
- WinSetActiveWindow (HWND_DESKTOP, hwnd) ;
-
- if (MoveWindow (hwndFrame, &ptlPosition, msg == WM_CHAR))
- {
- WinSetWindowPos (hwndFrame, NULL, (SHORT) ptlPosition.x,
- (SHORT) ptlPosition.y,
- 0, 0, SWP_MOVE) ;
-
- WinWriteProfileData (hab, szAppName, szKeyName,
- &ptlPosition, sizeof ptlPosition) ;
- }
- return 0 ;
-
- case WM_PAINT:
- hps = WinBeginPaint (hwnd, NULL, NULL) ;
- GpiErase (hps) ;
-
- UpdateTime (hwnd, hps) ;
-
- WinEndPaint (hps) ;
- return 0 ;
-
- case WM_DESTROY:
- WinStopTimer (hab, hwnd, ID_TIMER) ;
- return 0 ;
- }
- return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
- }
-