Accueil > > > ICONES DU BUREAU EN CERCLE
ICONES DU BUREAU EN CERCLE
Information sur la source
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 ???
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
UNE JOLIE-HORLOGE ET PAS QU'UN PEU !UNE JOLIE-HORLOGE ET PAS QU'UN PEU ! par neodante
Pour les possesseurs d'iPhone, ça y est Bijin Tokei - qui se traduit littéralement en Français par " Jolie Horloge " - est arrivé et GRATUITEMENT s'il vous plaît ! Après la version Tokyo, Hokkaido, night club, racing, Gal, "pour les mademoiselles'", . voi...
Cliquez pour lire la suite de l'article par neodante TECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICESTECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICES par ROMELARD Fabrice
Animé par: Gaetan Bouveret et Julien Chomarat Business Connectivity Services (BCS) est dans SharePoint 2010 la version 2 de Business Data Catalog (BDC dans SharePoint 2007). Il s'agit de la solution permettant de visualiser des données provenan...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE par orion
Comme de nombreux geek, je suis un grand amateur de série TV et je rate régulièrement des épisodes de mes séries préférés. Une solution s'offre à vous avec ce merveilleux site : Tv Gorge - www.tvgorge.com Moteur de recherche à l'appui, vous pouvez ...
Cliquez pour lire la suite de l'article par orion TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Forum
RE : WIN APIRE : WIN API par racpp
Cliquez pour lire la suite par racpp WIN APIWIN API par omarino_007
Cliquez pour lire la suite par omarino_007
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|