Vaccation-win32 vcpp6 (merci à xentor609)

Description

Salut à tous,
Ce programme me sert en quelque sorte d'emploi du temps,
En effet je ne travail pas comme tout le monde, c-a-d 5 jours ouvrables
+ 1 week-end, je bosse en cycle de 8 vaccations:
1° Vaccation----> 1° Nuit
2° Vaccation----> 1° Descente de nuit
3° Vaccation----> 1° Journee
4° Vaccation----> 2° Nuit
5° Vaccation----> 2° Descente de nuit
6° Vaccation----> 2° Journee
7° Vaccation----> 1° Repos
8° Vaccation----> 2° Repos

Je l'ai déjà codé en mode console et en Javascript, les sources sont dispo sur notre site vénéré !!!
Je remercie Xentor609 pour sa patience et son aide qui m'ont bien orienté, dailleur
les bases du prog sont pompé sur une de ses sources.

Source / Exemple :


/* Ce programme me sert en quelque sorte d'emploi du temps,
En effet je ne travail pas comme tout le monde, c-a-d 5 jours ouvrables
+ 1 week-end, je bosse en cycle de 8 vaccations:
1° Vaccation----> 1° Nuit
2° Vaccation----> 1° Descente de nuit
3° Vaccation----> 1° Journee
4° Vaccation----> 2° Nuit
5° Vaccation----> 2° Descente de nuit
6° Vaccation----> 2° Journee
7° Vaccation----> 1° Repos
8° Vaccation----> 2° Repos

  • /
#include <windows.h> #include "resource.h" HINSTANCE hInst = NULL; HWND hwnd = NULL; ////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////// // Declaration des Variables int nbJourDebut, nbMoisDebut, nbAnneeDebut, nbNombre; int nbJourFin, nbMoisFin; char *NomVaccation; int NumeroJour; char *NomJour; int nbNombreJours; int Fevrier; int MaxJours; int Annee2000 = 2000; int EcartAnnees; int AnneesBissextiles; int EcartJoursAnnees; int TotalJoursMois; int NombreDeJours; int Vaccation; long i; const int nbAnneeBisextile = 2000; bool ModeAuto=false; ////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////// // Declaration des Fonctions bool AnneeBisextile (int Annee) { int Diff = abs(nbAnneeBisextile - Annee); int Rest = Diff % 4; if (!Rest) return true; else return false; } int AnneeBisextilePendant (int Annee1, int Annee2) { int ABP=0; int Diff = abs(Annee1 - Annee2); int i; for (i=0;i<=Diff;i++) { if (Annee1>Annee2) { if (AnneeBisextile(Annee2+i)) ABP++; } else { if (AnneeBisextile(Annee1+i)) ABP++; } } return ABP; } void RecupereTout (HWND hwnd) { char strJourDebut[3], strMoisDebut[3], strAnneeDebut[5];// strNombre[6]; GetDlgItemText(hwnd,IDC_EDIT1,strJourDebut,3); nbJourDebut = (int) atof (strJourDebut); GetDlgItemText(hwnd,IDC_EDIT2,strMoisDebut,3); nbMoisDebut = (int) atof (strMoisDebut); GetDlgItemText(hwnd,IDC_EDIT3,strAnneeDebut,5); nbAnneeDebut = (int) atof (strAnneeDebut); } bool VerifieSiVide () { if ((nbJourDebut != 0) && (nbMoisDebut != 0) && (nbAnneeDebut != 0)) { return true; } else { return false; } } bool VerifieJour (HWND hwnd) { bool TorF=false; switch (nbMoisDebut) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: { if (nbJourDebut>31) { SetDlgItemTextA (hwnd,IDC_EDIT1,""); MessageBox(hwnd,"Jour incorrect !!!","Erreur Date !!!",MB_ICONWARNING); } else { TorF=true; } break; } case 4: case 6: case 9: case 11: { if (nbJourDebut>30) { SetDlgItemTextA (hwnd,IDC_EDIT1,""); MessageBox(hwnd,"Jour incorrect !!!","Erreur Date !!!",MB_ICONWARNING); } else { TorF=true; } break; } case 2 : { if (AnneeBisextile(nbAnneeDebut)) { if (nbJourDebut>29) { SetDlgItemTextA (hwnd,IDC_EDIT1,""); MessageBox(hwnd,"Jour incorrect !!!","Erreur Date !!!",MB_ICONWARNING); } else { TorF=true; } } else { if (nbJourDebut>28) { SetDlgItemTextA (hwnd,IDC_EDIT1,""); MessageBox(hwnd,"Jour incorrect !!!","Erreur Date !!!",MB_ICONWARNING); } else { TorF=true; } } break; } } return TorF; } bool VerifieDate (HWND hwnd) { bool TorF=false; if (nbAnneeDebut > 9725) { SetDlgItemTextA (hwnd,IDC_EDIT3,""); MessageBox(hwnd,"Vous n'avez pas le droit d'aller au-delà de 9725 !!!","Erreur !!!",MB_ICONWARNING); } else { if ((nbMoisDebut < 1) || (nbMoisDebut>12)) { SetDlgItemTextA (hwnd,IDC_EDIT2,""); MessageBox(hwnd,"Mois incorrect !!!","Erreur Date !!!",MB_ICONWARNING); } else { TorF=VerifieJour (hwnd); } } return TorF; } void CalculVaccation(HWND hwnd) { // Calcul du nombre total de jour entre le 1° Janvier 2000 // et la date saisie EcartAnnees= nbAnneeDebut-Annee2000-1; AnneesBissextiles= (EcartAnnees / 4); EcartJoursAnnees= (AnneesBissextiles* 366) + ((EcartAnnees-AnneesBissextiles)*365); if ((nbAnneeDebut % 4 ) == 0) {Fevrier= 29;} else {Fevrier= 28;} switch (nbMoisDebut) { case 1: TotalJoursMois = 0;break; case 2: TotalJoursMois = 31;break; case 3: TotalJoursMois = 31+Fevrier;break; case 4: TotalJoursMois = 31+Fevrier+31;break; case 5: TotalJoursMois = 31+Fevrier+31+30;break; case 6: TotalJoursMois = 31+Fevrier+31+30+31;break; case 7: TotalJoursMois = 31+Fevrier+31+30+31+30;break; case 8: TotalJoursMois = 31+Fevrier+31+30+31+30+31;break; case 9: TotalJoursMois = 31+Fevrier+31+30+31+30+31+31;break; case 10: TotalJoursMois = 31+Fevrier+31+30+31+30+31+31+30;break; case 11: TotalJoursMois = 31+Fevrier+31+30+31+30+31+31+30+31;break; case 12: TotalJoursMois = 31+Fevrier+31+30+31+30+31+31+30+31+30;break; } NombreDeJours= TotalJoursMois+EcartJoursAnnees+nbJourDebut; // Calcul de la Vaccation Vaccation= NombreDeJours%8; switch (Vaccation) { case 0: NomVaccation = " Premier repos "; SetDlgItemText (hwnd,IDC_EDIT4,NomVaccation); break; case 1: NomVaccation = " Deuxieme repos "; SetDlgItemText (hwnd,IDC_EDIT4,NomVaccation); break; case 2: NomVaccation = " Premiere nuit "; SetDlgItemText (hwnd,IDC_EDIT4,NomVaccation); break; case 3: NomVaccation = " Premiere descente de nuit "; SetDlgItemText (hwnd,IDC_EDIT4,NomVaccation);break; case 4: NomVaccation = " Premiere Journee "; SetDlgItemText (hwnd,IDC_EDIT4,NomVaccation);break; case 5: NomVaccation = " Deuxieme nuit "; SetDlgItemText (hwnd,IDC_EDIT4,NomVaccation);break; case 6: NomVaccation = " Deuxieme descente de nuit "; SetDlgItemText (hwnd,IDC_EDIT4,NomVaccation);break; case 7: NomVaccation = " Deuxieme Journee "; SetDlgItemText (hwnd,IDC_EDIT4,NomVaccation);break; default: NomVaccation = " Erreur !!! "; SetDlgItemText (hwnd,IDC_EDIT4,NomVaccation);break; } // Calcul du jour de la semaine NumeroJour= NombreDeJours%7; switch (NumeroJour) { case 0: NomJour = " Dimanche "; SetDlgItemText (hwnd,IDC_EDIT5,NomJour); break; case 1: NomJour = " Lundi "; SetDlgItemText (hwnd,IDC_EDIT5,NomJour); break; case 2: NomJour = " Mardi "; SetDlgItemText (hwnd,IDC_EDIT5,NomJour); break; case 3: NomJour = " Mercredi "; SetDlgItemText (hwnd,IDC_EDIT5,NomJour);break; case 4: NomJour = " Jeudi "; SetDlgItemText (hwnd,IDC_EDIT5,NomJour);break; case 5: NomJour = " Vendredi "; SetDlgItemText (hwnd,IDC_EDIT5,NomJour);break; case 6: NomJour = " Samedi "; SetDlgItemText (hwnd,IDC_EDIT5,NomJour);break; default: NomJour = " Erreur !!! "; SetDlgItemText (hwnd,IDC_EDIT5,NomJour);break; } } void ActiveModeAuto (HWND hwnd) { EnableWindow ( GetDlgItem ( hwnd , IDOK ) , false ) ; SetWindowText( GetDlgItem ( hwnd , IDOK ) , "Automatique" ) ; } void DesactiveModeAuto (HWND hwnd) { ModeAuto=false; EnableWindow ( GetDlgItem ( hwnd , IDOK ) , true ) ; SetWindowText( GetDlgItem ( hwnd , IDOK ) , "&Calculer" ) ; } ////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////// // Declaration des Procedures LRESULT CALLBACK WindowProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam); LRESULT CALLBACK DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK DlgProc2(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK WindowProc(HWND hwnd, // Handle de la fenêtre UINT msg, // message du système WPARAM wparam, // paramètre supplémentaire LPARAM lparam) // paramètre supplémentaire { // les messages que nous ne traitons pas sont dirigés par Window return (DefWindowProc(hwnd, msg, wparam, lparam)); } // Le gestionnaire d'évènements pour notre boîte de dialogue LRESULT CALLBACK DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_INITDIALOG: { //hIcon = LoadIcon ( hInst , MAKEINTRESOURCE ( IDI_ICON1 ) ) ; break; } // Un bouton de commande (le # du bouton est contenu dans le low 8-bit de wParam) case WM_COMMAND: { switch(LOWORD(wParam)) { case IDC_EDIT1: case IDC_EDIT2: case IDC_EDIT3: { if (ModeAuto) DesactiveModeAuto(hwnd); break; } case ID_VIDETOUT: { SetDlgItemTextA (hwnd,IDC_EDIT1,""); SetDlgItemTextA (hwnd,IDC_EDIT2,""); SetDlgItemTextA (hwnd,IDC_EDIT3,""); SetDlgItemTextA (hwnd,IDC_EDIT4,""); SetDlgItemTextA (hwnd,IDC_EDIT5,""); break; } case IDOK: { RecupereTout(hwnd); if (!VerifieSiVide()) { MessageBox(hwnd,"Il manque des informations !!!","Erreur !!!",MB_ICONWARNING); } else { if (VerifieDate(hwnd)) { //nbNombreJours = JourMoisVersJours () + nbNombre; //JoursVersJourMoisAnnee(); CalculVaccation (hwnd); //MontreResultat(hwnd); ModeAuto=true; ActiveModeAuto(hwnd); } } break; } // Quitter case ID_QUIT: { EndDialog(hwnd, FALSE); break; } case WM_DESTROY: { EndDialog(hwnd, FALSE); break; } } break; } default: return FALSE; } return TRUE; } ///////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////// // Declaration de la Procedure principale (Win)Main int WINAPI WinMain( HINSTANCE hInstance, // handle sur l'instance présente HINSTANCE hPrevInst, // handle sur l'instance précédente (Win 3.1, obsolète) LPSTR lpCmdLine, // ptr sur la ligne de commande (ie: argv[], argc) int nCmdShow) // l'état de la fenêtre { // sauvegarder l'instance de notre programme hInst = hInstance; // Activer la boîte de dialogue DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), NULL, ( DLGPROC ) DlgProc); return (0); }

Conclusion :


J'attend vos remarques...
Merci.
depuis le 07 Juin la version donne aussi le jour de la semaine

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.