begin process at 2012 05 27 21:15:00
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Date / Heure

 > VACCATION-WIN32 VCPP6 (MERCI À XENTOR609)

VACCATION-WIN32 VCPP6 (MERCI À XENTOR609)


 Information sur la source

Note :
Aucune note
Catégorie :Date / Heure Niveau :Débutant Date de création :05/06/2004 Date de mise à jour :07/06/2004 22:01:39 Vu / téléchargé :3 713 / 64

Auteur : sebman

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

 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

  • /* 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);
  • }
/* 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

 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 une capture VACCATION (AVEC FONCTION) CONSOLERIE, REMIX GCC
Source avec Zip DATE EN BRETON (MODE CONSOLE,VCPP6)
Source avec Zip CHRONOMETRE AU MILLIEME DE SECONDES EN MODE CONSOLE VC++6
Source avec Zip NOMBRES PREMIERS AVEC CHRONO ET INCREMENTEUR INCORPORÉ
VACCATION (AVEC FONCTIONS) CONSOLERIE VCPP6

 Sources de la même categorie

DATETIMECONVERTER par guill76
Source avec Zip CLASSE DE DATE LOCALISÉE (20 LANGUES) par exar
Source avec Zip CLASSE MOMENT V2.0 par le_duche
CALCUL DATE DE PAQUES (DATE MOBILE) par steph12358
Source avec une capture VACCATION (AVEC FONCTION) CONSOLERIE, REMIX GCC par sebman

Commentaires et avis

Commentaire de BruNews le 05/06/2004 11:59:48 administrateur CS

#include &lt;iostream.h&gt;
#include &lt;stdio.h&gt;
#include &lt;sys\timeb.h&gt;
a part stdio.h qui sert pour formater un float (sprintf) dans une chaine, tout ceci n'a rien a faire dans un prog Windows, a enlever.
A quoi te sert d'enregistrer une classe de fenetre dans WinMain si tu ne t'en sers pas ???

default: printf("Vous vous etes plantes lors de la saisie du mois !!!\n");break;
C'est sense sortir OU ce printf ??? Un prog commençant en WinMain n'est pas console, c'est l'un ou l'autre.

Faudrait que tu lises Petzold.
Bosse bien.

Commentaire de sebman le 05/06/2004 20:25:30

Merci BruNews de tes remarques, oh combien constructives !!!
Alors j'ai sucré les fichiers entete et le printf.
c't'erreur vien du fait que j'avais pompé sur ma source en mode console.
Mais pour WinMain, c'est du à ma pompe sur la source de l'ami Xentor609
Soit indulgent c'est ma première source en en C pour win32
J'apprend doucement, mais surement !!!

bon autrement ki c'est Petzol

Commentaire de BruNews le 05/06/2004 22:14:19 administrateur CS

Petzold, a lire absolument:
http://brunews.free.fr/brunews/download/CP5.zip
http://brunews.free.fr/brunews/download/CP5Sources.zip

Commentaire de sebman le 06/06/2004 08:16:39

Merci beaucoup,j'n'en avais jamais entendu parler!!!
Ca n'a pas l'air si compliqué même si c'est en anglais

 Ajouter un commentaire




Nos sponsors


Sondage...

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



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

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