Accueil > > > PROGRESS BAR COLOR
PROGRESS BAR COLOR
Information sur la source
Description
hello! ben c'est programme qui utilise une progress bar avec un dégradé de couleur! ne m'en demandez pas l'utilitée! c'est egalement un exemple de création de thread
Source
- #include <windows.h>
- #include "resource.h"
- #include <commctrl.h>
-
- // variables globale
- HWND hDlg;
- HINSTANCE hinst;
- HINSTANCE hinst2;
- HANDLE SecondThread;
- DWORD ThreadID;
- HWND hProgress;
- int val_choix_fix;
- int vitesse;
- HICON hIcon;
-
- // prototype des fonctions
- BOOL CALLBACK AppProc(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam);
- BOOL CALLBACK AbtProc(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam);
- DWORD WINAPI ThreadProc(LPVOID lpParameter);
- void about();
- void generer();
-
- // fonction gérant les message concernant la boite de dialogue principale
- BOOL CALLBACK AppProc(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- switch(msg)
- {
- case WM_INITDIALOG:
- {
- hDlg=hdlg;
- hIcon = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON1)); // charge l'icone.....
- SetClassLong(hdlg, GCL_HICON, (long)hIcon); // ... et l'affiche
- hProgress = GetDlgItem(hDlg, IDC_PROGRESS);
- vitesse = 50;
- }
- case WM_COMMAND:
- switch(wParam)
- {
- case IDC_LANCER:
- generer();
- break;
- case IDC_ABOUT:
- about();
- break;
- case IDC_STOP:
- TerminateThread(SecondThread,NULL);
- break;
- case IDCANCEL:
- EndDialog(hDlg,0);
- }
- default:
- break;
- }
- return 0;
- }
-
- // fonction gérant les messages concernant la fenetre a propos de...
- BOOL CALLBACK AbtProc(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- switch(msg)
- {
- case WM_INITDIALOG:
- break;
- case WM_COMMAND:
- switch(wParam)
- {
- case IDCANCEL:
- EndDialog(hdlg,0);
- }
- default:
- break;
- }
- return 0;
- }
-
- // fonction principale, c'est la premiere executée
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, int)
- {
- hinst = hInstance;
- DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG), hDlg, AppProc);
- return 0;
- }
-
- // voici les fonctions!
- void about()
- {
- DialogBox(hinst2, MAKEINTRESOURCE(IDD_DIALOG_2), hDlg, AbtProc);
- }
-
- void generer()
- {
- TerminateThread(SecondThread,NULL);
- SecondThread = CreateThread(NULL,NULL,ThreadProc,NULL,NULL,&ThreadID);
- }
-
- DWORD WINAPI ThreadProc(LPVOID lpParameter) // fonction executée par le thread
- {
- int R;
- int G;
- val_choix_fix = 700;
- SendMessage(hProgress, PBM_SETRANGE, 0, MAKELPARAM (0, val_choix_fix));
- for(int a = 0;a<=val_choix_fix;a++)
- {
- R=255;
- G=0;
- if(a<(val_choix_fix/2))
- {
- R = 255;
- G = (255*a)/(val_choix_fix/2);
- }
- if(a>=(val_choix_fix/2))
- {
- G = 255;
- R = 2*(255-((255*a)/(val_choix_fix)));
- R--;
- if(R<0)
- R=0;
-
- }
- SetDlgItemInt(hDlg,IDC_EDIT_R,R,FALSE);
- SetDlgItemInt(hDlg,IDC_EDIT_G,G,FALSE);
- SendMessage(hProgress, PBM_SETBARCOLOR , 0 , RGB(R,G,0));
- SendMessage(hProgress, PBM_SETPOS, (WPARAM) a, 0);
- SetDlgItemInt(hDlg,IDC_VALEUR,a,FALSE);
- Sleep(vitesse);
- }
- return 0;
- }
#include <windows.h>
#include "resource.h"
#include <commctrl.h>
// variables globale
HWND hDlg;
HINSTANCE hinst;
HINSTANCE hinst2;
HANDLE SecondThread;
DWORD ThreadID;
HWND hProgress;
int val_choix_fix;
int vitesse;
HICON hIcon;
// prototype des fonctions
BOOL CALLBACK AppProc(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK AbtProc(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam);
DWORD WINAPI ThreadProc(LPVOID lpParameter);
void about();
void generer();
// fonction gérant les message concernant la boite de dialogue principale
BOOL CALLBACK AppProc(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_INITDIALOG:
{
hDlg=hdlg;
hIcon = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON1)); // charge l'icone.....
SetClassLong(hdlg, GCL_HICON, (long)hIcon); // ... et l'affiche
hProgress = GetDlgItem(hDlg, IDC_PROGRESS);
vitesse = 50;
}
case WM_COMMAND:
switch(wParam)
{
case IDC_LANCER:
generer();
break;
case IDC_ABOUT:
about();
break;
case IDC_STOP:
TerminateThread(SecondThread,NULL);
break;
case IDCANCEL:
EndDialog(hDlg,0);
}
default:
break;
}
return 0;
}
// fonction gérant les messages concernant la fenetre a propos de...
BOOL CALLBACK AbtProc(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_INITDIALOG:
break;
case WM_COMMAND:
switch(wParam)
{
case IDCANCEL:
EndDialog(hdlg,0);
}
default:
break;
}
return 0;
}
// fonction principale, c'est la premiere executée
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, int)
{
hinst = hInstance;
DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG), hDlg, AppProc);
return 0;
}
// voici les fonctions!
void about()
{
DialogBox(hinst2, MAKEINTRESOURCE(IDD_DIALOG_2), hDlg, AbtProc);
}
void generer()
{
TerminateThread(SecondThread,NULL);
SecondThread = CreateThread(NULL,NULL,ThreadProc,NULL,NULL,&ThreadID);
}
DWORD WINAPI ThreadProc(LPVOID lpParameter) // fonction executée par le thread
{
int R;
int G;
val_choix_fix = 700;
SendMessage(hProgress, PBM_SETRANGE, 0, MAKELPARAM (0, val_choix_fix));
for(int a = 0;a<=val_choix_fix;a++)
{
R=255;
G=0;
if(a<(val_choix_fix/2))
{
R = 255;
G = (255*a)/(val_choix_fix/2);
}
if(a>=(val_choix_fix/2))
{
G = 255;
R = 2*(255-((255*a)/(val_choix_fix)));
R--;
if(R<0)
R=0;
}
SetDlgItemInt(hDlg,IDC_EDIT_R,R,FALSE);
SetDlgItemInt(hDlg,IDC_EDIT_G,G,FALSE);
SendMessage(hProgress, PBM_SETBARCOLOR , 0 , RGB(R,G,0));
SendMessage(hProgress, PBM_SETPOS, (WPARAM) a, 0);
SetDlgItemInt(hDlg,IDC_VALEUR,a,FALSE);
Sleep(vitesse);
}
return 0;
}
Conclusion
je vais ajouter un slider pour modifier la vitesee, mais je ne sais pas encore l'utiliser!
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
SESSION SILVERLIGHT 5 3D : SLIDES ET DEMOSSESSION SILVERLIGHT 5 3D : SLIDES ET DEMOS par Groc
Durant les techdays, j'ai eu le plaisir d'animer une session sur Silverlight 5 et la 3D avec Simon Ferquel. Comme promis, voici nos slides et mes démos (celles avec le viper BSG) ici et là. Pour mémoire, les démos utilisent toutes le viper BSG...
Cliquez pour lire la suite de l'article par Groc [TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES par gpommier
Suite à la session que j'ai présenté sur WebMatrix 2, vous pouvez trouver les slides ici, ainsi que les démos en packages nuget : démos1 et démos2 J'en profite pour remercier chaleureusement tous ceux qui sont venus très nombreux à cette sess...
Cliquez pour lire la suite de l'article par gpommier [SHAREPOINT] LES SESSIONS TECHDAYS 2012.[SHAREPOINT] LES SESSIONS TECHDAYS 2012. par Patrick Guimonet
Voici donc pour ceux qui n'ont pas pu venir, ou ceux qui n'ont pas pu toutes les suivre la liste des sessions SharePoint aux TechDays 2012, que je mettrais à jour dès que les liens des vidéo seront disponibles. Ou ici : http...
Cliquez pour lire la suite de l'article par Patrick Guimonet TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE !MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE ! par Vko
Hier durant une session dédiée aux Techdays 2012, j'ai eu le plaisir d'annoncer la sortie de la Béta 2 de Mishra Reader. C'est quoi ? Pour les utilisateurs, c'est une vraie expérience de lecture de flux RSS sur Windows. Rien à voir avec les produit...
Cliquez pour lire la suite de l'article par Vko
Forum
ALGORITHMESALGORITHMES par whayoub
Cliquez pour lire la suite par whayoub
Logiciels
Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.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 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
|