begin process at 2010 02 10 03:53:47
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Application

 > ICONES DU BUREAU EN CERCLE

ICONES DU BUREAU EN CERCLE


 Information sur la source

Note :
Aucune note
Catégorie :Application Niveau :Débutant Date de création :02/01/2003 Date de mise à jour :03/01/2003 15:06:08 Vu / téléchargé :3 435 / 152

Auteur : mogwai93

Ecrire un message privé
Commentaire sur cette source (5)
Ajouter un commentaire et/ou une note

 Description

Recupere les icones du bureau et en fait un cercle.
Le diametre du cercle est modifiable grace a l'icone dans la barre des taches.

Realise avec DevC++
mais doit fonctionner sans grand pb avec BorlandC++ et VC++

Teste sur Win98 et WinNT4.
Devrait fonctionner sur les autres Windows

Source

  • #include <windows.h>
  • #include <shellapi.h>
  • #include <commctrl.h>
  • #include <math.h>
  • #define ID_RESET 1001
  • #define ID_RATIO 1002
  • #define ID_OK 1003
  • #define ID_ICON 1004
  • #define WM_PITASKBAR 2001
  • /* Make the class name into a global variable */
  • const char szAppName[] = "PosIcons";
  • /* Declare Windows procedure */
  • LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
  • /* Variables globales */
  • int lScreen, hScreen, nIcons;
  • float actRatio;
  • HINSTANCE hInst;
  • HWND hWndMain, hWndReset, hWndRatio, hWndOK, hWndSysListView;
  • /*** ICONE BARRE DE TACHES ***/
  • void PITaskBarAdd(HICON hIcon, int idIcon)
  • {
  • NOTIFYICONDATA tnid;
  • tnid.cbSize = sizeof(NOTIFYICONDATA);
  • tnid.hWnd = hWndMain;
  • tnid.uID = idIcon;
  • tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
  • tnid.uCallbackMessage = WM_PITASKBAR;
  • tnid.hIcon = hIcon;
  • lstrcpyn(tnid.szTip, szAppName, sizeof(tnid.szTip));
  • Shell_NotifyIcon(NIM_ADD, &tnid);
  • }
  • void PITaskBarDel(int idIcon)
  • {
  • NOTIFYICONDATA tnid;
  • tnid.cbSize = sizeof(NOTIFYICONDATA);
  • tnid.hWnd = hWndMain;
  • tnid.uID = idIcon;
  • Shell_NotifyIcon(NIM_DELETE, &tnid);
  • }
  • /*** FIN ICONE BARRE DE TACHES ***/
  • /*** RECUPERATION Bureau ***/
  • void PIInfos(void)
  • {
  • RECT r;
  • hWndSysListView = GetWindow(GetWindow(FindWindowEx(NULL, NULL, "Progman", "Program Manager"), GW_CHILD), GW_CHILD);
  • nIcons = ListView_GetItemCount(hWndSysListView);
  • GetWindowRect(GetDesktopWindow(), &r);
  • lScreen = r.right;
  • hScreen = r.bottom;
  • }
  • /*** Realise le cercle ***/
  • void PICircle(float ratio)
  • {
  • int i;
  • float x, y;
  • float x1 = lScreen / 2;
  • float y1 = hScreen / 2;
  • float ratio1 = lScreen * ratio / 100;
  • float ratio2 = hScreen * ratio / 100;
  • float M_PI = 3.14;
  • float Constante = 2 * M_PI / nIcons;
  • for (i = 0; i < nIcons; i++)
  • {
  • x = x1 + ratio1 * cos(i * Constante) - 16;
  • y = y1 - ratio2 * sin(i * Constante) - 24;
  • ListView_SetItemPosition(hWndSysListView, i, (int)x, (int)y);
  • }
  • }
  • int WINAPI
  • WinMain (HINSTANCE hThisInstance,
  • HINSTANCE hPrevInstance,
  • LPSTR lpszArgument,
  • int nFunsterStil)
  • {
  • HWND hWnd; /* This is the handle for our window */
  • MSG messages; /* Here messages to the application are saved */
  • WNDCLASSEX wincl; /* Data structure for the windowclass */
  • /* The Window structure */
  • wincl.hInstance = hThisInstance;
  • wincl.lpszClassName = szAppName;
  • wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
  • wincl.style = CS_DBLCLKS; /* Catch double-clicks */
  • wincl.cbSize = sizeof (WNDCLASSEX);
  • /* Use default icon and mouse-pointer */
  • wincl.hIcon = LoadIcon (NULL, IDI_WINLOGO);
  • wincl.hIconSm = LoadIcon (NULL, IDI_WINLOGO);
  • wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
  • wincl.lpszMenuName = NULL; /* No menu */
  • wincl.cbClsExtra = 0; /* No extra bytes after the window class */
  • wincl.cbWndExtra = 0; /* structure or the window instance */
  • /* Use Windows's default color as the background of the window */
  • wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
  • /* Register the window class, and if it fails quit the program */
  • if (!RegisterClassEx (&wincl))
  • return 0;
  • /* The class is registered, let's create the program*/
  • hWnd = CreateWindow(szAppName, szAppName,
  • WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_CLIPCHILDREN,
  • 0, 0, 0, 0, NULL, NULL, hThisInstance, NULL);
  • hWndMain = hWnd;
  • hInst = hThisInstance;
  • PITaskBarAdd(LoadIcon (NULL, IDI_WINLOGO), ID_ICON);
  • // Pour changer l'icone de la barre des taches
  • // Il faut modifier cette variable :
  • // LoadIcon (NULL, IDI_WINLOGO)
  • // Fenetre invisible au demarrage
  • ShowWindow(hWnd, SW_HIDE);
  • /* Run the message loop. It will run until GetMessage() returns 0 */
  • while (GetMessage (&messages, NULL, 0, 0))
  • {
  • /* Translate virtual-key messages into character messages */
  • TranslateMessage(&messages);
  • /* Send message to WindowProcedure */
  • DispatchMessage(&messages);
  • }
  • /* The program return-value is 0 - The value that PostQuitMessage() gave */
  • return messages.wParam;
  • }
  • /* This function is called by the Windows function DispatchMessage() */
  • LRESULT CALLBACK
  • WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  • {
  • switch (message) /* handle the messages */
  • {
  • case WM_CREATE:
  • PIInfos();
  • hWndReset = CreateWindow("button", "Reset", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 4, 4, 108, 24, hwnd, (HMENU)ID_RESET, hInst, NULL);
  • SendMessage(hWndReset, WM_SETFONT, (WPARAM)GetStockObject(ANSI_VAR_FONT), 0);
  • hWndOK = CreateWindow("button", "OK", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 4, 108, 108, 24, hwnd, (HMENU)ID_OK, hInst, NULL);
  • SendMessage(hWndOK, WM_SETFONT, (WPARAM)GetStockObject(ANSI_VAR_FONT), 0);
  • hWndRatio = CreateWindowEx(0, TRACKBAR_CLASS, "Ratio", WS_CHILD | WS_VISIBLE | TBS_NOTICKS | TBS_VERT, 44, 28, 24, 80, hwnd, (HMENU)ID_RATIO, hInst, NULL);
  • SendMessage(hWndRatio, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(0, 45));
  • SendMessage(hWndRatio, TBM_SETPAGESIZE, (WPARAM)0, (LPARAM)4);
  • SendMessage(hWndRatio, TBM_SETLINESIZE, (WPARAM)0, (LPARAM)1);
  • SendMessage(hwnd, WM_COMMAND, (WPARAM)ID_RESET, (LPARAM)0);
  • return 0;
  • case WM_COMMAND:
  • switch(wParam)
  • {
  • case ID_RESET:
  • if ((actRatio = (nIcons - 1) * 100 / 36) > 45) actRatio = 45;
  • SendMessage(hWndRatio, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)actRatio);
  • PICircle(actRatio);
  • break;
  • case ID_OK:
  • ShowWindow(hwnd, SW_HIDE);
  • break;
  • }
  • return 0;
  • case WM_PITASKBAR:
  • // Clic sur l'icone de la barre des taches
  • if ((wParam == ID_ICON) && (lParam == WM_LBUTTONDOWN)) ShowWindow(hwnd, SW_SHOW);
  • return 0;
  • case WM_VSCROLL:
  • actRatio = SendMessage(hWndRatio, TBM_GETPOS, (WPARAM)0, (LPARAM)0);
  • PICircle(actRatio);
  • return 0;
  • case WM_ACTIVATE:
  • switch(wParam)
  • {
  • case WA_ACTIVE:
  • case WA_CLICKACTIVE:
  • PIInfos();
  • PICircle(actRatio);
  • MoveWindow(hwnd, (lScreen / 2) - 60, (hScreen / 2) - 80, 120, 160, TRUE);
  • SetForegroundWindow(hwnd);
  • break;
  • case WA_INACTIVE:
  • ShowWindow(hwnd, SW_HIDE);
  • break;
  • }
  • return 0;
  • case WM_DESTROY:
  • PITaskBarDel(ID_ICON); // Supprimer l'icone de la barre des taches
  • PostQuitMessage (0); /* send a WM_QUIT to the message queue */
  • break;
  • default: /* for messages that we don't deal with */
  • return DefWindowProc (hwnd, message, wParam, lParam);
  • }
  • return 0;
  • }
#include <windows.h>
#include <shellapi.h>
#include <commctrl.h>
#include <math.h>


#define ID_RESET 1001
#define ID_RATIO 1002
#define ID_OK    1003
#define ID_ICON  1004
#define WM_PITASKBAR 2001

/*  Make the class name into a global variable  */
const char szAppName[] = "PosIcons";

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);



/* Variables globales */
int lScreen, hScreen, nIcons;
float actRatio;
HINSTANCE hInst;
HWND hWndMain, hWndReset, hWndRatio, hWndOK, hWndSysListView;

/***  ICONE BARRE DE TACHES ***/
void PITaskBarAdd(HICON hIcon, int idIcon)
{
	NOTIFYICONDATA tnid;

   tnid.cbSize = sizeof(NOTIFYICONDATA);
   tnid.hWnd = hWndMain;
   tnid.uID = idIcon;
   tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
   tnid.uCallbackMessage = WM_PITASKBAR;
   tnid.hIcon = hIcon;
   lstrcpyn(tnid.szTip, szAppName, sizeof(tnid.szTip));
   Shell_NotifyIcon(NIM_ADD, &tnid);
}

void PITaskBarDel(int idIcon)
{
   NOTIFYICONDATA tnid;

   tnid.cbSize = sizeof(NOTIFYICONDATA);
   tnid.hWnd = hWndMain;
   tnid.uID = idIcon;
   Shell_NotifyIcon(NIM_DELETE, &tnid);
}
/***  FIN ICONE BARRE DE TACHES ***/


/***  RECUPERATION Bureau ***/
void PIInfos(void)
{
   RECT r;
   hWndSysListView = GetWindow(GetWindow(FindWindowEx(NULL, NULL, "Progman", "Program Manager"), GW_CHILD), GW_CHILD);
   nIcons = ListView_GetItemCount(hWndSysListView);
   GetWindowRect(GetDesktopWindow(), &r);
   lScreen = r.right;
   hScreen = r.bottom;
}


/*** Realise le cercle ***/
void PICircle(float ratio)
{
   int i;
   float x, y;
   float x1 = lScreen / 2;
   float y1 = hScreen / 2;
   float ratio1 = lScreen * ratio / 100;
   float ratio2 = hScreen * ratio / 100;
      
   float M_PI = 3.14;
   float Constante = 2 * M_PI / nIcons;

   for (i = 0; i < nIcons; i++)
   {
       x = x1 + ratio1 * cos(i * Constante) - 16;
       y = y1 - ratio2 * sin(i * Constante) - 24;      
       ListView_SetItemPosition(hWndSysListView, i, (int)x, (int)y);
   }
}




int WINAPI
WinMain (HINSTANCE hThisInstance,
         HINSTANCE hPrevInstance,
         LPSTR lpszArgument,
         int nFunsterStil)

{
    HWND hWnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szAppName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_WINLOGO);
    wincl.hIconSm = LoadIcon (NULL, IDI_WINLOGO);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;

    /* The class is registered, let's create the program*/

   hWnd = CreateWindow(szAppName, szAppName, 
   WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_CLIPCHILDREN, 
   0, 0, 0, 0, NULL, NULL, hThisInstance, NULL);
   hWndMain = hWnd;
   hInst = hThisInstance;
   
 
   PITaskBarAdd(LoadIcon (NULL, IDI_WINLOGO), ID_ICON);
   // Pour changer l'icone de la barre des taches
   // Il faut modifier cette variable :
   // LoadIcon (NULL, IDI_WINLOGO)
   
   // Fenetre invisible au demarrage 
   ShowWindow(hWnd, SW_HIDE);



    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}


/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK
WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)                  /* handle the messages */
    {
        case WM_CREATE:
            PIInfos();
                   
            hWndReset = CreateWindow("button", "Reset", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 4, 4, 108, 24, hwnd, (HMENU)ID_RESET, hInst, NULL);
            SendMessage(hWndReset, WM_SETFONT, (WPARAM)GetStockObject(ANSI_VAR_FONT), 0);

            hWndOK = CreateWindow("button", "OK", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 4, 108, 108, 24, hwnd, (HMENU)ID_OK, hInst, NULL);
            SendMessage(hWndOK, WM_SETFONT, (WPARAM)GetStockObject(ANSI_VAR_FONT), 0);

            hWndRatio = CreateWindowEx(0, TRACKBAR_CLASS, "Ratio", WS_CHILD | WS_VISIBLE | TBS_NOTICKS | TBS_VERT, 44, 28, 24, 80, hwnd, (HMENU)ID_RATIO, hInst, NULL);
            SendMessage(hWndRatio, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(0, 45));

            SendMessage(hWndRatio, TBM_SETPAGESIZE, (WPARAM)0, (LPARAM)4);
            SendMessage(hWndRatio, TBM_SETLINESIZE, (WPARAM)0, (LPARAM)1);
            SendMessage(hwnd, WM_COMMAND, (WPARAM)ID_RESET, (LPARAM)0);
        return 0;
    
    
        case WM_COMMAND:
      	    switch(wParam)
            {
         	   case ID_RESET:
            	 	if ((actRatio = (nIcons - 1) * 100 / 36) > 45) actRatio = 45;
                    SendMessage(hWndRatio, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)actRatio);
                    PICircle(actRatio);
               break;
               
               case ID_OK:
            		ShowWindow(hwnd, SW_HIDE);
               break;
            }
      	return 0;
    
       	case WM_PITASKBAR:
       	    // Clic sur l'icone de la barre des taches 
      	    if ((wParam == ID_ICON) && (lParam == WM_LBUTTONDOWN)) ShowWindow(hwnd, SW_SHOW);
        return 0;
    
    
        case WM_VSCROLL:
         	actRatio = SendMessage(hWndRatio, TBM_GETPOS, (WPARAM)0, (LPARAM)0);
            PICircle(actRatio);
        return 0;


        case WM_ACTIVATE:
      	    switch(wParam)
            {
         	   case WA_ACTIVE:
               case WA_CLICKACTIVE:
                	PIInfos();
                    PICircle(actRatio);
                    MoveWindow(hwnd, (lScreen / 2) - 60, (hScreen / 2) - 80, 120, 160, TRUE);
                    SetForegroundWindow(hwnd);
                    break;

               case WA_INACTIVE:
                 	ShowWindow(hwnd, SW_HIDE);
                    break;
             }
        return 0;
    
    
        case WM_DESTROY:
            PITaskBarDel(ID_ICON);     // Supprimer l'icone de la barre des taches 
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}
 

 Conclusion

Evolutions possibles :
- memoriser d'autres formes (carre, triangle, etoile, ...)
- rajouter des ressources (pour l'icone, ...)

si qqn trouve le code avant moi (pour d'autres formes), merci de m'aider un peu  (-:

Bugs connus ???

 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 QUIZZ IMAGES

 Sources de la même categorie

GESTIONNAIRE DE BIBLIOTHEQUE par eishtein
FICHIER ALBUM MUSICAL par imenouuuuuuuuuche
LOUISDU81 HTTP EDITOR par louisdu81
Source avec Zip Source avec une capture Source .NET (Dotnet) CLIENT IRC BASIQUE par king67
Source avec Zip CONVERTISSEUR NOMBRE ARABE => NOMBRE ROMAIN (1 À 4999) par Calli95

Commentaires et avis

Commentaire de trinitacs le 02/01/2003 12:50:42

vive les Jackis !!!

Je vais essayer de l'améliorer pour faire n'importe quelle figure :) polygone, cube (chaque icône sera un point), polygone formant un cone
Seul problème je ne connais pas windows.h mais ce n'est pas insurmontable :)

Commentaire de mogwai93 le 02/01/2003 13:06:10

Normalement, pour faire d'autres figures, tu n'as pas besoin de connaitre windows.h, il suffit de modifier le contenu de PICircle par des formules mathematiques.

ebauche de code :

     for (i = 0; i &lt; nIcons; i++)
     {
         x = f(x, ratio);
         y = g(y, ratio);
         // peut etre d'autres lignes seront necessaires dans certains cas
         ListView_SetItemPosition(hWndSysListView, i, (int)x, (int)y);
     }

il suffit seulement de coder f et g ... !!!

Commentaire de LordBob le 02/01/2003 20:05:46

juste une chose, tout d'abord je pense k'un zip ca aurrait été bien ou au minimum une capture ca aurrait été excelent pour illustrer ta source... voila tout...

Commentaire de mogwai93 le 06/01/2003 13:10:56

un bug :
si "Reorganisation automatique" est cochée, alors ca ne fait rien.
si qqn sait comment detecter/desactiver/activer cette option

Merci

Commentaire de morgandetoi06 le 02/10/2003 22:41:05

je compile avec dev c++ et j ai une erreur à la compilation:
C:DOCUME~1MorganLOCALS~1TempccoZbaaa.o(.text+0x515):icones~1.cpp: undefined reference to `GetStockObject@4'
C:DOCUME~1MorganLOCALS~1TempccoZbaaa.o(.text+0x56a):icones~1.cpp: undefined reference to `GetStockObject@4'

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
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,452 sec (4)

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