|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
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
Sources en rapport avec celle ci
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
|
Téléchargements
Logiciels à télécharger sur le même thème :
Comparez les prix Nouvelle version
|