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
TECHDAYS PARIS 2012 : COMMENT SHAREPOINT A SAUVé MES TECHDAYSTECHDAYS PARIS 2012 : COMMENT SHAREPOINT A SAUVé MES TECHDAYS par ROMELARD Fabrice
Speakers : Lionel Limozin et Alain Marty La session commence par une découverte de SharePoint à travers la mise en place d'un environnement SharePoint pour la gestion des Sessions animées par BeWise. Le besoin est très ba...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice PERSPECTIVE 3.0 POUR SILVERLIGHT 5.0PERSPECTIVE 3.0 POUR SILVERLIGHT 5.0 par odewit
Je viens de publier la version 3.0 de Perspective pour Silverlight, qui regroupe un portage sous Silverlight 5.0 des fonctionnalités de Perspective 2.0, le framework 3D de haut-niveau introduit récemment et de nouveaux exemples de code. En voici la li...
Cliquez pour lire la suite de l'article par odewit TECHDAYS PARIS 2012 : TOP 10 DES BEST PRACTICES POUR SQL SERVERTECHDAYS PARIS 2012 : TOP 10 DES BEST PRACTICES POUR SQL SERVER par ROMELARD Fabrice
Speaker : Nadia Ben El Kadi Configuration machine La session commence par la toute première question à se poser lors de la mise en place d'environnement SQL Server, la configuration des machines : Type de mac...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : KINECT + OFFICE 365 UN BON GESTE POUR VOTRE SITECHDAYS PARIS 2012 : KINECT + OFFICE 365 UN BON GESTE POUR VOTRE SI par ROMELARD Fabrice
Speakers : Fabrice Barbin, Samuel Blanchard, Julien Lo Presti Titre Prometteur et attractif invitant à voir comment lier le composant ludique Kinect dans le cadre d'une structure IT classique, notamment au travers de la plat...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : PLEINIèRE DU PREMIER JOURTECHDAYS PARIS 2012 : PLEINIèRE DU PREMIER JOUR par ROMELARD Fabrice
KeyNotes du premier jour pour les développeurs. La session est principalement axée sur une des principales directions prise par Microsoft à travers tous ses nouveaux produits : Cloud privé ou public (Solution Azure) ...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Forum
C++ C++ par yesoun1
Cliquez pour lire la suite par yesoun1 OPNETOPNET par hth21
Cliquez pour lire la suite par hth21 RE : ARBRE BINAIRERE : ARBRE BINAIRE par pacotheking
Cliquez pour lire la suite par pacotheking
Logiciels
Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|