1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
/********************************************************/
/* */
/* 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)\0*.xls\0Fichiers txt (*.txt)\0*.txt\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
char*JourCourant=new char;
wsprintf(JourCourant,"%d",SystemTime.wDay);
strcpy ( DateCourante, JourCourant );
strcat ( DateCourante, "/" );
char*MoisCourant=new char;
wsprintf(MoisCourant,"%d",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 ;
} |
Partager