- /*******************************************************/
- /* */
- /* Plusieurs Méthode Outils */
- /* */
- /* LoadDirectory : */
- /* Fenetre de type Enregistrer Sous */
- /* */
- /* SelectDir : */
- /* Fenetre du type Sélectionner un dir */
- /* */
- /* DateJour : */
- /* Retourne la date courante 01/01/2003 */
- /* */
- /* ConvertDate : */
- /* Converti la chaine date sans les caracteres '/' */
- /* */
- /* Créé le 01/12/2002 Par Trinita */
- /* Modifié le 24/01/2003 */
- /* Version 1.0.4 */
- /*******************************************************/
-
- #include <windows.h>
- #include <shlobj.h>
- #include <time.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- #include "tools.h"
-
- #define MAIN_LEN 80
- #define IDC_MAIN_TEXT 100
-
- /* Fenêtre ENREGISTRER SOUS */
- void LoadDirectory(HWND hDlgTools, char szFileName[MAIN_LEN+1])
- {
- /* Déclaration des variables */
- OPENFILENAME ofn;
-
- /* Init des variables */
- ZeroMemory(&ofn, sizeof(ofn));
- szFileName[0]=0;
-
- /* Déclaration de la structure de OPENFILENAME */
- ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = hDlgTools;
- // ofn.hInstance =;
- ofn.lpstrFilter = "Fichiers xls (*.xls)\0Tous (*.*)\0*.*";
- // ofn.lpstrCustomFilter;
- // ofn.nMaxCustFilter;
- // ofn.nFilterIndex;
- ofn.lpstrFile = szFileName;
- ofn.nMaxFile = MAIN_LEN+1;
- // ofn.lpstrFileTitle = "Exportation";
- // ofn.nMaxFileTitle;
- ofn.lpstrInitialDir = "c:\\";
- // ofn.lpstrTitle;
- ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST |
- OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT |
- OFN_NOCHANGEDIR;
- // ofn.nFileOffset;
- // ofn.nFileExtension =;
- ofn.lpstrDefExt = "xls";
- // ofn.lCustData;
- // ofn.lpfnHook;
- ofn.lpTemplateName ="Exportation";
-
- /* Ouverture de la fenetre de selection */
- if ( GetSaveFileName ( &ofn ) )
- {
- /* Récupération du nom de fichier */
- SendMessage(GetDlgItem
- (hDlgTools,IDC_MAIN_TEXT),WM_GETTEXT,sizeof
- (szFileName),(LPARAM)
- szFileName);
- }
- }
-
- /* Sélection d'un répertoire */
- HWND hDlgTool;
-
- int SelectDir( char szPath[MAX_PATH] )
- {
-
- BROWSEINFO bi;
- ITEMIDLIST *il;
- char Buffer[MAX_PATH];
-
- bi.hwndOwner=hDlgTool;
- bi.pidlRoot=NULL;
- bi.pszDisplayName=&Buffer[0];
- bi.lpszTitle="Choisissez un répertoire :";
- bi.ulFlags=0;
- bi.lpfn=NULL;
- if( (il=SHBrowseForFolder(&bi)) ==NULL ) return 0;
- return SHGetPathFromIDList(il, &szPath[0]);
- }
-
- /* Donne la date du jour du PC */
- /* Format CHAR 11 */
- void DateJour (char DateCourante[11])
- {
-
- SYSTEMTIME SystemTime;
- GetSystemTime(&SystemTime); //Initialisation
-
- /* La structure
- SystemTime.wDay => le jour
- SystemTime.wMonth => le mois
- SystemTime.wYear => l'année
- SystemTime.wHour => l'heure
- SystemTime.wMinute => les minutes
- SystemTime.wSecond => les secondes
- SystemTime.wMilliseconds => les milli-secondes
- */
-
- // Construction de la chaine de retour
- // %02d pour avoir le mois ou le jour sur deux caracteres
- char*JourCourant=new char;
- wsprintf(JourCourant,"%02d",SystemTime.wDay);
- strcpy ( DateCourante, JourCourant );
-
- strcat ( DateCourante, "/" );
-
- char*MoisCourant=new char;
- wsprintf(MoisCourant,"%02d",SystemTime.wMonth);
- strcat ( DateCourante, MoisCourant );
-
- strcat ( DateCourante, "/" );
-
- char*AnneeCourante=new char;
- wsprintf(AnneeCourante,"%d",SystemTime.wYear);
- strcat ( DateCourante, AnneeCourante );
-
- return;
-
- }
-
- /* Converti une chaine char de type date <01/01/2002> au format <01012002> */
- void ConvertDate ( char ChaineDate[11], char NewChaineDate[9])
- {
- char *pointeur;
- char *separateur = { "/" };
- char *buffer;
-
- buffer = strdup ( ChaineDate );
-
- // premier appel, le jour
- pointeur = strtok( buffer, separateur );
- strcpy ( NewChaineDate, pointeur );
-
- // pour le mois et l'année
- while( pointeur != NULL )
- {
-
- // Cherche les autres separateur
- pointeur = strtok( NULL, separateur );
- if ( pointeur != NULL )
- {
- strcat ( NewChaineDate, pointeur );
- }
- }
-
- return ;
- }
-
- /********************************************************/
- /* */
- /* tools.h */
- /* */
- /********************************************************/
- /* prototypage des fonctions tools */
- void LoadDirectory ( HWND, char [] );
- int SelectDir( char []);
- void DateJour (char []);
- void ConvertDate ( char [], char []);
-
-
-
-
-
-
-
-
-
-
-
/*******************************************************/
/* */
/* Plusieurs Méthode Outils */
/* */
/* LoadDirectory : */
/* Fenetre de type Enregistrer Sous */
/* */
/* SelectDir : */
/* Fenetre du type Sélectionner un dir */
/* */
/* DateJour : */
/* Retourne la date courante 01/01/2003 */
/* */
/* ConvertDate : */
/* Converti la chaine date sans les caracteres '/' */
/* */
/* Créé le 01/12/2002 Par Trinita */
/* Modifié le 24/01/2003 */
/* Version 1.0.4 */
/*******************************************************/
#include <windows.h>
#include <shlobj.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "tools.h"
#define MAIN_LEN 80
#define IDC_MAIN_TEXT 100
/* Fenêtre ENREGISTRER SOUS */
void LoadDirectory(HWND hDlgTools, char szFileName[MAIN_LEN+1])
{
/* Déclaration des variables */
OPENFILENAME ofn;
/* Init des variables */
ZeroMemory(&ofn, sizeof(ofn));
szFileName[0]=0;
/* Déclaration de la structure de OPENFILENAME */
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hDlgTools;
// ofn.hInstance =;
ofn.lpstrFilter = "Fichiers xls (*.xls)\0Tous (*.*)\0*.*";
// ofn.lpstrCustomFilter;
// ofn.nMaxCustFilter;
// ofn.nFilterIndex;
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAIN_LEN+1;
// ofn.lpstrFileTitle = "Exportation";
// ofn.nMaxFileTitle;
ofn.lpstrInitialDir = "c:\\";
// ofn.lpstrTitle;
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST |
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT |
OFN_NOCHANGEDIR;
// ofn.nFileOffset;
// ofn.nFileExtension =;
ofn.lpstrDefExt = "xls";
// ofn.lCustData;
// ofn.lpfnHook;
ofn.lpTemplateName ="Exportation";
/* Ouverture de la fenetre de selection */
if ( GetSaveFileName ( &ofn ) )
{
/* Récupération du nom de fichier */
SendMessage(GetDlgItem
(hDlgTools,IDC_MAIN_TEXT),WM_GETTEXT,sizeof
(szFileName),(LPARAM)
szFileName);
}
}
/* Sélection d'un répertoire */
HWND hDlgTool;
int SelectDir( char szPath[MAX_PATH] )
{
BROWSEINFO bi;
ITEMIDLIST *il;
char Buffer[MAX_PATH];
bi.hwndOwner=hDlgTool;
bi.pidlRoot=NULL;
bi.pszDisplayName=&Buffer[0];
bi.lpszTitle="Choisissez un répertoire :";
bi.ulFlags=0;
bi.lpfn=NULL;
if( (il=SHBrowseForFolder(&bi)) ==NULL ) return 0;
return SHGetPathFromIDList(il, &szPath[0]);
}
/* Donne la date du jour du PC */
/* Format CHAR 11 */
void DateJour (char DateCourante[11])
{
SYSTEMTIME SystemTime;
GetSystemTime(&SystemTime); //Initialisation
/* La structure
SystemTime.wDay => le jour
SystemTime.wMonth => le mois
SystemTime.wYear => l'année
SystemTime.wHour => l'heure
SystemTime.wMinute => les minutes
SystemTime.wSecond => les secondes
SystemTime.wMilliseconds => les milli-secondes
*/
// Construction de la chaine de retour
// %02d pour avoir le mois ou le jour sur deux caracteres
char*JourCourant=new char;
wsprintf(JourCourant,"%02d",SystemTime.wDay);
strcpy ( DateCourante, JourCourant );
strcat ( DateCourante, "/" );
char*MoisCourant=new char;
wsprintf(MoisCourant,"%02d",SystemTime.wMonth);
strcat ( DateCourante, MoisCourant );
strcat ( DateCourante, "/" );
char*AnneeCourante=new char;
wsprintf(AnneeCourante,"%d",SystemTime.wYear);
strcat ( DateCourante, AnneeCourante );
return;
}
/* Converti une chaine char de type date <01/01/2002> au format <01012002> */
void ConvertDate ( char ChaineDate[11], char NewChaineDate[9])
{
char *pointeur;
char *separateur = { "/" };
char *buffer;
buffer = strdup ( ChaineDate );
// premier appel, le jour
pointeur = strtok( buffer, separateur );
strcpy ( NewChaineDate, pointeur );
// pour le mois et l'année
while( pointeur != NULL )
{
// Cherche les autres separateur
pointeur = strtok( NULL, separateur );
if ( pointeur != NULL )
{
strcat ( NewChaineDate, pointeur );
}
}
return ;
}
/********************************************************/
/* */
/* tools.h */
/* */
/********************************************************/
/* prototypage des fonctions tools */
void LoadDirectory ( HWND, char [] );
int SelectDir( char []);
void DateJour (char []);
void ConvertDate ( char [], char []);