by_rabbit_08
Messages postés
109
Date d'inscription
vendredi 8 avril 2005
Statut
Membre
Dernière intervention
15 mai 2007
1
13 mai 2007 à 18:28
Voila...
Mais comme vous pouvez le voir, rien que cette fonction est très longue. Mais si ca peut aider à trouver la solution, ben c pas grave...
//variables pour tous le fichier
char AncienMDP[100],NouveauMDP[100],ConfirmeMDP[100],login_temp_replace[100];
int test,test2,user_cat;
HWND groupbox_hDlg3,Radio1,Radio2,combo_3;
UINT temp_forme;
int temp_finish;
int temp_paint;
int k4,j4,choix1;
//Thread
HANDLE hThread2;
//hDlg3
HWND edit_compte,edit_mdp,edit_confirme_mdp,combo_1,edit_compte2;
char compte[255],mdp[255],mdp2[255], compte_temp[255];
//variable globale
int num_error2,num_error3;
char temp_pass[255];
//var glob, proc2
int temp_return_dial2;
BOOL APIENTRY Dialog4Proc(HWND hDlg4,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
UINT Trait;
CHAR szFile[MAX_PATH]={0};
HWND radio_couper,radio_coller;
HWND edit_fichier4,edit_info;
HWND bouton_parcourir;
HWND stext_nb;
static HWND trackbar_1;
char temp_text[20], extention[10];
char total[1000];
char *taille;
double i2;
double i3;
int i4;
OPENFILENAME ofn;
FILE *fichier;
HDC hDC, hMemDC;
PAINTSTRUCT ps;
RECT rRect;
switch (uMsg)
{
case WM_INITDIALOG:
GetWindowRect(hDlg4,&rRect);
//coté gauche contenu dans int=rRect.left ; haut contenu dans int=rRect.top
if(choix==0)//premier choix
{
MoveWindow(hDlg4,rRect.left,rRect.top,450,350,FALSE);//changement de la taille de la fenêtre en fonction du choix
SetWindowText(hDlg4, "Decoupage/Recollage de fichier");//changement du titre
}
else
{
MoveWindow(hDlg4,rRect.left,rRect.top,450,250,FALSE);//changement de la taille de la fenêtre en fonction du choix
SetWindowText(hDlg4, "Essai");//changement du titre
}
if(choix==0)
{
radio_couper=CreateWindowEx(
0,
"BUTTON",
"Couper",
WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON|BS_LEFTTEXT,
10,
10,
60,
20,
hDlg4,
(HMENU)ID_RADIO_COUPER,
hinstance2,
NULL
);
radio_coller=CreateWindowEx(
0,
"BUTTON",
"Coller",
WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON|BS_LEFTTEXT,
100,
10,
53,
20,
hDlg4,
(HMENU)ID_RADIO_COLLER,
hinstance2,
NULL
);
edit_fichier4 = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW,
"EDIT",
"",
WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL|ES_NOHIDESEL|WS_TABSTOP,
55,
45,
250,
25,
hDlg4,
(HMENU)ID_EDIT_FICHIER4,
hinstance2,
NULL);
bouton_parcourir = CreateWindowEx(0,
"BUTTON",
"Parcourir",
WS_VISIBLE|WS_CHILD|WS_TABSTOP,
55+200+60,
45,
80,
25,
hDlg4,
(HMENU)ID_BOUTON_PARCOURIR,
hinstance2,
NULL);
trackbar_1 = CreateWindowEx( 0, // no extended styles
TRACKBAR_CLASS, // class name
"Trackbar Control", // title (caption)
WS_CHILD | WS_VISIBLE | TBS_AUTOTICKS, // style
10,
150+100, // position
200,
30, // size
hDlg4, // parent window
(HMENU)ID_TRACKBAR, // control identifier
hinstance2, // instance
NULL
);
stext_nb = CreateWindowEx(0,
"STATIC",
"essai",
WS_VISIBLE|WS_CHILD,
215+105,
155+100,
80,
25,
hDlg4,
(HMENU)ID_STEXT_NB,
hinstance2,
NULL);
edit_info = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW,
"EDIT",
"",
WS_VISIBLE|WS_CHILD|ES_NOHIDESEL|ES_MULTILINE|ES_AUTOVSCROLL|ES_WANTRETURN|ES_READONLY|ES_OEMCONVERT,
10,
105,
425,
80,
hDlg4,
(HMENU)ID_EDIT_INFO,
hinstance2,
NULL);
combo_3 = CreateWindowEx(0,
"COMBOBOX",
NULL,
WS_CHILD|WS_VISIBLE|CBS_DROPDOWNLIST,
215,
155+125,
130,
200,
hDlg4,
(HMENU)ID_COMBO_3,
hinstance2,
NULL);
SendMessage(combo_3, CB_ADDSTRING, 0, (LPARAM)"octets [o]");
SendMessage(combo_3, CB_ADDSTRING, 0, (LPARAM)"kilooctets [ko]");
SendMessage(combo_3, CB_ADDSTRING, 0, (LPARAM)"Megaoctets [Mo]");
SendMessage(combo_3, CB_ADDSTRING, 0, (LPARAM)"Gigaoctets [Go]");
SendMessage(combo_3, WM_SETFONT, (WPARAM)font_normal, MAKELPARAM(TRUE, 0));
SendDlgItemMessage(hDlg4, ID_COMBO_3, CB_SETCURSEL, 1, 0);
SendMessage(radio_couper, WM_SETFONT, (WPARAM)font_normal, MAKELPARAM(TRUE, 0));
SendMessage(radio_coller, WM_SETFONT, (WPARAM)font_normal, MAKELPARAM(TRUE, 0));
SendMessage(edit_fichier4, WM_SETFONT, (WPARAM)font_normal, MAKELPARAM(TRUE, 0));
SendMessage(bouton_parcourir, WM_SETFONT, (WPARAM)font_normal, MAKELPARAM(TRUE, 0));
SendMessage(trackbar_1, WM_SETFONT, (WPARAM)font_normal, MAKELPARAM(TRUE, 0));
SendMessage(stext_nb, WM_SETFONT, (WPARAM)font_normal, MAKELPARAM(TRUE, 0));
SendMessage(edit_info, WM_SETFONT, (WPARAM)font_petit, MAKELPARAM(TRUE, 0));
Trait=1;
SetDlgItemInt(hDlg4, ID_STEXT_NB, Trait, FALSE);
SendMessage(trackbar_1, TBM_SETRANGE,FALSE, MAKELONG(1, 10));
SendMessage(trackbar_1, TBM_SETPOS,TRUE, Trait);
SendMessage(hDlg4, WM_HSCROLL, 0, 0);
CheckDlgButton(hDlg4,ID_RADIO_COUPER,BST_CHECKED);
}
return FALSE;
case WM_HSCROLL:
SetDlgItemInt(hDlg4, ID_STEXT_NB, SendMessage(trackbar_1, TBM_GETPOS, 0, 0), FALSE);
char_clean(temp_text);
GetDlgItemText(hDlg4,ID_STEXT_NB,temp_text,9999);
i4=strlen(temp_text);
temp_text[i4]=' ';
temp_text[i4+1]='k';
temp_text[i4+2]='o';
temp_text[i4+3]='\0';
SetDlgItemText(hDlg4,ID_STEXT_NB,temp_text);
return TRUE;
case WM_PAINT:
hDC = BeginPaint(hDlg4, & ps); //debut de dessin
SetBkMode(hDC, TRANSPARENT); //defini comme semi-transparent
SelectObject(hDC, font_normal); //application de la police d'ecriture
//AFFICHAGE DU TEXTE SUR LA FENÊTRE DE LOGIN
if(choix==0)
{
TextOut(hDC, 10, 50, "Fichier", strlen("Fichier")); //affichage de login
TextOut(hDC, 10, 50+35, "Informations Fichier", strlen("Informations Fichier"));
TextOut(hDC, 215, 155+100, "Taille des parties:", strlen("Taille des parties:"));
}
DeleteDC(hMemDC); //suppression de la mémoire de dessin
EndPaint(hDlg4, & ps); //fin de dessin
break;
case WM_COMMAND:
if (LOWORD(wParam) == ID_COMBO_3)
{
if(HIWORD(wParam) == CBN_SELCHANGE)
{
choix1 = SendDlgItemMessage(hDlg4, ID_COMBO_3, CB_GETCURSEL, 0, 0);
switch(choix1)
{
case 0:
//octets
SetDlgItemInt(hDlg4, ID_STEXT_NB, SendMessage(trackbar_1, TBM_GETPOS, 0, 0), FALSE);
char_clean(temp_text);
GetDlgItemText(hDlg4,ID_STEXT_NB,temp_text,9999);
i4=strlen(temp_text);
temp_text[i4]=' ';
temp_text[i4+1]='o';
temp_text[i4+2]='\0';
SetDlgItemText(hDlg4,ID_STEXT_NB,temp_text);
break;
case 1:
//ko
/*SetDlgItemInt(hDlg4, ID_STEXT_NB, SendMessage(trackbar_1, TBM_GETPOS, 0, 0), FALSE);
char_clean(temp_text);
GetDlgItemText(hDlg4,ID_STEXT_NB,temp_text,9999);
i4=strlen(temp_text);
temp_text[i4]=' ';
temp_text[i4+1]='o';
temp_text[i4+2]='k';
temp_text[i4+3]='\0';
SetDlgItemText(hDlg4,ID_STEXT_NB,temp_text);*/
break;
case 2:
//Mo
break;
case 3:
//Go
break;
}
}
}
if(LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg4,0);
return TRUE;
}
if(LOWORD(wParam) ID_BOUTON_PARCOURIR && (HIWORD(wParam) BN_CLICKED))
{
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hDlg4;
ofn.lpstrFile = szFile;
ofn.nMaxFile = MAX_PATH;
//ofn.lpstrFilter ="Fichier source C\0*.c\0Fichier source CPP\0*.cpp\0Tous les fichiers\0*.*\0";
ofn.lpstrFilter ="Tous les fichiers\0*.*\0";
ofn.nFilterIndex = 1;
ofn.lpstrTitle="Parcourir";
ofn.Flags=OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
ofn.lpstrInitialDir=NULL;
if (GetOpenFileName(&ofn)==TRUE)
{
SendMessage(edit_fichier4, WM_SETTEXT, 0, (LPARAM)szFile);
SetDlgItemText(hDlg4, ID_EDIT_FICHIER4, "");
SetDlgItemText(hDlg4, ID_EDIT_FICHIER4, szFile);
if(IsDlgButtonChecked(hDlg4,ID_RADIO_COUPER)==BST_CHECKED)
{
//Couper
EnableWindow(GetDlgItem(hDlg4,ID_RADIO_COLLER),FALSE);
//#####################
char_clean(total);
strcpy(total,"Nom et Chemin: ");
strcat(total,ofn.lpstrFile);
strcat(total,"\r\n");
strcat(total,"Taille du Fichier: ");
fichier = fopen(szFile,"rb");
i4=0;
fseek(fichier, 0, SEEK_END);
i2=ftell(fichier);
fclose(fichier);
itoa((long)i2,taille,10);
strcat(total,taille);
strcat(total," octets");
strcat(total,"\r\n");
i3=i2/1024;//i3 contient la taille en ko pas arrondis
char_clean(taille);
sprintf(taille,"%.2lf",i3);
strcat(total,"Taille du Fichier en unités choisies: ");
strcat(total,taille);
strcat(total," ko");
strcat(total,"\r\n");
strcat(total,"Extention du fichier: ");
char_clean(extention);
i4=strlen(szFile);
char_clean(extention);
i4=strlen(szFile);
while(szFile[i4]!='.')
{
i4--;
}
i4++;
k4=0;
for(j4=i4;j4<strlen(szFile);j4++)
{
extention[k4]=szFile[j4];
k4++;
}
strlwr(extention);
strcat(total,extention);
SetDlgItemText(hDlg4, ID_EDIT_INFO, total);
}
else
{
//Coller
EnableWindow(GetDlgItem(hDlg4,ID_RADIO_COUPER),FALSE);
}
}
else
{
//erreur
}
}
return TRUE;
default:
return FALSE;
}
}