begin process at 2010 03 18 20:25:07
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Graphique

 > ECRAN VEILLE LE PLUS BASIC

ECRAN VEILLE LE PLUS BASIC


 Description

Cliquez pour voir la capture en taille normale
le plus court et le plus simple screensaver!!!!

utilise la lib scrnsave.lib de windows

fait des ronds sur l ecran vielle bouge la sourit pour changer

forme

utilise  ScreenSaverProc pour demarer l application

et non int APIENTRY WinMain()

Source

  • #include <windows.h>
  • #include <scrnsave.h>
  • #include <math.h>
  • #include <commctrl.h>
  • #pragma comment(lib,"scrnsave.lib")
  • #pragma comment(lib,"comctl32.lib")
  • int delay=8;
  • const double Pi=3.1415926;
  • int Rand(int);
  • int Rand(int nMax)
  • {
  • static long seed=GetTickCount();
  • seed=(25173*seed+13849)%65535;
  • return abs(seed%nMax);
  • }
  • BOOL WINAPI ScreenSaverConfigureDialog(HWND hwnd,UINT message,
  • WPARAM wParam,LPARAM lParam)
  • {
  • return 0;
  • }
  • BOOL WINAPI RegisterDialogClasses(HANDLE hInst)
  • {
  • return 1;
  • }
  • LRESULT WINAPI ScreenSaverProc(HWND hwnd,UINT message,
  • WPARAM wParam,LPARAM lParam)
  • {
  • static HDC hdc;
  • static RECT scr_dim;
  • static SIZE size;
  • static HBRUSH hBlk_Brush;
  • static int d=1,c=1,q=3,center_x,center_y,hs,vs;
  • static long red,green,blue;
  • int i,x,y;
  • double xs,ys,temp,k=0.2;
  • switch(message)
  • {
  • case WM_CREATE:
  • SetTimer(hwnd,1,delay,NULL);
  • hBlk_Brush=(HBRUSH)GetStockObject(BLACK_BRUSH);//Background Black
  • red=Rand(256);
  • green=Rand(256);
  • blue=Rand(256);
  • hs=GetSystemMetrics(SM_CXSCREEN)/30;
  • vs=GetSystemMetrics(SM_CYSCREEN)/30;
  • //hs=GetSystemMetrics(SM_CXVIRTUALSCREEN)/30;
  • //vs=GetSystemMetrics(SM_CYVIRTUALSCREEN)/30;
  • break;
  • case WM_ERASEBKGND:
  • hdc=GetDC(hwnd);
  • GetClientRect(hwnd,&scr_dim);
  • center_x=(scr_dim.right-scr_dim.left)/2;
  • center_y=(scr_dim.bottom-scr_dim.top)/2;
  • SelectObject(hdc,hBlk_Brush);
  • PatBlt(hdc,0,0,scr_dim.right,scr_dim.bottom,PATCOPY);
  • ReleaseDC(hwnd,hdc);
  • break;
  • case WM_MOUSEMOVE:
  • c = 25;
  • case WM_TIMER:
  • hdc=GetDC(hwnd);
  • ///ys=d/3.0;
  • //xs=c/3.0;
  • ys=d/3.5;
  • xs=c/3.5;
  • for(i=0;i<1000;i++)
  • {
  • temp=(xs+k*sin(ys))*cos(2*Pi/q)+ys*sin(2*Pi/q);
  • ys=-(xs+k*sin(ys))*sin(2*Pi/q)+ys*cos(2*Pi/q);
  • xs=temp;
  • x=(int)(xs*hs);
  • y=(int)(ys*vs);
  • if(i>10) {
  • SetPixel(hdc,x+center_x,center_y-y,RGB(red,green,blue));
  • SetPixel(hdc,x+80,center_y-y,RGB(green,blue,red));
  • //SetPixel(hdc,x+80,center_y-y,RGB(i,i,i));
  • SetPixel(hdc,GetSystemMetrics(SM_CXSCREEN)-x,center_y-y,RGB(blue,red,green));
  • }
  • }
  • c++;
  • if(c>24)
  • {
  • c=1;
  • d++;
  • if(d>24)
  • {
  • d=1;
  • q++;
  • SelectObject(hdc,hBlk_Brush);
  • PatBlt(hdc,0,0,scr_dim.right,scr_dim.bottom,PATCOPY);
  • red=Rand(256);
  • green=Rand(256);
  • blue=Rand(256);
  • if(q>12)
  • {
  • q=3;
  • c=1;
  • d=1;
  • }
  • }
  • }
  • ReleaseDC(hwnd,hdc);
  • break;
  • case WM_DESTROY:
  • KillTimer(hwnd,1);
  • break;
  • default:
  • return DefScreenSaverProc(hwnd,message,wParam,lParam);
  • }
  • return 0;
  • }
#include <windows.h>
#include <scrnsave.h>
#include <math.h>

#include <commctrl.h>

#pragma comment(lib,"scrnsave.lib")
#pragma comment(lib,"comctl32.lib")

int delay=8; 
const	double Pi=3.1415926;
int		Rand(int);

int	Rand(int nMax)
{
	static	long	seed=GetTickCount();

	seed=(25173*seed+13849)%65535; 
	return abs(seed%nMax);
}

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

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





LRESULT WINAPI ScreenSaverProc(HWND hwnd,UINT message,
							   WPARAM wParam,LPARAM lParam)
{
	static	HDC	hdc;
	static	RECT	scr_dim;
	static	SIZE	size;
	static	HBRUSH	hBlk_Brush;
	static	int	d=1,c=1,q=3,center_x,center_y,hs,vs;
	static long	red,green,blue;
	int		i,x,y;
	double	xs,ys,temp,k=0.2;
	switch(message)
	{

	case	WM_CREATE: 
		SetTimer(hwnd,1,delay,NULL); 
		hBlk_Brush=(HBRUSH)GetStockObject(BLACK_BRUSH);//Background Black
		red=Rand(256);
		green=Rand(256);
		blue=Rand(256);
		hs=GetSystemMetrics(SM_CXSCREEN)/30;
		vs=GetSystemMetrics(SM_CYSCREEN)/30;
		//hs=GetSystemMetrics(SM_CXVIRTUALSCREEN)/30;
		//vs=GetSystemMetrics(SM_CYVIRTUALSCREEN)/30;

		break;
	case	WM_ERASEBKGND: 
		hdc=GetDC(hwnd);
		GetClientRect(hwnd,&scr_dim);
		center_x=(scr_dim.right-scr_dim.left)/2;
		center_y=(scr_dim.bottom-scr_dim.top)/2;
		SelectObject(hdc,hBlk_Brush);
		PatBlt(hdc,0,0,scr_dim.right,scr_dim.bottom,PATCOPY); 
		ReleaseDC(hwnd,hdc);
		break;

	case	WM_MOUSEMOVE:
		c = 25;
	case	WM_TIMER: 

		hdc=GetDC(hwnd);
		///ys=d/3.0;
		//xs=c/3.0;
		ys=d/3.5;
		xs=c/3.5;

		for(i=0;i<1000;i++)
		{
			temp=(xs+k*sin(ys))*cos(2*Pi/q)+ys*sin(2*Pi/q);
			ys=-(xs+k*sin(ys))*sin(2*Pi/q)+ys*cos(2*Pi/q);

	

			xs=temp;
			x=(int)(xs*hs);
			y=(int)(ys*vs);
			if(i>10) {
				SetPixel(hdc,x+center_x,center_y-y,RGB(red,green,blue));
			    SetPixel(hdc,x+80,center_y-y,RGB(green,blue,red));
				//SetPixel(hdc,x+80,center_y-y,RGB(i,i,i));
				SetPixel(hdc,GetSystemMetrics(SM_CXSCREEN)-x,center_y-y,RGB(blue,red,green));
			}
		}
		c++;
		if(c>24)
		{
			c=1;
			d++;
			if(d>24)
			{
				d=1;
				q++;
				SelectObject(hdc,hBlk_Brush);
				PatBlt(hdc,0,0,scr_dim.right,scr_dim.bottom,PATCOPY);
				red=Rand(256);
				green=Rand(256);
				blue=Rand(256);
				if(q>12)
				{
					q=3;
					c=1;
					d=1;
				}
			}
		}
		ReleaseDC(hwnd,hdc);
		break;
	case	WM_DESTROY:
		KillTimer(hwnd,1);
		break;
	default:
		return	DefScreenSaverProc(hwnd,message,wParam,lParam);
	}
	return 0;
}



 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Sources du même auteur

Source avec Zip Source avec une capture POISSON D AVRIL (JOKE)
Source avec Zip SUPER MINI MP3 JOUEUR
Source avec Zip CPU INFO MHZ
Source avec Zip KEYLOGGER INVISIBLE
Source avec Zip Source avec une capture TRADUCTION DE MOT AVEC GOOGLE (UN AUTRE)

 Sources de la même categorie

Source avec Zip Source avec une capture VISUALISATION DES IMAGES EN 3D SANS OPENGL par Pistol_Pete
Source avec Zip Source avec une capture ANALYSE DE LA TEXTURE D'UNE IMAGE : FILTRE DE GABOR par Pistol_Pete
Source avec Zip Source avec une capture MONPPM : UN AFFICHEUR .PPM par pgl10
Source avec Zip Source avec une capture MOTEUR 3D : CASTOR3D par dragonjoker59
Source avec Zip Source avec une capture VIEWER COMPLET POUR LE TRAITEMENT DE L'IMAGE : IMANALYSE par Pistol_Pete

 Sources en rapport avec celle ci

Source avec Zip Source avec une capture CONTROLE AFFICHEUR (WIN32) par hattabking
Source avec Zip DIRECT DRAW PIXEL 8,16 OU 32 BITS TEST par f_l_a_s_h_b_a_c_k
Source avec Zip Source avec une capture SCREENSAVER HYPNOTISEUR par acx01b
Source avec Zip ECRAN DE VEILLE (LOAD IMAGE REPERTOIRE) par taureau23
Source avec Zip Source avec une capture ECRAN DE VEILLE PARTICULES 3D par Arnaud16022

Commentaires et avis

Commentaire de gagah1 le 03/07/2008 16:23:42

Pas mal pour une source basic.
J'ai modifié la source pour mettre la capture d'écran en image de fond. Et comme les 3 effets ne sont pas symetriques, je ne retient que celui du centre, j'ai remplacé pi par le macro M_PI:


#include <windows.h>
#include <scrnsave.h>
#include <math.h>
#include <commctrl.h>

int delay = 8;
int Rand(int);

int Rand(int nMax)
{
rand()%nMax;
}

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

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

LRESULT WINAPI ScreenSaverProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static  HBITMAP hbmp;
static RECT scr_dim;
static SIZE size;
static int d=1, c=1, q=3, center_x, center_y, hs, vs;
static int screenWidth, screenHeight;
static long red,green,blue;
HDC    hdc, hdcMem;
int i,x,y;
double xs, ys, temp, k=0.2;

    switch(message)
{
     case WM_CREATE:
            srand(GetTickCount());
     SetTimer(hwnd,1,delay,NULL);
     red=Rand(256);
     green=Rand(256);
     blue=Rand(256);
     hs = GetSystemMetrics(SM_CXSCREEN)/30;
     vs = GetSystemMetrics(SM_CYSCREEN)/30;
    
     screenWidth = GetSystemMetrics(SM_CXSCREEN);
     screenHeight = GetSystemMetrics(SM_CYSCREEN);
            hdc = CreateDCA("DISPLAY", NULL, NULL, NULL);
            hdcMem = CreateCompatibleDC(hdc);
    
            hbmp = CreateCompatibleBitmap(hdc, screenWidth, screenHeight );
            SelectObject (hdcMem, hbmp);
            BitBlt(hdcMem, 0, 0, screenWidth, screenHeight, hdc, 0, 0, SRCCOPY);
            
            DeleteDC(hdc);
            DeleteDC(hdcMem);
    
     break;
     case WM_ERASEBKGND:
     hdc = GetDC(hwnd);
     hdcMem = CreateCompatibleDC(hdc);
     GetClientRect(hwnd, &scr_dim);
     center_x = (scr_dim.right - scr_dim.left)/2;
     center_y = (scr_dim.bottom - scr_dim.top)/2;
     SelectObject(hdcMem, hbmp);
            BitBlt(hdc, 0, 0, screenWidth, screenHeight, hdcMem, 0, 0, SRCCOPY);  
    
            DeleteDC(hdcMem);
            ReleaseDC(hwnd, hdc);
     break;
    
     case WM_TIMER:
     hdc = GetDC(hwnd);
     hdcMem = CreateCompatibleDC(hdc);
    
     ys = d/3.0;
     xs = c/3.0;
    
     for(i=0; i<1000; i++)
     {
     temp =(xs + k*sin(ys))*cos(2*M_PI/q) + ys*sin(2*M_PI/q);
     ys = -(xs + k*sin(ys))*sin(2*M_PI/q) + ys*cos(2*M_PI/q);
    
     xs = temp;
     x = (int)(xs * hs);
     y = (int)(ys * vs);
     if(i>10)
                    SetPixel(hdc, x + center_x, center_y - y, RGB(red, green, blue));
     }
     c++;
     if(c>24)
     {
     c=1;
     d++;
     if(d>24)
     {
     d=1;
     q++;
     SelectObject(hdcMem, hbmp);
                    BitBlt(hdc, 0, 0, screenWidth, screenHeight, hdcMem, 0, 0, SRCCOPY);
     red=Rand(256);
     green=Rand(256);
     blue=Rand(256);
     if(q>12)
     {
     q=3;
     c=1;
     d=1;
     }
     }
     }
     DeleteDC(hdcMem);
            ReleaseDC(hwnd,hdc);
     break;
    
        case WM_DESTROY:
     KillTimer(hwnd,1);
     DeleteObject(hbmp);
     break;
    
        default:
     return DefScreenSaverProc(hwnd,message,wParam,lParam);
}
return 0;
}

Commentaire de f_l_a_s_h_b_a_c_k le 03/07/2008 19:31:05

"3 effets ne sont pas symetriques"

moi mon ordi a 2 ecran et il marche ok,
je l ai pas tester sur 1 ecran...

jái tester t a source ses cool!
ses different je vois plus l ecran en noir :)

il a fallu que je modifie

int Rand(int nMax)
{
return rand()%nMax;
}

et que je rajoute #define M_PI 3.14159








Commentaire de gagah1 le 03/07/2008 19:40:26

M_PI est déjà défini dans math.h
Je parle de symetrie, le positionnement des 2 effets par rapport à celui du centre.

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

SetPixel() ... [ par payen ] Salut a tous,alors voila : j'aimerais faire un petit soft de traitement d'images, mais les images qu'on utilise sont au format brut (c'est a dire 1 pi GROS probleme :( [ par morgandetoi06 ] bonjour,j ai voulu faire un ecran de veille avec une phase d installation donc pour cela je regarde le nom du fichier, si c est Morgan_screensaver.scr OpenGL & ScreenSaver ? [ par ParMesSoins ] Bonjour, je souhaite me lancer dans la programmation (où j'ai quelque notion) d'animation OpenGL temps réel, en fait je veux faire des économiseurs d' GetPixel / SetPixel [ par glipper ] Bonjour à tous,j'ai un problème avec la fonction GetPixel. J'appelle une procédure qui doit tester la couleur d'un pixel à l'ecran, mais la valeur ren SetPixel et GetPixel [ par Adeon ] Salut je n'arrive pas a me servir de SetPixel() et GetPixel() en API. Je sais que ca existe mais j'ai des erreurs tout le temps quand je m'en ser. QQ SetPixel(hdc,i,j,RGB..) peut-on utiliser autre chose que RGB [ par izle ] IzLe,la coloration en RGB n'est pas vraiment suffisante avec le type d'image que je produit, j'aimerais soit ajouter un 4ième paramètre de luminosité GetPixel [ par elflink ] Bonjour &#224; tous,Je suis actuellement en train de concevoir un logiciel de lecture vid&#233;o et afin de changer la couleur de certains pixels (ble API Setpixel [ par Stephane ] Salut a tous voila, j'utilise l'API SetPixel pour remplir une zone dont je connais le HDC (pass&#233;e en parametre par une appli VB). Mon probleme e Gestion des couleurs [ par lilington ] salut j'aimerai savoir s'il existe une fonction pour convertire 3 teintes de couleurs en index: j'utilise la fonction SetPixel(Hwnd,int,int,index); Setpixel [ par 69lion69 ] salut, je voudrais juste savoir si quequ'un aurait un exemple ou il utilise les setpixel.Merci


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mars 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728
293031    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,998 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales