Accueil > > > ECRAN VEILLE LE PLUS BASIC
ECRAN VEILLE LE PLUS BASIC
Information sur la source
Description
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;
}
Sources du même auteur
Sources de la même categorie
Commentaires et avis
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 à tous,Je suis actuellement en train de concevoir un logiciel de lecture vidé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é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
|
Derniers Blogs
[MIX10] KEYNOTE DEUXIèME JOURNéE - INTERNET EXPLORER 9, HTML5, VISUAL STUDIO 2010, ODATA[MIX10] KEYNOTE DEUXIèME JOURNéE - INTERNET EXPLORER 9, HTML5, VISUAL STUDIO 2010, ODATA par cyril
Le deuxième keynote du mix fut très riche en contenu. Internet Explorer 9 Juste un après le lancement de Internet Explorer 8, Microsoft a dévoilé les nouveautés de Internet Explorer 9. Désormais, IE supportera HTML5, SVG et CSS3. L'élément ...
Cliquez pour lire la suite de l'article par cyril CERTIFICATIONS BETA .NET 4CERTIFICATIONS BETA .NET 4 par KooKiz
Les inscriptions pour les certifications beta .NET 4 ont commencé. L'inscription est offerte pour les examens suivants : - 71-511, TS: Windows Applications Development with Microsoft .NET Framework 4 - 71-515, TS: Web Applications Development with...
Cliquez pour lire la suite de l'article par KooKiz [MIX 2010] - MICROSOFT TRANSLATOR TECHNOLOGY PREVIEW V2[MIX 2010] - MICROSOFT TRANSLATOR TECHNOLOGY PREVIEW V2 par redo
J'imagine que la plupart d'entre vous connaissent bien et utilisent le service de traduction de Google, mais connaissez-vous celui de Microsoft . Microsoft Translator ? Effectivement, Microsoft nous annoncé le lancement version 2 de la Technologie Preview...
Cliquez pour lire la suite de l'article par redo LANCEMENT EN PREVIEW DE CYCLONE LORS DES TECHDAYS 2010!LANCEMENT EN PREVIEW DE CYCLONE LORS DES TECHDAYS 2010! par MPOWARE
Toutes les vidéos de ce lancement sont en ligne!
Partie I - Intro
http://www.youtube.com/watch?v=LkQzTQ8T6CA
Partie II - Démo 1
http://www.youtube.com/watch?v=drAhYQ7lqvo
Partie III - Démo 2
http://www.youtube.com/watch?v=c8KM_1Gqybc...
Cliquez pour lire la suite de l'article par MPOWARE
Forum
TABLEAU DE LISTETABLEAU DE LISTE par help26
Cliquez pour lire la suite par help26
Logiciels
Academy System (10.9.4.0)ACADEMY SYSTEM (10.9.4.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods
|