Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Screen Saver AppWizard

, 17 Jun 2004 CPOL
An article on creating a Screen Saver AppWizard
scrnsvrwizard_src.zip
ScreenSaverWizard
res
ScreenSaverWizard.ico
ScreenSaverWizard.clw
ScreenSaverWizard.dsp
ScreenSaverWizard.dsw
Template
confirm.inf
newproj.inf
// ps7.cpp : Defines the entry point for the application.
//

#include "stdafx.h"

#define szAppName	"$$Root$$"
#define szAuthor	"Author of $$Root$$"
#define szPreview	"$$Root$$ Preview"

BOOL WINAPI ScreenSaverConfigureDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	return FALSE;
}

BOOL WINAPI RegisterDialogClasses(HANDLE hInst)
{
	return TRUE;
}

LRESULT WINAPI ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	
	static PAINTSTRUCT ps = {NULL};
	static HDC hDC = NULL;
	static HBRUSH hBrush = NULL;
	static UINT uTimer = 0;
	static int xpos, ypos;
	static RECT rc;
	static RECT wrec;
	
	static int delay = 6500; 

	switch(message)
	{
	case WM_CREATE:
		
		xpos = GetSystemMetrics(SM_CXSCREEN);
		ypos = GetSystemMetrics(SM_CYSCREEN);

		xpos/=2;
		ypos/=2;

		hBrush = CreateSolidBrush(RGB(0, 0, 0));
		uTimer = SetTimer(hWnd, 1, delay, NULL);

		PostMessage(hWnd,WM_TIMER,0,0);

		break;

    case WM_DESTROY:
		if(uTimer)
			KillTimer(hWnd, uTimer);

		if(hBrush)
			DeleteObject(hBrush);
		
		PostQuitMessage(0);
		break;

	case WM_TIMER:
		{

			/* Here you can load a file or a resource or make display algorithms*/

		}
		
		GetWindowRect(hWnd,&wrec);

		InvalidateRect(hWnd, &wrec, TRUE);
		break;

	case WM_PAINT:
		hDC = BeginPaint(hWnd, &ps);

		if(fChildPreview)
		{
			SetBkColor(hDC, RGB(0, 0, 0));
			SetTextColor(hDC, RGB(255, 255, 0));
			TextOut(hDC, 25, 45, szPreview, strlen(szPreview));
		}
		else
		{
			SetBkColor(hDC, RGB(0, 0, 0));
			SetTextColor(hDC, RGB(120, 120, 120));
			TextOut(hDC, 0, ypos * 2 - 42, szAppName, strlen(szAppName));
			TextOut(hDC, 0, ypos * 2 - 25, szAuthor, strlen(szAuthor));

			/* code to Display what you want to */
			
		}
		
		EndPaint(hWnd, &ps);
		break;

    default: 
		return DefScreenSaverProc(hWnd, message, wParam, lParam);
	}
	
	return 0;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Fabio Fornaro
Software Developer (Senior)
Italy Italy
Worked as a Java developer targeting J2EE and J2SE for half a decade.
 
Now he's employed for Avanade as a Senior Associate Consultant on Microsoft technologies.
 
His hobbies are Win32 programming using SDK, MFC, ATL and COM; playing guitar and listening to music.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.1411023.1 | Last Updated 18 Jun 2004
Article Copyright 2004 by Fabio Fornaro
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid