home *** CD-ROM | disk | FTP | other *** search
- //
- // Filename: cscrnsvr.cpp
- //
- //
- /*
-
- This is a screen saver which uses colormap animation, a simple technique
- to achieve seemingly complicated motion. The entire source of this
- program is provided for your convenience. If you find it useful, I'll
- appreciate if you'll send me $10. Send the check to:
-
- CMAP registration
- c/o: Sin-Yaw Wang
- 5878 W. Walbrook Dr.
- San Jose, CA 95129
-
- You can also contact me at sinyaw@netcom.com.
-
-
- */
- #include <afxwin.h>
- #include "cscrnsvr.h"
-
- void
- CScreenSaverWindow::OnDestroy()
- {
- PostQuitMessage(0);
- }
-
- void
- CScreenSaverWindow::OnMouseMove(UINT, CPoint)
- {
- static BOOL fHere;
- static POINT ptLast;
- POINT ptCursor,ptCheck;
-
- if (!fHere) {
- GetCursorPos (&ptLast);
- fHere = TRUE;
- } else {
- GetCursorPos (&ptCheck);
-
- if (ptCursor.x = ptCheck.x - ptLast.x) {
- if (ptCursor.x < 0) {
- ptCursor.x *= -1;
- }
- }
- if (ptCursor.y = ptCheck.y - ptLast.y) {
- if (ptCursor.y < 0) {
- ptCursor.y *= -1;
- }
- }
- if ((ptCursor.x + ptCursor.y) > THRESHOLD) {
- PostMessage(WM_CLOSE,0,0l);
- }
- } // end-if-else
- }
-
- BOOL
- CScreenSaverWindow::OnSetCursor(CWnd *, UINT, UINT)
- {
- SetCursor(NULL);
-
- return TRUE;
- }
-
-
- BEGIN_MESSAGE_MAP(CScreenSaverWindow, CFrameWnd)
- ON_WM_DESTROY()
- ON_WM_KEYDOWN()
- ON_WM_LBUTTONDOWN()
- ON_WM_MBUTTONDOWN()
- ON_WM_MOUSEMOVE()
- ON_WM_RBUTTONDOWN()
- ON_WM_SETCURSOR()
- ON_WM_SYSKEYDOWN()
- END_MESSAGE_MAP()
-
- void
- CScreenSaverWindow::OnSysKeyDown(UINT, UINT, UINT)
- {
- PostMessage(WM_CLOSE, 0, 0l);
- }
-
- void
- CScreenSaverWindow::OnKeyDown(UINT, UINT, UINT)
- {
- PostMessage(WM_CLOSE, 0, 0l);
- }
-
- void
- CScreenSaverWindow::OnLButtonDown(UINT, CPoint)
- {
- PostMessage(WM_CLOSE, 0, 0l);
- }
-
- void
- CScreenSaverWindow::OnMButtonDown(UINT, CPoint)
- {
- PostMessage(WM_CLOSE, 0, 0l);
- }
-
- void
- CScreenSaverWindow::OnRButtonDown(UINT, CPoint)
- {
- PostMessage(WM_CLOSE, 0, 0l);
- }
-
-