www.pudn.com > scrnsaverTY23.zip > scrnsaver.cpp


// scrnsaver.cpp : Defines the entry point for the application. 
// 
//请连接scrnsave.lib! 
#include "stdafx.h" 
#include  
#include "Matrix.h" 
#include "constants.h" 
#include "SaverConfigDialog.h" 
 
void DrawScreen(HWND hWnd); 
 
 
/************************************************************************************* 
//函数:ScreenSaverProc 
//Windows回调,该函数调用DrawScreen实现绘图工作。 
*************************************************************************************/ 
LRESULT WINAPI ScreenSaverProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 
{ 
	static uTimer; 
	int nSpeed; 
 
    switch(message)  
    {  
        case WM_CREATE:  
			nSpeed = CSaverConfigDialog::GetSpeed(); 
			uTimer = SetTimer(hWnd, 1, SHOW_INTERVAL * (MAX_SPEED - nSpeed + 1), NULL); 
			theMatrix.LoadMatrix(hWnd); 
			break; 
        case WM_ERASEBKGND:  
			break;  
        case WM_TIMER:  
			DrawScreen(hWnd); 
            break;  
        case WM_DESTROY:  
            KillTimer(hWnd, uTimer); 
			theMatrix.DestroyMatrix(); 
			break;  
		default: 
			break; 
	} 
	return DefScreenSaverProc(hWnd, message, wParam, lParam);  
} 
 
void DrawScreen(HWND hWnd) 
{ 
	HDC hDC = GetDC(hWnd); 
	CDC *pDC = CDC::FromHandle(hDC); 
	theMatrix.MatrixGO(pDC); 
	ReleaseDC(hWnd, hDC); 
}