begin process at 2010 03 21 14:48:59
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Application

 > CALCULER SES MOYENNES

CALCULER SES MOYENNES


 Information sur la source

Note :
Aucune note
Catégorie :Application Classé sous :moyennes, graphe, graphique, win32, dialog Niveau :Débutant Date de création :15/04/2008 Date de mise à jour :12/10/2008 02:49:46 Vu / téléchargé :3 466 / 227

Auteur : uaip

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

 Description

Cliquez pour voir la capture en taille normale
Mon premier programme en C, entièrement recodé. Il n'est pas vraiment révolutionnaire mais permet de calculer simplement ses moyennes (donc destiné aux étudiants) selon certains paramètres, et d'afficher les résultats dans un graphe.

On peut maintenant choisir ses propres coefficients (de 1 à 99), sauvegarder les notes, charger des tableaux de notes, on peut également afficher la médiane et l'étendue des notes. L'application permet aussi de faire un screenshot de la fenêtre (cette fonction n'est pas de moi, je l'ai trouvée ici). J'ai également rajouté une fenêtre qui affiche les coefficients pour le BAC des 3 principales filières (L, S, SES) ainsi que leurs spécialités. Pourquoi ? Cela m'a permis de gérer une TreeView.

(J'ai utilisé win32 donc le programme tourne uniquement sous Windows)
Développé sous Codes::Blocks (final: 74ko).

Source

  • #include <windows.h>
  • #include <string.h>
  • #include <stdio.h>
  • #include <math.h>
  • #include <richedit.h>
  • #include <commctrl.h>
  • #include "define.h"
  • //Variables globales et prototypes
  • HINSTANCE hinst;
  • void Refresh();
  • void Draw(BOOL calcul);
  • int __stdcall HwndToBmpFile(HWND hwnd,char *pszflname);
  • LRESULT CALLBACK MainWndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
  • BOOL APIENTRY Dialog1Proc1(HWND,UINT,WPARAM,LPARAM);
  • BOOL APIENTRY Dialog1Proc2(HWND,UINT,WPARAM,LPARAM);
  • BOOL APIENTRY ProcCoefficients(HWND,UINT,WPARAM,LPARAM);
  • static HBRUSH ColorStatic(HWND,WPARAM,LPARAM);
  • int nbritem=0;
  • char nbritem2[100];
  • float afficheMoy=0;
  • int calcul=1;
  • int popup=0;
  • HANDLE fo,fp;
  • CHAR szFile[MAX_PATH]={0};
  • HWND hwnd,texte,ok,edit,annuler,recommencer,texte_background,list,combo,background,box,box2,goback,enregistrer,imprimer,
  • check,coeff05,coeff1,coeff2,coeffautre,coeff,note,about,charger,coeffBAC,hTTip;
  • //Déclaration de la fenêtre
  • int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) {
  • //Variables
  • MSG msg;
  • hinst=hinstance;
  • //Paramètres de la fenêtre
  • WNDCLASS wc;
  • wc.style=0;
  • wc.lpfnWndProc=MainWndProc;
  • wc.cbClsExtra=0;
  • wc.cbWndExtra=0;
  • wc.hInstance=hinstance;
  • wc.hIcon=LoadIcon(hinstance,MAKEINTRESOURCE(1));
  • wc.hCursor=LoadCursor(NULL,IDC_ARROW);
  • wc.hbrBackground=(HBRUSH)(COLOR_3DFACE+1);
  • wc.lpszMenuName= NULL;
  • wc.lpszClassName="MaWinClass";
  • if(!RegisterClass(&wc)) return FALSE;
  • //Création de la fenêtre
  • int cxS=GetSystemMetrics(SM_CXSCREEN);
  • int cyS=GetSystemMetrics(SM_CYSCREEN);
  • hwnd=CreateWindowEx(WS_EX_WINDOWEDGE,"MaWinClass","Aucune valeur",WS_CAPTION|WS_MINIMIZEBOX|WS_SYSMENU,(cxS-700)/2,(cyS-275)/2,320,275,HWND_DESKTOP,NULL,hinstance,NULL);
  • //Mise en place des contrôles
  • box=CreateWindowEx(0,"BUTTON","Aucune valeur",SS_LEFT|WS_CHILD|WS_VISIBLE|BS_GROUPBOX,10,10,280,225,hwnd,(HMENU)ID_BOX,hinstance,NULL);
  • SendMessage(box,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • box2=CreateWindowEx(0,"BUTTON","Propriétés :",SS_LEFT|WS_CHILD|WS_VISIBLE|BS_GROUPBOX,90,242,200,58,hwnd,(HMENU)ID_BOX2,hinstance,NULL);
  • SendMessage(box2,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • edit=CreateWindowEx(WS_EX_STATICEDGE|WS_EX_CLIENTEDGE,"EDIT","12.5",WS_CHILD|WS_VISIBLE|WS_EX_CLIENTEDGE|WS_EX_STATICEDGE,110,40,55,20,hwnd,(HMENU)ID_EDIT,hinstance,NULL);
  • SendMessage(edit,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • texte_background=CreateWindowEx(WS_EX_STATICEDGE,"STATIC","",SS_LEFT|WS_CHILD|WS_VISIBLE,110,150,170,74,hwnd,(HMENU)ID_TEXTE_BACKGROUND,hinstance,NULL);
  • SendMessage(texte_background,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • texte=CreateWindowEx(0,"STATIC","Astuce : Pensez à ramener vos notes sur 20 afin que les coefficients (s'ils sont activés) soient proportionnels.",WS_CHILD|WS_VISIBLE,120,160,150,60,hwnd,(HMENU)ID_TEXTE,hinstance,NULL);
  • SendMessage(texte,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • ok=CreateWindowEx(0,"BUTTON","OK",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE,170,40,30,20,hwnd,(HMENU)ID_OK,hinstance,NULL);
  • SendMessage(ok,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • annuler=CreateWindowEx(0,"BUTTON","Annuler",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE|WS_DISABLED,110,70,90,20,hwnd,(HMENU)ID_ANNULER,hinstance,NULL);
  • SendMessage(annuler,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • recommencer=CreateWindowEx(0,"BUTTON","Recommencer",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE|WS_DISABLED,110,90,90,20,hwnd,(HMENU)ID_RECOMMENCER,hinstance,NULL);
  • SendMessage(recommencer,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • list=CreateWindowEx(WS_EX_STATICEDGE,"LISTBOX",NULL,WS_CHILD|WS_VISIBLE|WS_VSCROLL,20,40,80,200,hwnd,(HMENU)ID_LIST,hinstance,NULL);
  • SendMessage(list,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • combo=CreateWindowEx(0,"COMBOBOX",NULL,WS_CHILD|WS_VISIBLE|CBS_DROPDOWNLIST,110,120,170,0,hwnd,(HMENU)ID_COMBO,hinstance,NULL);
  • SendMessage(combo,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • goback=CreateWindowEx(WS_EX_STATICEDGE,"BUTTON",">",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE,295,35,15,40,hwnd,(HMENU)ID_GOBACK,hinstance,NULL);
  • SendMessage(goback,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • enregistrer=CreateWindowEx(0,"BUTTON","Enregistrer",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE,95,255,90,20,hwnd,(HMENU)ID_ENREGISTRER,hinstance,NULL);
  • SendMessage(enregistrer,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • imprimer=CreateWindowEx(0,"BUTTON","Impression Ecran",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE,195,255,90,20,hwnd,(HMENU)ID_IMPRIMER,hinstance,NULL);
  • SendMessage(imprimer,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • charger=CreateWindowEx(0,"BUTTON","Charger...",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE,95,275,90,20,hwnd,(HMENU)ID_CHARGER,hinstance,NULL);
  • SendMessage(charger,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • check=CreateWindowEx(0,"BUTTON","Afficher la grille",WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX,195,275,89,20,hwnd,(HMENU)ID_CHECK,hinstance,NULL);
  • SendMessage(check,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • background=CreateWindowEx(WS_EX_STATICEDGE,"STATIC",NULL,SS_LEFT|WS_CHILD|WS_VISIBLE,205,40,75,70,hwnd,(HMENU)ID_BACKGROUND,hinstance,NULL);
  • SendMessage(background,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • coeff05=CreateWindowEx(0,"BUTTON","0.5",WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON,210,44,69,17,hwnd,(HMENU)ID_COEFF05,hinstance,NULL);
  • SendMessage(coeff05,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • coeff1=CreateWindowEx(0,"BUTTON","1",WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON,210,59,69,17,hwnd,(HMENU)ID_COEFF1,hinstance,NULL);
  • SendMessage(coeff1,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • coeff2=CreateWindowEx(0,"BUTTON","2",WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON,210,74,69,17,hwnd,(HMENU)ID_COEFF2,hinstance,NULL);
  • SendMessage(coeff2,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • coeffautre=CreateWindowEx(0,"BUTTON","autre...",WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON,210,89,69,17,hwnd,(HMENU)ID_COEFFAUTRE,hinstance,NULL);
  • SendMessage(coeffautre,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • note=CreateWindowEx(0,"STATIC","Note :",WS_CHILD|WS_VISIBLE,110,25,50,14,hwnd,(HMENU)ID_NOTE,hinstance,NULL);
  • SendMessage(note,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • coeff=CreateWindowEx(0,"STATIC","Coefficient :",WS_CHILD|WS_VISIBLE,205,25,60,14,hwnd,(HMENU)ID_COEFF,hinstance,NULL);
  • SendMessage(coeff,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • note=CreateWindowEx(0,"STATIC","Note (coefficient)",WS_CHILD|WS_VISIBLE,20,25,90,14,hwnd,(HMENU)ID_EXEMPLE,hinstance,NULL);
  • SendMessage(note,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • about=CreateWindowEx(WS_EX_STATICEDGE,"BUTTON","A propos...",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE,10,274,70,22,hwnd,(HMENU)ID_ABOUT,hinstance,NULL);
  • SendMessage(about,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • coeffBAC=CreateWindowEx(0,"BUTTON","Coeffs BAC",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE,10,255,70,20,hwnd,(HMENU)ID_BAC,hinstance,NULL);
  • SendMessage(coeffBAC,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
  • SendMessage(combo,CB_ADDSTRING,0,(LPARAM)"Moyenne (avec coefficients)");
  • SendMessage(combo,CB_ADDSTRING,0,(LPARAM)"Moyenne (sans coefficients)");
  • SendMessage(combo,CB_ADDSTRING,0,(LPARAM)"Nombre de notes >= 10");
  • SendMessage(combo,CB_ADDSTRING,0,(LPARAM)"Nombre de notes < 10");
  • SendMessage(combo,CB_ADDSTRING,0,(LPARAM)"Etendue (différence max - min)");
  • SendMessage(combo,CB_ADDSTRING,0,(LPARAM)"Médiane (avec coefficients)");
  • SendMessage(combo,CB_ADDSTRING,0,(LPARAM)"Médiane (sans coefficients)");
  • SendMessage(combo,CB_SELECTSTRING,0,(LPARAM)"Moyenne (avec coefficients)");
  • CheckDlgButton(hwnd,ID_COEFF1,BST_CHECKED);
  • //Création des Tooltips
  • TOOLINFO ti;
  • RECT rect;
  • hTTip=CreateWindow(TOOLTIPS_CLASS,NULL,WS_POPUP|TTS_NOPREFIX,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,hwnd,NULL,hinstance,NULL);
  • GetClientRect(hwnd,&rect);
  • ti.cbSize=sizeof(TOOLINFO);
  • ti.uFlags=TTF_SUBCLASS;
  • GetClientRect(hwnd,&rect);
  • for(int a=1;a <= 137;a++) {
  • ti.hwnd=GetDlgItem(hwnd,a);
  • ti.uId=0;
  • if (a == ID_OK)
  • ti.lpszText="Ajouter la note à la liste";
  • else if (a == ID_ANNULER)
  • ti.lpszText="Annuler la dernière note";
  • else if (a == ID_RECOMMENCER)
  • ti.lpszText="SUpprimer toutes les notes";
  • else if (a == ID_LIST)
  • ti.lpszText="Liste des notes";
  • else if (a == ID_EDIT)
  • ti.lpszText="Tapez vos notes ici";
  • else if (a == ID_COMBO)
  • ti.lpszText="Interractions sur les notes";
  • else if (a == ID_GOBACK)
  • ti.lpszText="Afficher/cacher le graphe";
  • else if (a == ID_ENREGISTRER)
  • ti.lpszText="Enregistrer le tableau de notes actuel";
  • else if (a == ID_IMPRIMER)
  • ti.lpszText="Faire une 'impression-écran' de cette fenêtre (permet de sauvegarder le graphe)";
  • else if (a == ID_CHECK)
  • ti.lpszText="Afficher/cacher la grille sur le graphe";
  • else if (a == ID_COEFFAUTRE)
  • ti.lpszText="Choisir son propre coefficient (entre 1 et 99)";
  • else if (a == ID_ABOUT)
  • ti.lpszText="Afficher l'auteur du logiciel";
  • else if (a == ID_CHARGER)
  • ti.lpszText="Charger un tableau de notes";
  • ti.rect.left=rect.left;
  • ti.rect.top=rect.top;
  • ti.rect.right=rect.right;
  • ti.rect.bottom=rect.bottom;
  • SendMessage(hTTip,TTM_ADDTOOL,0,(LPARAM)&ti);
  • }
  • SetFocus(edit);
  • if (!hwnd) return FALSE;
  • ShowWindow(hwnd,nCmdShow);
  • while (GetMessage(&msg,NULL,0,0)) {
  • TranslateMessage(&msg);
  • DispatchMessage(&msg);
  • }
  • return msg.wParam;
  • }
  • //Traitement des messages Client-Machine
  • LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  • switch (uMsg) {
  • case WM_CONTEXTMENU:
  • HMENU hmenu,hpopup;
  • hmenu=LoadMenu(hinst,"LEMENU");
  • hpopup=GetSubMenu(hmenu,0);
  • TrackPopupMenuEx(hpopup,0,LOWORD(lParam),HIWORD(lParam),hwnd,NULL);
  • DestroyMenu(hmenu);
  • break;
  • case WM_COMMAND:
  • switch (LOWORD(wParam)) {
  • case 111:
  • DialogBox(hinst,"Coefficients",hwnd,(DLGPROC)ProcCoefficients);
  • break;
  • case 112:
  • DestroyWindow(hwnd);
  • break;
  • case ID_BAC:
  • DialogBox(hinst,"Coefficients",hwnd,(DLGPROC)ProcCoefficients);
  • break;
  • case ID_COEFFAUTRE:
  • DialogBox(hinst,"DIALOG1",hwnd,(DLGPROC)Dialog1Proc1);
  • break;
  • case ID_GOBACK:
  • RECT area;
  • GetWindowRect(hwnd,&area);
  • int width=area.right-area.left;
  • if (width == 320) {
  • SetWindowPos(hwnd,0,area.left,area.top,800,350,0);
  • SetWindowText(goback,"<");
  • }
  • else {
  • SetWindowPos(hwnd,0,area.left,area.top,320,275,0);
  • SetWindowText(goback,">");
  • }
  • break;
  • case ID_COMBO:
  • nbritem=SendMessage(list,LB_GETCOUNT,0,0);
  • if (nbritem > 0) Refresh();
  • break;
  • case ID_ANNULER:
  • nbritem=SendMessage(list,LB_GETCOUNT,0,0)-1;
  • SendMessage(list,LB_DELETESTRING,nbritem,0);
  • Refresh();
  • break;
  • case ID_RECOMMENCER:
  • if (MessageBox(hwnd,"Etes-vous sûr(e) de vouloir annuler tous les calculs en cours ?\t\n",
  • "Avertissement",MB_ICONQUESTION|MB_OKCANCEL) == IDOK) {
  • while (SendMessage(list,LB_GETCOUNT,0,0)*2)
  • SendMessage(list,LB_DELETESTRING,0,0);
  • SetWindowText(edit,"");
  • SendMessage(combo,CB_SELECTSTRING,0,(LPARAM)"Moyenne (avec coefficients)");
  • CheckDlgButton(hwnd,ID_COEFF05,BST_UNCHECKED);
  • CheckDlgButton(hwnd,ID_COEFF2,BST_UNCHECKED);
  • CheckDlgButton(hwnd,ID_COEFFAUTRE,BST_UNCHECKED);
  • CheckDlgButton(hwnd,ID_COEFF1,BST_CHECKED);
  • SetWindowText(coeffautre,"autre...");
  • EnableWindow(recommencer,FALSE);
  • Refresh();
  • }
  • break;
  • case ID_CHECK:
  • Refresh();
  • InvalidateRect(hwnd,NULL,FALSE);
  • UpdateWindow(hwnd);
  • break;
  • case ID_OK:
  • {
  • char text[10];
  • GetWindowText(edit,text,10);
  • int text2=atoi(text);
  • for(int a=1;a <= 20;a++) {
  • if (text2 == a) {
  • int b=7;
  • while (b<=10) {
  • if (IsDlgButtonChecked(hwnd,b)) {
  • char textcoeff[5];
  • double verif=1.5;
  • GetWindowText(GetDlgItem(hwnd,b),textcoeff,10);
  • if (strchr(textcoeff,'a') != NULL) {
  • sscanf(textcoeff,"autre: %lf",&verif);
  • sprintf(textcoeff,"%lf",verif);
  • }
  • char par[10]="";
  • sprintf(par,"%s (%s)",text,textcoeff);
  • SendMessage(list,LB_ADDSTRING,0,(LPARAM)par);
  • EnableWindow(annuler,TRUE);
  • EnableWindow(recommencer,TRUE);
  • Refresh();
  • break;
  • }
  • b++;
  • }
  • }
  • }
  • break;
  • }
  • case ID_CHARGER:
  • while (SendMessage(list,LB_GETCOUNT,0,0)*2)
  • SendMessage(list,LB_DELETESTRING,0,0);
  • SetWindowText(edit,"");
  • SendMessage(combo,CB_SELECTSTRING,0,(LPARAM)"Moyenne (avec coefficients)");
  • CheckDlgButton(hwnd,ID_COEFF05,BST_UNCHECKED);
  • CheckDlgButton(hwnd,ID_COEFF2,BST_UNCHECKED);
  • CheckDlgButton(hwnd,ID_COEFFAUTRE,BST_UNCHECKED);
  • CheckDlgButton(hwnd,ID_COEFF1,BST_CHECKED);
  • SetWindowText(coeffautre,"autre...");
  • EnableWindow(recommencer,FALSE);
  • OPENFILENAME ofn;
  • ZeroMemory(&ofn,sizeof(OPENFILENAME));
  • ofn.lStructSize=sizeof(OPENFILENAME);
  • ofn.hwndOwner=hwnd;
  • ofn.lpstrFile=szFile;
  • ofn.nMaxFile=MAX_PATH;
  • ofn.lpstrFilter="Fichier Moyenne (*.moy)\0*.moy\0";
  • ofn.nFilterIndex=1;
  • ofn.lpstrTitle="Ouvrir un fichier Moyenne...";
  • ofn.Flags=OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
  • if (GetOpenFileName(&ofn) == TRUE) {
  • DWORD lenbloc,s;
  • char *tampon;
  • fo=CreateFile(szFile,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
  • lenbloc=GetFileSize(fo,NULL);
  • tampon=(PCHAR)LocalAlloc(LMEM_FIXED,lenbloc+1);
  • ReadFile(fo,tampon,lenbloc,&s,NULL);
  • tampon[lenbloc]=0;
  • int i=0,p=0;
  • for(i=0;tampon[i] != '\0';i++) {
  • if (tampon[i] == '\r') {
  • for(p=i;tampon[p]!= '\0';p++)
  • tampon[p]=tampon[p+1];
  • }
  • }
  • char* token=strtok(tampon,"\n");
  • while (token != NULL) {
  • SendMessage(list,LB_ADDSTRING,0,(LPARAM)token);
  • token=strtok(NULL,"\n");
  • }
  • LocalFree(tampon);
  • CloseHandle(fo);
  • Refresh();
  • }
  • break;
  • case ID_ENREGISTRER:
  • DialogBox(hinst,"DIALOG2",hwnd,(DLGPROC)Dialog1Proc2);
  • break;
  • case ID_IMPRIMER:
  • if (HwndToBmpFile(hwnd,"Moyennes/Graphique.bmp")) {
  • PostMessage(hwnd,WM_NEXTDLGCTL,0,0);
  • if (MessageBox(hwnd,"L'impression écran s'est effectuée avec succès !\t\n"
  • "L'image a été enregistrée dans le dossier /Moyennes/\t\n"
  • "sous le nom de 'Graphique.bmp'.\t\n\n"
  • "Souhaitez-vous ouvrire l'image maintenant ?\t\n",
  • "Information",MB_ICONINFORMATION|MB_OKCANCEL) != IDCANCEL)
  • ShellExecute(hwnd,"open","Graphique.bmp",NULL,"Moyennes",SW_SHOW);
  • }
  • else
  • MessageBox(hwnd,"Veuillez recommencer.","Erreur",MB_OK);
  • break;
  • case ID_ABOUT:
  • MessageBox(hwnd,"- Moyennes -\nLogiciel pour calculer ses moyennes\t\n(copyrights © WINKEL Vincent)\t\n",
  • "A propos...",MB_OK|MB_ICONASTERISK);
  • break;
  • }
  • case WM_PAINT:
  • Draw(calcul);
  • break;
  • case WM_DESTROY:
  • PostQuitMessage(0);
  • break;
  • default:
  • return DefWindowProc(hwnd,uMsg,wParam,lParam);
  • }
  • }
  • //Aliases de raccourci (traitement du graphique)
  • void Refresh() {
  • nbritem=SendMessage(list,LB_GETCOUNT,0,0);
  • if (nbritem > 0) {
  • char textitem[100];
  • GetWindowText(combo,textitem,100);
  • char item1[]="Moyenne (avec coefficients)";
  • char item2[]="Moyenne (sans coefficients)";
  • char item3[]="Nombre de notes >= 10";
  • char item4[]="Nombre de notes < 10";
  • char item5[]="Etendue (différence max - min)";
  • char item6[]="Médiane (avec coefficients)";
  • char item7[]="Médiane (sans coefficients)";
  • int a=0;
  • double nbr=0,nbr2=0,note=0,coeff=0;
  • char text[20],texttitle[200];
  • if (strcmp(textitem,item1) == 0) {
  • for(a=0;a < nbritem;a++) {
  • SendMessage(list,LB_GETTEXT,a,(LPARAM)text);
  • sscanf(text,"%lf (%lf)",&note,&coeff);
  • nbr+=note*coeff;
  • nbr2+=coeff;
  • }
  • afficheMoy=nbr/nbr2;
  • sprintf(texttitle,"Moyenne (avec coefficients): %.2f",afficheMoy);
  • SetWindowText(box,texttitle);
  • SetWindowText(hwnd,texttitle);
  • calcul=1;
  • }
  • else if (strcmp(textitem,item2) == 0) {
  • for(a=0;a < nbritem;a++) {
  • SendMessage(list,LB_GETTEXT,a,(LPARAM)text);
  • sscanf(text,"%lf (%lf)",&note,&coeff);
  • nbr+=note;
  • }
  • afficheMoy=nbr/nbritem;
  • sprintf(texttitle,"Moyenne (sans coefficients): %.2f",afficheMoy);
  • SetWindowText(box,texttitle);
  • SetWindowText(hwnd,texttitle);
  • calcul=1;
  • }
  • if (strcmp(textitem,item3) == 0) {
  • for(a=0;a < nbritem;a++) {
  • SendMessage(list,LB_GETTEXT,a,(LPARAM)text);
  • sscanf(text,"%lf (%lf)",&note,&coeff);
  • if (note >= 10) nbr++;
  • nbr2++;
  • }
  • coeff=(nbr*100)/nbr2;
  • sprintf(texttitle,"Notes >= 10: %.0f/%.0f (%.1f %%)",nbr,nbr2,coeff);
  • SetWindowText(box,texttitle);
  • SetWindowText(hwnd,texttitle);
  • calcul=0;
  • }
  • else if (strcmp(textitem,item4) == 0) {
  • for(a=0;a < nbritem;a++) {
  • SendMessage(list,LB_GETTEXT,a,(LPARAM)text);
  • sscanf(text,"%lf (%lf)",&note,&coeff);
  • if (note < 10) nbr++;
  • nbr2++;
  • }
  • coeff=(nbr*100)/nbr2;
  • sprintf(texttitle,"Notes < 10: %.0f/%.0f (%.1f %%)",nbr,nbr2,coeff);
  • SetWindowText(box,texttitle);
  • SetWindowText(hwnd,texttitle);
  • calcul=0;
  • }
  • else if (strcmp(textitem,item5) == 0) {
  • if (nbritem < 2) {
  • SetWindowText(box,"2 valeurs minimum sont requises");
  • SetWindowText(hwnd,"2 valeurs minimum sont requises");
  • }
  • else {
  • nbr=0,nbr2=20;
  • for(a=0; a < nbritem;a++) {
  • SendMessage(list,LB_GETTEXT,a,(LPARAM)text);
  • sscanf(text,"%lf (%lf)",&note,&coeff);
  • if (note > nbr) nbr=note;
  • else if (note < nbr2) nbr2=note;
  • }
  • nbr-=nbr2;
  • sprintf(texttitle,"Etendue des notes: %.2f",nbr);
  • SetWindowText(box,texttitle);
  • SetWindowText(hwnd,texttitle);
  • calcul=0;
  • }
  • }
  • else if (strcmp(textitem,item6) == 0) {
  • for(a=0;a < nbritem;a++) {
  • SendMessage(list,LB_GETTEXT,a,(LPARAM)text);
  • sscanf(text,"%lf (%lf)",&note,&coeff);
  • nbr+=coeff;
  • }
  • nbr/=2;
  • SendMessage(list,LB_GETTEXT,nbr,(LPARAM)text);
  • sscanf(text,"%lf (%lf)",&note,&coeff);
  • sprintf(texttitle,"Médiane (avec coefficients): %.2f",note);
  • SetWindowText(box,texttitle);
  • SetWindowText(hwnd,texttitle);
  • calcul=0;
  • }
  • else if (strcmp(textitem,item7) == 0) {
  • }
  • }
  • else {
  • SetWindowText(box,"Aucune valeur");
  • SetWindowText(hwnd,"Aucune valeur");
  • }
  • Draw(calcul);
  • InvalidateRect(hwnd,NULL,FALSE);
  • UpdateWindow(hwnd);
  • }
  • void Draw(BOOL calcul) {
  • PAINTSTRUCT ps;
  • HDC hdc=BeginPaint(hwnd,&ps);
  • HPEN hp2px,hpOld;
  • HBRUSH brush;
  • HFONT NewFont,OldFont;
  • LOGFONT lf;
  • ZeroMemory(&lf,sizeof(LOGFONT));
  • lstrcpy(lf.lfFaceName,"Arial");
  • lf.lfHeight=12;
  • NewFont=CreateFontIndirect(&lf);
  • OldFont=(HFONT)SelectObject(hdc,NewFont);
  • //Initialisation du graphique
  • /*if (calcul == FALSE) {
  • brush=CreateSolidBrush(RGB(220,220,220));
  • hpOld=(HPEN)SelectObject(hdc,brush);
  • }*/
  • Rectangle(hdc,330,10,780,300);
  • MoveToEx(hdc,360,20,NULL);
  • LineTo(hdc,360,270);
  • MoveToEx(hdc,350,260,NULL);
  • LineTo(hdc,745,260);
  • //Ajout des graduations
  • int a=20,b=360,d=20;
  • char c[3];
  • for(a=20;a <= 250;a+=12) {
  • sprintf(c,"%d",d);
  • MoveToEx(hdc,358,a,NULL);
  • LineTo(hdc,360,a);
  • int l=strlen(c);
  • if (l == 2) TextOut(hdc,345,a-5,c,lstrlen(c));
  • else TextOut(hdc,350,a-5,c,lstrlen(c));
  • d--;
  • }
  • for(b=360;b <= 750;b+=12) {
  • MoveToEx(hdc,b,261,NULL);
  • LineTo(hdc,b,263);
  • }
  • //Ajout de texte
  • sprintf(nbritem2,"%d",nbritem);
  • char e[]="Total des notes: ";
  • char e2[]=" / 32";
  • strcat(e,nbritem2);
  • strcat(e,e2);
  • lf.lfHeight=15;
  • NewFont=CreateFontIndirect(&lf);
  • OldFont=(HFONT)SelectObject(hdc,NewFont);
  • TextOut(hdc,480,275,e,lstrlen(e));
  • //Traçage du graphique
  • hp2px=CreatePen(PS_SOLID,1,RGB(150,150,250));
  • hpOld=(HPEN)SelectObject(hdc,hp2px);
  • a=0,b=362;
  • char text[20];
  • for(a=0;a <= nbritem-1;a++) {
  • if (a > 31) break;
  • SendMessage(list,LB_GETTEXT,a,(LPARAM)text);
  • float nbr=atof(text);
  • SelectObject(hdc,GetStockObject(LTGRAY_BRUSH));
  • Rectangle(hdc,b,ceil(260-12*nbr),b+9,260);
  • b+=12;
  • }
  • //Affichage (ou non) de la grille
  • if (IsDlgButtonChecked(hwnd,ID_CHECK)) {
  • hp2px=CreatePen(PS_SOLID,1,RGB(200,200,200));
  • hpOld=(HPEN)SelectObject(hdc,hp2px);
  • int a=20,b=372;
  • for(a=20;a<=250;a+=12) {
  • MoveToEx(hdc,361,a,NULL);
  • LineTo(hdc,745,a);
  • }
  • for(b=372;b<=750;b+=12) {
  • MoveToEx(hdc,b,20,NULL);
  • LineTo(hdc,b,260);
  • }
  • }
  • //Affichage de la moyenne
  • if (nbritem > 0) {
  • hp2px=CreatePen(PS_SOLID,1,RGB(50,150,170));
  • hpOld=(HPEN)SelectObject(hdc,hp2px);
  • float nbr=260-12*afficheMoy;
  • MoveToEx(hdc,360,nbr,NULL);
  • LineTo(hdc,745,nbr);
  • lf.lfHeight=13;
  • NewFont=CreateFontIndirect(&lf);
  • OldFont=(HFONT)SelectObject(hdc,NewFont);
  • TextOut(hdc,700,nbr-13,"Moyenne",7);
  • }
  • //Annonce de l'état du traitement du graphique
  • if (calcul == FALSE) {
  • hp2px=CreatePen(PS_SOLID,1,RGB(100,100,100));
  • hpOld=(HPEN)SelectObject(hdc,hp2px);
  • lf.lfHeight=40;
  • NewFont=CreateFontIndirect(&lf);
  • OldFont=(HFONT)SelectObject(hdc,NewFont);
  • BeginPath(hdc);
  • TextOut(hdc,400,100," Graphique non-traité ",22);
  • EndPath(hdc);
  • StrokePath(hdc);
  • }
  • DeleteObject(NewFont);
  • EndPaint(hwnd,&ps);
  • }
  • //Autre choix d'un coefficiant
  • BOOL APIENTRY Dialog1Proc1(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) {
  • switch (uMsg) {
  • case WM_COMMAND:
  • if (LOWORD(wParam) == 2) {
  • CheckDlgButton(hwnd,ID_COEFF1,BST_CHECKED);
  • CheckDlgButton(hwnd,ID_COEFFAUTRE,BST_UNCHECKED);
  • EndDialog(hDlg,0);
  • }
  • else if (LOWORD(wParam) == 1) {
  • char textedit[100]="";
  • GetDlgItemText(hDlg,3,textedit,100);
  • int verif=atoi(textedit);
  • if (verif <= 0 || verif > 99) {
  • MessageBox(hwnd,"Le coefficient doit être un nombre.\t\n"
  • " (compris entre 1 et 99)\t\n","Erreur de syntaxe",MB_OK|MB_ICONERROR);
  • SetFocus(GetDlgItem(hDlg,3));
  • }
  • else {
  • char textedit2[]="autre: ";
  • strcat(textedit2,textedit);
  • SetWindowText(coeffautre,textedit2);
  • EndDialog(hDlg,0);
  • return TRUE;
  • }
  • return FALSE;
  • }
  • break;
  • default:
  • return FALSE;
  • }
  • }
  • //Demande de nom de fichier
  • BOOL APIENTRY Dialog1Proc2(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) {
  • switch (uMsg) {
  • case WM_COMMAND:
  • if (LOWORD(wParam) == 2)
  • EndDialog(hDlg,0);
  • else if (LOWORD(wParam) == 1) {
  • //Vérification de l'existence du dossier /Moyennes/
  • HANDLE hDir=CreateFile("Moyennes",FILE_LIST_DIRECTORY,FILE_SHARE_READ|FILE_SHARE_DELETE,NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,NULL);
  • if (hDir == INVALID_HANDLE_VALUE)
  • CreateDirectory("Moyennes",NULL);
  • else
  • CloseHandle(hDir);
  • //Procédure
  • int a=0,lenbloc=0,total=0;
  • total=SendMessage(list,LB_GETCOUNT,0,0);
  • char text[99]="",item[20]="",fichier[99]="Moyennes/";
  • GetDlgItemText(hDlg,3,text,50);
  • if (total <= 0) {
  • MessageBox(GetActiveWindow(),"Aucune moyenne n'a été ajoutée.\t\n","Erreur",MB_ICONERROR|MB_OK);
  • EndDialog(hDlg,0);
  • return FALSE;
  • }
  • else if (strcmp(text,"") == 0) {
  • MessageBox(GetActiveWindow(),"Il faut choisir un nom de fichier.\t\n","Erreur",MB_ICONERROR|MB_OK);
  • return FALSE;
  • }
  • strcat(fichier,text);
  • strcat(fichier,".moy");
  • FILE* file=fopen(fichier,"w");
  • for(a=0;a < total;a++) {
  • SendMessage(list,LB_GETTEXT,a,(LPARAM)item);
  • MessageBox(hwnd,item,"ok",MB_OK);
  • fprintf(file,"%s\n",item);
  • }
  • fclose(file);
  • EndDialog(hDlg,0);
  • return TRUE;
  • }
  • break;
  • default:
  • return FALSE;
  • }
  • }
  • //Tableau des coefficients
  • BOOL APIENTRY ProcCoefficients(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) {
  • switch (uMsg) {
  • case WM_CLOSE:
  • EndDialog(hDlg,0);
  • break;
  • case WM_CTLCOLORSTATIC:
  • return((BOOL)ColorStatic(hDlg,wParam,lParam));
  • case WM_INITDIALOG:
  • {
  • MessageBox(hDlg,"Les renseignements fournis ci-après ont été trouvés sur Internet.\t\n"
  • "Malgré les nombreuses recherches, il se peut qu'un (ou plusieurs) coefficient(s)\t\n"
  • "soi(en)t erroné(s). N'hésitez pas à contacter l'auteur (winkel@live.fr).\t\n","Avertissemen",
  • MB_ICONINFORMATION|MB_OK);
  • ShowWindow(GetDlgItem(hDlg,1),SW_HIDE);
  • char** tab=split(Matieres,";",0);
  • int nbr;
  • for(nbr=0;tab[nbr] != NULL;nbr++) {}
  • for(int a=0;a < nbr;a++)
  • SendMessage(GetDlgItem(hDlg,2),LB_ADDSTRING,0,(LPARAM)tab[a]);
  • free(tab);
  • InitListView(hDlg);
  • break;
  • }
  • case WM_COMMAND:
  • if (LOWORD(wParam) == 2) {
  • int num=SendMessage(GetDlgItem(hDlg,2),LB_GETCURSEL,0,0);
  • char item[30];
  • SendMessage(GetDlgItem(hDlg,2),LB_GETTEXT,num,(LPARAM)item);
  • if (strcmp(item," &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; ") == 0)
  • SendMessage(GetDlgItem(hDlg,3),LVM_DELETEALLITEMS,0,0);
  • else if (strcmp(item,"L - Langue vivante 1") == 0)
  • SelectItem(hDlg,0);
  • else if (strcmp(item,"L - Langue vivante 2") == 0)
  • SelectItem(hDlg,1);
  • else if (strcmp(item,"L - Mathématiques") == 0)
  • SelectItem(hDlg,2);
  • else if (strcmp(item,"S - S.I") == 0)
  • SelectItem(hDlg,3);
  • else if (strcmp(item,"&#8212; S.V.T") == 0)
  • SelectItem(hDlg,4);
  • else if (strcmp(item,"&#8212; Mathématiques") == 0)
  • SelectItem(hDlg,5);
  • else if (strcmp(item,"&#8212; Physique/Chimie") == 0)
  • SelectItem(hDlg,6);
  • else if (strcmp(item,"S.E.S - Langues viv.") == 0)
  • SelectItem(hDlg,7);
  • else if (strcmp(item,"S.E.S - Maths") == 0)
  • SelectItem(hDlg,8);
  • else if (strcmp(item,"S.E.S - S.E.S") == 0)
  • SelectItem(hDlg,9);
  • if (strcmp(item,"S - S.V.T :") == 0) {
  • popup=1;
  • RECT rct;
  • GetClientRect(hDlg,&rct);
  • int cX=rct.right+1;
  • int cY=rct.bottom-20;
  • MoveWindow(GetDlgItem(hDlg,2),15,65,105,cY-81,TRUE);
  • MoveWindow(GetDlgItem(hDlg,3),122,65,cX-142,cY-81,TRUE);
  • ShowWindow(GetDlgItem(hDlg,1),SW_SHOW);
  • }
  • else {
  • popup=0;
  • RECT rct;
  • GetClientRect(hDlg,&rct);
  • int cX=rct.right+1;
  • int cY=rct.bottom;
  • MoveWindow(GetDlgItem(hDlg,2),15,65,105,cY-81,TRUE);
  • MoveWindow(GetDlgItem(hDlg,3),122,65,cX-142,cY-81,TRUE);
  • ShowWindow(GetDlgItem(hDlg,1),SW_HIDE);
  • }
  • }
  • break;
  • case WM_SIZE:
  • int cX=LOWORD(lParam)+1;
  • int cY=HIWORD(lParam);
  • int cH=(popup)?20:0;
  • MoveWindow(GetDlgItem(hDlg,1),15,cY-24,400,cY-10,TRUE);
  • MoveWindow(GetDlgItem(hDlg,2),15,65,105,cY-81-cH,TRUE);
  • MoveWindow(GetDlgItem(hDlg,3),122,65,cX-142,cY-81-cH,TRUE);
  • break;
  • case WM_SIZING:
  • RECT* wndRect=(RECT*)lParam;
  • int cXp=wndRect->right-wndRect->left;
  • int cYp=wndRect->bottom-wndRect->top;
  • if (cXp < 440) wndRect->right = 440+wndRect->left;
  • if (cYp < 320) wndRect->bottom = 320+wndRect->top;
  • break;
  • default:
  • return FALSE;
  • }
  • }
  • //Enregistrement du graphe
  • int __stdcall HwndToBmpFile(HWND hwnd,char* pszflname) {
  • HDC memdc,hdc;
  • HANDLE hfl;
  • DWORD dwBytes,dwNumColors;
  • void* pBits;
  • HBITMAP hbmp;
  • BITMAPFILEHEADER fileheader;
  • BITMAPINFOHEADER infoheader;
  • RGBQUAD colors[256];
  • BITMAPINFO bmpinfo;
  • HGDIOBJ hret;
  • RECT rct;
  • hdc=GetWindowDC(hwnd);
  • if(!hdc)
  • return 0;
  • GetWindowRect(hwnd,&rct);
  • rct.bottom-=rct.top;
  • rct.right-=rct.left;
  • rct.top=GetDeviceCaps(hdc,BITSPIXEL);
  • if (rct.top <= 8)
  • dwNumColors=256;
  • else
  • dwNumColors=0;
  • if (!(memdc=CreateCompatibleDC(hdc)))
  • goto relHwndDc;
  • bmpinfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
  • bmpinfo.bmiHeader.biWidth=rct.right;
  • bmpinfo.bmiHeader.biHeight=rct.bottom;
  • bmpinfo.bmiHeader.biPlanes=1;
  • bmpinfo.bmiHeader.biBitCount=(WORD)rct.top;
  • bmpinfo.bmiHeader.biCompression=BI_RGB;
  • bmpinfo.bmiHeader.biSizeImage=0;
  • bmpinfo.bmiHeader.biXPelsPerMeter=0;
  • bmpinfo.bmiHeader.biYPelsPerMeter=0;
  • bmpinfo.bmiHeader.biClrUsed=dwNumColors;
  • bmpinfo.bmiHeader.biClrImportant=dwNumColors;
  • hbmp=CreateDIBSection(hdc,&bmpinfo,DIB_PAL_COLORS,&pBits,NULL,0);
  • if (!hbmp)
  • goto errato;
  • hret=SelectObject(memdc,hbmp);
  • if ((!hret) || (hret == HGDI_ERROR))
  • goto errato;
  • if (!BitBlt(memdc,0,0,rct.right,rct.bottom,hdc,0,0,SRCCOPY))
  • goto errato;
  • if (dwNumColors)
  • dwNumColors=GetDIBColorTable(memdc,0,dwNumColors,colors);
  • fileheader.bfType=0x4D42;
  • rct.left=dwNumColors*sizeof(RGBQUAD);
  • fileheader.bfSize=((rct.right*rct.bottom*rct.top) >> 3)+rct.left+sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
  • fileheader.bfReserved1=fileheader.bfReserved2=0;
  • fileheader.bfOffBits=rct.left+sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
  • infoheader.biSize=sizeof(BITMAPINFOHEADER);
  • infoheader.biWidth=rct.right;
  • infoheader.biHeight=rct.bottom;
  • infoheader.biPlanes=1;
  • infoheader.biBitCount=(WORD)rct.top;
  • infoheader.biCompression=BI_RGB;
  • infoheader.biSizeImage=infoheader.biClrImportant=0;
  • infoheader.biXPelsPerMeter=infoheader.biYPelsPerMeter=0;
  • infoheader.biClrUsed=dwNumColors;
  • hfl=CreateFile(pszflname,GENERIC_WRITE,0,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
  • if (hfl == INVALID_HANDLE_VALUE) {
  • DeleteObject(hbmp);
  • goto errato;
  • }
  • WriteFile(hfl,&fileheader,sizeof(BITMAPFILEHEADER),&dwBytes,0);
  • WriteFile(hfl,&infoheader,sizeof(BITMAPINFOHEADER),&dwBytes,0);
  • if(!dwNumColors)
  • WriteFile(hfl,colors,rct.left,&dwBytes,0);
  • WriteFile(hfl,pBits,(rct.right*rct.bottom*rct.top) >> 3,&dwBytes, 0);
  • CloseHandle(hfl);
  • DeleteObject(hbmp);
  • DeleteDC(memdc);
  • return 1;
  • errato:
  • DeleteDC(memdc);
  • relHwndDc:
  • ReleaseDC(hwnd,hdc);
  • return 0;
  • }
  • static HBRUSH ColorStatic(HWND hDlg,WPARAM wParam,LPARAM lParam) {
  • if((HWND)lParam == GetDlgItem(hDlg,10)) {
  • SetBkMode((HDC)wParam,TRANSPARENT);
  • SetBkColor((HDC)wParam,GetSysColor(COLOR_INFOBK));
  • SetTextColor((HDC)wParam,GetSysColor(COLOR_INFOTEXT));
  • return GetSysColorBrush(COLOR_INFOBK);
  • }
  • else {
  • SetBkMode((HDC)wParam,TRANSPARENT);
  • SetBkColor((HDC)wParam,(COLORREF)GetSysColor(COLOR_3DFACE));
  • SetTextColor((HDC)wParam,RGB(60,60,60));
  • return GetSysColorBrush(COLOR_3DFACE);
  • }
  • }
#include <windows.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <richedit.h>
#include <commctrl.h>
#include "define.h"

//Variables globales et prototypes
HINSTANCE hinst;
void Refresh();
void Draw(BOOL calcul);
int __stdcall HwndToBmpFile(HWND hwnd,char *pszflname);
LRESULT CALLBACK MainWndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
BOOL APIENTRY Dialog1Proc1(HWND,UINT,WPARAM,LPARAM);
BOOL APIENTRY Dialog1Proc2(HWND,UINT,WPARAM,LPARAM);
BOOL APIENTRY ProcCoefficients(HWND,UINT,WPARAM,LPARAM);
static HBRUSH ColorStatic(HWND,WPARAM,LPARAM);
int nbritem=0;
char nbritem2[100];
float afficheMoy=0;
int calcul=1;
int popup=0;
HANDLE fo,fp;
CHAR szFile[MAX_PATH]={0};
HWND hwnd,texte,ok,edit,annuler,recommencer,texte_background,list,combo,background,box,box2,goback,enregistrer,imprimer,
        check,coeff05,coeff1,coeff2,coeffautre,coeff,note,about,charger,coeffBAC,hTTip;
//Déclaration de la fenêtre
int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) {
    //Variables
    MSG msg;
    hinst=hinstance;
    //Paramètres de la fenêtre
    WNDCLASS wc;
    wc.style=0;
    wc.lpfnWndProc=MainWndProc;
    wc.cbClsExtra=0;
    wc.cbWndExtra=0;
    wc.hInstance=hinstance;
    wc.hIcon=LoadIcon(hinstance,MAKEINTRESOURCE(1));
    wc.hCursor=LoadCursor(NULL,IDC_ARROW);
    wc.hbrBackground=(HBRUSH)(COLOR_3DFACE+1);
    wc.lpszMenuName= NULL;
    wc.lpszClassName="MaWinClass";
    if(!RegisterClass(&wc)) return FALSE;
    //Création de la fenêtre
    int cxS=GetSystemMetrics(SM_CXSCREEN);
    int cyS=GetSystemMetrics(SM_CYSCREEN);
    hwnd=CreateWindowEx(WS_EX_WINDOWEDGE,"MaWinClass","Aucune valeur",WS_CAPTION|WS_MINIMIZEBOX|WS_SYSMENU,(cxS-700)/2,(cyS-275)/2,320,275,HWND_DESKTOP,NULL,hinstance,NULL);
    //Mise en place des contrôles
    box=CreateWindowEx(0,"BUTTON","Aucune valeur",SS_LEFT|WS_CHILD|WS_VISIBLE|BS_GROUPBOX,10,10,280,225,hwnd,(HMENU)ID_BOX,hinstance,NULL);
    SendMessage(box,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    box2=CreateWindowEx(0,"BUTTON","Propriétés :",SS_LEFT|WS_CHILD|WS_VISIBLE|BS_GROUPBOX,90,242,200,58,hwnd,(HMENU)ID_BOX2,hinstance,NULL);
    SendMessage(box2,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    edit=CreateWindowEx(WS_EX_STATICEDGE|WS_EX_CLIENTEDGE,"EDIT","12.5",WS_CHILD|WS_VISIBLE|WS_EX_CLIENTEDGE|WS_EX_STATICEDGE,110,40,55,20,hwnd,(HMENU)ID_EDIT,hinstance,NULL);
    SendMessage(edit,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    texte_background=CreateWindowEx(WS_EX_STATICEDGE,"STATIC","",SS_LEFT|WS_CHILD|WS_VISIBLE,110,150,170,74,hwnd,(HMENU)ID_TEXTE_BACKGROUND,hinstance,NULL);
    SendMessage(texte_background,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    texte=CreateWindowEx(0,"STATIC","Astuce : Pensez à ramener vos notes sur 20 afin que les coefficients (s'ils sont activés) soient proportionnels.",WS_CHILD|WS_VISIBLE,120,160,150,60,hwnd,(HMENU)ID_TEXTE,hinstance,NULL);
    SendMessage(texte,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    ok=CreateWindowEx(0,"BUTTON","OK",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE,170,40,30,20,hwnd,(HMENU)ID_OK,hinstance,NULL);
    SendMessage(ok,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    annuler=CreateWindowEx(0,"BUTTON","Annuler",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE|WS_DISABLED,110,70,90,20,hwnd,(HMENU)ID_ANNULER,hinstance,NULL);
    SendMessage(annuler,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    recommencer=CreateWindowEx(0,"BUTTON","Recommencer",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE|WS_DISABLED,110,90,90,20,hwnd,(HMENU)ID_RECOMMENCER,hinstance,NULL);
    SendMessage(recommencer,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    list=CreateWindowEx(WS_EX_STATICEDGE,"LISTBOX",NULL,WS_CHILD|WS_VISIBLE|WS_VSCROLL,20,40,80,200,hwnd,(HMENU)ID_LIST,hinstance,NULL);
    SendMessage(list,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    combo=CreateWindowEx(0,"COMBOBOX",NULL,WS_CHILD|WS_VISIBLE|CBS_DROPDOWNLIST,110,120,170,0,hwnd,(HMENU)ID_COMBO,hinstance,NULL);
    SendMessage(combo,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    goback=CreateWindowEx(WS_EX_STATICEDGE,"BUTTON",">",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE,295,35,15,40,hwnd,(HMENU)ID_GOBACK,hinstance,NULL);
    SendMessage(goback,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    enregistrer=CreateWindowEx(0,"BUTTON","Enregistrer",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE,95,255,90,20,hwnd,(HMENU)ID_ENREGISTRER,hinstance,NULL);
    SendMessage(enregistrer,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    imprimer=CreateWindowEx(0,"BUTTON","Impression Ecran",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE,195,255,90,20,hwnd,(HMENU)ID_IMPRIMER,hinstance,NULL);
    SendMessage(imprimer,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    charger=CreateWindowEx(0,"BUTTON","Charger...",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE,95,275,90,20,hwnd,(HMENU)ID_CHARGER,hinstance,NULL);
    SendMessage(charger,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    check=CreateWindowEx(0,"BUTTON","Afficher la grille",WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX,195,275,89,20,hwnd,(HMENU)ID_CHECK,hinstance,NULL);
    SendMessage(check,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    background=CreateWindowEx(WS_EX_STATICEDGE,"STATIC",NULL,SS_LEFT|WS_CHILD|WS_VISIBLE,205,40,75,70,hwnd,(HMENU)ID_BACKGROUND,hinstance,NULL);
    SendMessage(background,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    coeff05=CreateWindowEx(0,"BUTTON","0.5",WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON,210,44,69,17,hwnd,(HMENU)ID_COEFF05,hinstance,NULL);
    SendMessage(coeff05,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    coeff1=CreateWindowEx(0,"BUTTON","1",WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON,210,59,69,17,hwnd,(HMENU)ID_COEFF1,hinstance,NULL);
    SendMessage(coeff1,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    coeff2=CreateWindowEx(0,"BUTTON","2",WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON,210,74,69,17,hwnd,(HMENU)ID_COEFF2,hinstance,NULL);
    SendMessage(coeff2,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    coeffautre=CreateWindowEx(0,"BUTTON","autre...",WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON,210,89,69,17,hwnd,(HMENU)ID_COEFFAUTRE,hinstance,NULL);
    SendMessage(coeffautre,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    note=CreateWindowEx(0,"STATIC","Note :",WS_CHILD|WS_VISIBLE,110,25,50,14,hwnd,(HMENU)ID_NOTE,hinstance,NULL);
    SendMessage(note,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    coeff=CreateWindowEx(0,"STATIC","Coefficient :",WS_CHILD|WS_VISIBLE,205,25,60,14,hwnd,(HMENU)ID_COEFF,hinstance,NULL);
    SendMessage(coeff,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    note=CreateWindowEx(0,"STATIC","Note (coefficient)",WS_CHILD|WS_VISIBLE,20,25,90,14,hwnd,(HMENU)ID_EXEMPLE,hinstance,NULL);
    SendMessage(note,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    about=CreateWindowEx(WS_EX_STATICEDGE,"BUTTON","A propos...",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE,10,274,70,22,hwnd,(HMENU)ID_ABOUT,hinstance,NULL);
    SendMessage(about,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    coeffBAC=CreateWindowEx(0,"BUTTON","Coeffs BAC",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE,10,255,70,20,hwnd,(HMENU)ID_BAC,hinstance,NULL);
    SendMessage(coeffBAC,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(TRUE,0));
    SendMessage(combo,CB_ADDSTRING,0,(LPARAM)"Moyenne (avec coefficients)");
    SendMessage(combo,CB_ADDSTRING,0,(LPARAM)"Moyenne (sans coefficients)");
    SendMessage(combo,CB_ADDSTRING,0,(LPARAM)"Nombre de notes >= 10");
    SendMessage(combo,CB_ADDSTRING,0,(LPARAM)"Nombre de notes < 10");
    SendMessage(combo,CB_ADDSTRING,0,(LPARAM)"Etendue (différence max - min)");
    SendMessage(combo,CB_ADDSTRING,0,(LPARAM)"Médiane (avec coefficients)");
    SendMessage(combo,CB_ADDSTRING,0,(LPARAM)"Médiane (sans coefficients)");
    SendMessage(combo,CB_SELECTSTRING,0,(LPARAM)"Moyenne (avec coefficients)");
    CheckDlgButton(hwnd,ID_COEFF1,BST_CHECKED);
    //Création des Tooltips
    TOOLINFO ti;
    RECT rect;
    hTTip=CreateWindow(TOOLTIPS_CLASS,NULL,WS_POPUP|TTS_NOPREFIX,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,hwnd,NULL,hinstance,NULL);
    GetClientRect(hwnd,&rect);
    ti.cbSize=sizeof(TOOLINFO);
    ti.uFlags=TTF_SUBCLASS;
    GetClientRect(hwnd,&rect);
    for(int a=1;a <= 137;a++) {
        ti.hwnd=GetDlgItem(hwnd,a);
        ti.uId=0;
        if (a == ID_OK)
            ti.lpszText="Ajouter la note à la liste";
        else if (a == ID_ANNULER)
            ti.lpszText="Annuler la dernière note";
        else if (a == ID_RECOMMENCER)
            ti.lpszText="SUpprimer toutes les notes";
        else if (a == ID_LIST)
            ti.lpszText="Liste des notes";
        else if (a == ID_EDIT)
            ti.lpszText="Tapez vos notes ici";
        else if (a == ID_COMBO)
            ti.lpszText="Interractions sur les notes";
        else if (a == ID_GOBACK)
            ti.lpszText="Afficher/cacher le graphe";
        else if (a == ID_ENREGISTRER)
            ti.lpszText="Enregistrer le tableau de notes actuel";
        else if (a == ID_IMPRIMER)
            ti.lpszText="Faire une 'impression-écran' de cette fenêtre (permet de sauvegarder le graphe)";
        else if (a == ID_CHECK)
            ti.lpszText="Afficher/cacher la grille sur le graphe";
        else if (a == ID_COEFFAUTRE)
            ti.lpszText="Choisir son propre coefficient (entre 1 et 99)";
        else if (a == ID_ABOUT)
            ti.lpszText="Afficher l'auteur du logiciel";
        else if (a == ID_CHARGER)
            ti.lpszText="Charger un tableau de notes";
        ti.rect.left=rect.left;
        ti.rect.top=rect.top;
        ti.rect.right=rect.right;
        ti.rect.bottom=rect.bottom;
        SendMessage(hTTip,TTM_ADDTOOL,0,(LPARAM)&ti);
    }
    SetFocus(edit);

    if (!hwnd) return FALSE;
    ShowWindow(hwnd,nCmdShow);
    while (GetMessage(&msg,NULL,0,0)) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return msg.wParam;
}
//Traitement des messages Client-Machine
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    switch (uMsg) {
        case WM_CONTEXTMENU:
            HMENU hmenu,hpopup;
            hmenu=LoadMenu(hinst,"LEMENU");
            hpopup=GetSubMenu(hmenu,0);
            TrackPopupMenuEx(hpopup,0,LOWORD(lParam),HIWORD(lParam),hwnd,NULL);
            DestroyMenu(hmenu);
            break;
        case WM_COMMAND:
            switch (LOWORD(wParam)) {
                case 111:
                    DialogBox(hinst,"Coefficients",hwnd,(DLGPROC)ProcCoefficients);
                    break;
                case 112:
                    DestroyWindow(hwnd);
                    break;
                case ID_BAC:
                    DialogBox(hinst,"Coefficients",hwnd,(DLGPROC)ProcCoefficients);
                    break;
                case ID_COEFFAUTRE:
                    DialogBox(hinst,"DIALOG1",hwnd,(DLGPROC)Dialog1Proc1);
                    break;
                case ID_GOBACK:
                    RECT area;
                    GetWindowRect(hwnd,&area);
                    int width=area.right-area.left;
                    if (width == 320) {
                        SetWindowPos(hwnd,0,area.left,area.top,800,350,0);
                        SetWindowText(goback,"<");
                    }
                    else {
                        SetWindowPos(hwnd,0,area.left,area.top,320,275,0);
                        SetWindowText(goback,">");
                    }
                    break;
                case ID_COMBO:
                    nbritem=SendMessage(list,LB_GETCOUNT,0,0);
                    if (nbritem > 0) Refresh();
                    break;
                case ID_ANNULER:
                    nbritem=SendMessage(list,LB_GETCOUNT,0,0)-1;
                    SendMessage(list,LB_DELETESTRING,nbritem,0);
                    Refresh();
                    break;
                case ID_RECOMMENCER:
                    if (MessageBox(hwnd,"Etes-vous sûr(e) de vouloir annuler tous les calculs en cours ?\t\n",
                        "Avertissement",MB_ICONQUESTION|MB_OKCANCEL) == IDOK) {
                        while (SendMessage(list,LB_GETCOUNT,0,0)*2)
                            SendMessage(list,LB_DELETESTRING,0,0);
                        SetWindowText(edit,"");
                        SendMessage(combo,CB_SELECTSTRING,0,(LPARAM)"Moyenne (avec coefficients)");
                        CheckDlgButton(hwnd,ID_COEFF05,BST_UNCHECKED);
                        CheckDlgButton(hwnd,ID_COEFF2,BST_UNCHECKED);
                        CheckDlgButton(hwnd,ID_COEFFAUTRE,BST_UNCHECKED);
                        CheckDlgButton(hwnd,ID_COEFF1,BST_CHECKED);
                        SetWindowText(coeffautre,"autre...");
                        EnableWindow(recommencer,FALSE);
                        Refresh();
                    }
                    break;
                case ID_CHECK:
                    Refresh();
                    InvalidateRect(hwnd,NULL,FALSE);
                    UpdateWindow(hwnd);
                    break;
                case ID_OK:
                {
                    char text[10];
                    GetWindowText(edit,text,10);
                    int text2=atoi(text);
                    for(int a=1;a <= 20;a++) {
                        if (text2 == a) {
                            int b=7;
                            while (b<=10) {
                                if (IsDlgButtonChecked(hwnd,b)) {
                                    char textcoeff[5];
                                    double verif=1.5;
                                    GetWindowText(GetDlgItem(hwnd,b),textcoeff,10);
                                    if (strchr(textcoeff,'a') != NULL) {
                                        sscanf(textcoeff,"autre: %lf",&verif);
                                        sprintf(textcoeff,"%lf",verif);
                                    }
                                    char par[10]="";
                                    sprintf(par,"%s  (%s)",text,textcoeff);
                                    SendMessage(list,LB_ADDSTRING,0,(LPARAM)par);
                                    EnableWindow(annuler,TRUE);
                                    EnableWindow(recommencer,TRUE);
                                    Refresh();
                                    break;
                                }
                                b++;
                            }
                        }
                    }
                    break;
                }
                case ID_CHARGER:
                    while (SendMessage(list,LB_GETCOUNT,0,0)*2)
                        SendMessage(list,LB_DELETESTRING,0,0);
                    SetWindowText(edit,"");
                    SendMessage(combo,CB_SELECTSTRING,0,(LPARAM)"Moyenne (avec coefficients)");
                    CheckDlgButton(hwnd,ID_COEFF05,BST_UNCHECKED);
                    CheckDlgButton(hwnd,ID_COEFF2,BST_UNCHECKED);
                    CheckDlgButton(hwnd,ID_COEFFAUTRE,BST_UNCHECKED);
                    CheckDlgButton(hwnd,ID_COEFF1,BST_CHECKED);
                    SetWindowText(coeffautre,"autre...");
                    EnableWindow(recommencer,FALSE);
                    OPENFILENAME ofn;
                    ZeroMemory(&ofn,sizeof(OPENFILENAME));
                    ofn.lStructSize=sizeof(OPENFILENAME);
                    ofn.hwndOwner=hwnd;
                    ofn.lpstrFile=szFile;
                    ofn.nMaxFile=MAX_PATH;
                    ofn.lpstrFilter="Fichier Moyenne (*.moy)\0*.moy\0";
                    ofn.nFilterIndex=1;
                    ofn.lpstrTitle="Ouvrir un fichier Moyenne...";
                    ofn.Flags=OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
                    if (GetOpenFileName(&ofn) == TRUE) {
                        DWORD lenbloc,s;
                        char *tampon;
                        fo=CreateFile(szFile,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
                        lenbloc=GetFileSize(fo,NULL);
                        tampon=(PCHAR)LocalAlloc(LMEM_FIXED,lenbloc+1);
                        ReadFile(fo,tampon,lenbloc,&s,NULL);
                        tampon[lenbloc]=0;
                        int i=0,p=0;
                        for(i=0;tampon[i] != '\0';i++) {
                            if (tampon[i] == '\r') {
                                for(p=i;tampon[p]!= '\0';p++)
                                    tampon[p]=tampon[p+1];
                            }
                        }
                        char* token=strtok(tampon,"\n");
                        while (token != NULL) {
                            SendMessage(list,LB_ADDSTRING,0,(LPARAM)token);
                            token=strtok(NULL,"\n");
                        }
                        LocalFree(tampon);
                        CloseHandle(fo);
                        Refresh();
                     }
                    break;
                case ID_ENREGISTRER:
                    DialogBox(hinst,"DIALOG2",hwnd,(DLGPROC)Dialog1Proc2);
                    break;
                case ID_IMPRIMER:
                    if (HwndToBmpFile(hwnd,"Moyennes/Graphique.bmp")) {
                        PostMessage(hwnd,WM_NEXTDLGCTL,0,0);
                        if (MessageBox(hwnd,"L'impression écran s'est effectuée avec succès !\t\n"
                            "L'image a été enregistrée dans le dossier /Moyennes/\t\n"
                            "sous le nom de 'Graphique.bmp'.\t\n\n"
                            "Souhaitez-vous ouvrire l'image maintenant ?\t\n",
                            "Information",MB_ICONINFORMATION|MB_OKCANCEL) != IDCANCEL)
                                ShellExecute(hwnd,"open","Graphique.bmp",NULL,"Moyennes",SW_SHOW);
                    }
                    else
                        MessageBox(hwnd,"Veuillez recommencer.","Erreur",MB_OK);
                    break;
                case ID_ABOUT:
                    MessageBox(hwnd,"- Moyennes -\nLogiciel pour calculer ses moyennes\t\n(copyrights © WINKEL Vincent)\t\n",
                        "A propos...",MB_OK|MB_ICONASTERISK);
                    break;
            }
        case WM_PAINT:
            Draw(calcul);
            break;
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
        default:
            return DefWindowProc(hwnd,uMsg,wParam,lParam);
    }
}
//Aliases de raccourci (traitement du graphique)
void Refresh() {
    nbritem=SendMessage(list,LB_GETCOUNT,0,0);
    if (nbritem > 0) {
        char textitem[100];
        GetWindowText(combo,textitem,100);
        char item1[]="Moyenne (avec coefficients)";
        char item2[]="Moyenne (sans coefficients)";
        char item3[]="Nombre de notes >= 10";
        char item4[]="Nombre de notes < 10";
        char item5[]="Etendue (différence max - min)";
        char item6[]="Médiane (avec coefficients)";
        char item7[]="Médiane (sans coefficients)";
        int a=0;
        double nbr=0,nbr2=0,note=0,coeff=0;
        char text[20],texttitle[200];
        if (strcmp(textitem,item1) == 0) {
            for(a=0;a < nbritem;a++) {
                SendMessage(list,LB_GETTEXT,a,(LPARAM)text);
                sscanf(text,"%lf  (%lf)",&note,&coeff);
                nbr+=note*coeff;
                nbr2+=coeff;
            }
            afficheMoy=nbr/nbr2;
            sprintf(texttitle,"Moyenne (avec coefficients): %.2f",afficheMoy);
            SetWindowText(box,texttitle);
            SetWindowText(hwnd,texttitle);
            calcul=1;
        }
        else if (strcmp(textitem,item2) == 0) {
            for(a=0;a < nbritem;a++) {
                SendMessage(list,LB_GETTEXT,a,(LPARAM)text);
                sscanf(text,"%lf  (%lf)",&note,&coeff);
                nbr+=note;
            }
            afficheMoy=nbr/nbritem;
            sprintf(texttitle,"Moyenne (sans coefficients): %.2f",afficheMoy);
            SetWindowText(box,texttitle);
            SetWindowText(hwnd,texttitle);
            calcul=1;
        }
        if (strcmp(textitem,item3) == 0) {
            for(a=0;a < nbritem;a++) {
                SendMessage(list,LB_GETTEXT,a,(LPARAM)text);
                sscanf(text,"%lf  (%lf)",&note,&coeff);
                if (note >= 10) nbr++;
                nbr2++;
            }
            coeff=(nbr*100)/nbr2;
            sprintf(texttitle,"Notes >= 10: %.0f/%.0f (%.1f %%)",nbr,nbr2,coeff);
            SetWindowText(box,texttitle);
            SetWindowText(hwnd,texttitle);
            calcul=0;
        }
        else if (strcmp(textitem,item4) == 0) {
            for(a=0;a < nbritem;a++) {
                SendMessage(list,LB_GETTEXT,a,(LPARAM)text);
                sscanf(text,"%lf  (%lf)",&note,&coeff);
                if (note < 10) nbr++;
                nbr2++;
            }
            coeff=(nbr*100)/nbr2;
            sprintf(texttitle,"Notes < 10: %.0f/%.0f (%.1f %%)",nbr,nbr2,coeff);
            SetWindowText(box,texttitle);
            SetWindowText(hwnd,texttitle);
            calcul=0;
        }
        else if (strcmp(textitem,item5) == 0) {
            if (nbritem < 2) {
                SetWindowText(box,"2 valeurs minimum sont requises");
                SetWindowText(hwnd,"2 valeurs minimum sont requises");
            }
            else {
                nbr=0,nbr2=20;
                for(a=0; a < nbritem;a++) {
                    SendMessage(list,LB_GETTEXT,a,(LPARAM)text);
                    sscanf(text,"%lf  (%lf)",&note,&coeff);
                    if (note > nbr) nbr=note;
                    else if (note < nbr2) nbr2=note;
                }
                nbr-=nbr2;
                sprintf(texttitle,"Etendue des notes: %.2f",nbr);
                SetWindowText(box,texttitle);
                SetWindowText(hwnd,texttitle);
                calcul=0;
            }
        }
        else if (strcmp(textitem,item6) == 0) {
            for(a=0;a < nbritem;a++) {
                SendMessage(list,LB_GETTEXT,a,(LPARAM)text);
                sscanf(text,"%lf  (%lf)",&note,&coeff);
                nbr+=coeff;
            }
            nbr/=2;
            SendMessage(list,LB_GETTEXT,nbr,(LPARAM)text);
            sscanf(text,"%lf  (%lf)",&note,&coeff);
            sprintf(texttitle,"Médiane (avec coefficients): %.2f",note);
            SetWindowText(box,texttitle);
            SetWindowText(hwnd,texttitle);
            calcul=0;
        }
        else if (strcmp(textitem,item7) == 0) {
        }
    }
    else {
        SetWindowText(box,"Aucune valeur");
        SetWindowText(hwnd,"Aucune valeur");
    }
    Draw(calcul);
    InvalidateRect(hwnd,NULL,FALSE);
    UpdateWindow(hwnd);
}
void Draw(BOOL calcul) {
    PAINTSTRUCT ps;
    HDC hdc=BeginPaint(hwnd,&ps);
    HPEN hp2px,hpOld;
    HBRUSH brush;
    HFONT NewFont,OldFont;
    LOGFONT lf;
    ZeroMemory(&lf,sizeof(LOGFONT));
    lstrcpy(lf.lfFaceName,"Arial");
    lf.lfHeight=12;
    NewFont=CreateFontIndirect(&lf);
    OldFont=(HFONT)SelectObject(hdc,NewFont);
    //Initialisation du graphique
    /*if (calcul == FALSE) {
        brush=CreateSolidBrush(RGB(220,220,220));
        hpOld=(HPEN)SelectObject(hdc,brush);
    }*/
    Rectangle(hdc,330,10,780,300);
    MoveToEx(hdc,360,20,NULL);
    LineTo(hdc,360,270);
    MoveToEx(hdc,350,260,NULL);
    LineTo(hdc,745,260);
    //Ajout des graduations
    int a=20,b=360,d=20;
    char c[3];
    for(a=20;a <= 250;a+=12) {
        sprintf(c,"%d",d);
        MoveToEx(hdc,358,a,NULL);
        LineTo(hdc,360,a);
        int l=strlen(c);
        if (l == 2) TextOut(hdc,345,a-5,c,lstrlen(c));
        else TextOut(hdc,350,a-5,c,lstrlen(c));
        d--;
    }
    for(b=360;b <= 750;b+=12) {
        MoveToEx(hdc,b,261,NULL);
        LineTo(hdc,b,263);
    }
    //Ajout de texte
    sprintf(nbritem2,"%d",nbritem);
    char e[]="Total des notes: ";
    char e2[]=" / 32";
    strcat(e,nbritem2);
    strcat(e,e2);
    lf.lfHeight=15;
    NewFont=CreateFontIndirect(&lf);
    OldFont=(HFONT)SelectObject(hdc,NewFont);
    TextOut(hdc,480,275,e,lstrlen(e));
    //Traçage du graphique
    hp2px=CreatePen(PS_SOLID,1,RGB(150,150,250));
    hpOld=(HPEN)SelectObject(hdc,hp2px);
    a=0,b=362;
    char text[20];
    for(a=0;a <= nbritem-1;a++) {
        if (a > 31) break;
        SendMessage(list,LB_GETTEXT,a,(LPARAM)text);
        float nbr=atof(text);
        SelectObject(hdc,GetStockObject(LTGRAY_BRUSH));
        Rectangle(hdc,b,ceil(260-12*nbr),b+9,260);
        b+=12;
    }
    //Affichage (ou non) de la grille
    if (IsDlgButtonChecked(hwnd,ID_CHECK)) {
        hp2px=CreatePen(PS_SOLID,1,RGB(200,200,200));
        hpOld=(HPEN)SelectObject(hdc,hp2px);
        int a=20,b=372;
        for(a=20;a<=250;a+=12) {
            MoveToEx(hdc,361,a,NULL);
            LineTo(hdc,745,a);
        }
        for(b=372;b<=750;b+=12) {
            MoveToEx(hdc,b,20,NULL);
            LineTo(hdc,b,260);
        }
    }
    //Affichage de la moyenne
    if (nbritem > 0) {
        hp2px=CreatePen(PS_SOLID,1,RGB(50,150,170));
        hpOld=(HPEN)SelectObject(hdc,hp2px);
        float nbr=260-12*afficheMoy;
        MoveToEx(hdc,360,nbr,NULL);
        LineTo(hdc,745,nbr);
        lf.lfHeight=13;
        NewFont=CreateFontIndirect(&lf);
        OldFont=(HFONT)SelectObject(hdc,NewFont);
        TextOut(hdc,700,nbr-13,"Moyenne",7);
    }
    //Annonce de l'état du traitement du graphique
    if (calcul == FALSE) {
        hp2px=CreatePen(PS_SOLID,1,RGB(100,100,100));
        hpOld=(HPEN)SelectObject(hdc,hp2px);
        lf.lfHeight=40;
        NewFont=CreateFontIndirect(&lf);
        OldFont=(HFONT)SelectObject(hdc,NewFont);
        BeginPath(hdc);
        TextOut(hdc,400,100," Graphique non-traité ",22);
        EndPath(hdc);
        StrokePath(hdc);
    }
    DeleteObject(NewFont);
    EndPaint(hwnd,&ps);
}
//Autre choix d'un coefficiant
BOOL APIENTRY Dialog1Proc1(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) {
    switch (uMsg) {
        case WM_COMMAND:
            if (LOWORD(wParam) == 2) {
                CheckDlgButton(hwnd,ID_COEFF1,BST_CHECKED);
                CheckDlgButton(hwnd,ID_COEFFAUTRE,BST_UNCHECKED);
                EndDialog(hDlg,0);
            }
            else if (LOWORD(wParam) == 1) {
                char textedit[100]="";
                GetDlgItemText(hDlg,3,textedit,100);
                int verif=atoi(textedit);
                if (verif <= 0 || verif > 99) {
                    MessageBox(hwnd,"Le coefficient doit être un nombre.\t\n"
                        "      (compris entre 1 et 99)\t\n","Erreur de syntaxe",MB_OK|MB_ICONERROR);
                    SetFocus(GetDlgItem(hDlg,3));
                }
                else {
                    char textedit2[]="autre: ";
                    strcat(textedit2,textedit);
                    SetWindowText(coeffautre,textedit2);
                    EndDialog(hDlg,0);
                    return TRUE;
                }
                return FALSE;
            }
            break;
        default:
            return FALSE;
    }
}
//Demande de nom de fichier
BOOL APIENTRY Dialog1Proc2(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) {
    switch (uMsg) {
        case WM_COMMAND:
            if (LOWORD(wParam) == 2)
                EndDialog(hDlg,0);
            else if (LOWORD(wParam) == 1) {
                //Vérification de l'existence du dossier /Moyennes/
                HANDLE hDir=CreateFile("Moyennes",FILE_LIST_DIRECTORY,FILE_SHARE_READ|FILE_SHARE_DELETE,NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,NULL);
                if (hDir == INVALID_HANDLE_VALUE)
                    CreateDirectory("Moyennes",NULL);
                else
                    CloseHandle(hDir);
                //Procédure
                int a=0,lenbloc=0,total=0;
                total=SendMessage(list,LB_GETCOUNT,0,0);
                char text[99]="",item[20]="",fichier[99]="Moyennes/";
                GetDlgItemText(hDlg,3,text,50);
                if (total <= 0) {
                    MessageBox(GetActiveWindow(),"Aucune moyenne n'a été ajoutée.\t\n","Erreur",MB_ICONERROR|MB_OK);
                    EndDialog(hDlg,0);
                    return FALSE;
                }
                else if (strcmp(text,"") == 0) {
                    MessageBox(GetActiveWindow(),"Il faut choisir un nom de fichier.\t\n","Erreur",MB_ICONERROR|MB_OK);
                    return FALSE;
                }
                strcat(fichier,text);
                strcat(fichier,".moy");
                FILE* file=fopen(fichier,"w");
                for(a=0;a < total;a++) {
                    SendMessage(list,LB_GETTEXT,a,(LPARAM)item);
                    MessageBox(hwnd,item,"ok",MB_OK);
                    fprintf(file,"%s\n",item);
                }
                fclose(file);
                EndDialog(hDlg,0);
                return TRUE;
            }
            break;
        default:
            return FALSE;
    }
}
//Tableau des coefficients
BOOL APIENTRY ProcCoefficients(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) {
    switch (uMsg) {
        case WM_CLOSE:
            EndDialog(hDlg,0);
            break;
        case WM_CTLCOLORSTATIC:
            return((BOOL)ColorStatic(hDlg,wParam,lParam));
        case WM_INITDIALOG:
        {
            MessageBox(hDlg,"Les renseignements fournis ci-après ont été trouvés sur Internet.\t\n"
                "Malgré les nombreuses recherches, il se peut qu'un (ou plusieurs) coefficient(s)\t\n"
                "soi(en)t erroné(s). N'hésitez pas à contacter l'auteur (winkel@live.fr).\t\n","Avertissemen",
                MB_ICONINFORMATION|MB_OK);
            ShowWindow(GetDlgItem(hDlg,1),SW_HIDE);
            char** tab=split(Matieres,";",0);
            int nbr;
            for(nbr=0;tab[nbr] != NULL;nbr++) {}
            for(int a=0;a < nbr;a++)
                SendMessage(GetDlgItem(hDlg,2),LB_ADDSTRING,0,(LPARAM)tab[a]);
            free(tab);
            InitListView(hDlg);
            break;
        }
        case WM_COMMAND:
            if (LOWORD(wParam) == 2) {
                int num=SendMessage(GetDlgItem(hDlg,2),LB_GETCURSEL,0,0);
                char item[30];
                SendMessage(GetDlgItem(hDlg,2),LB_GETTEXT,num,(LPARAM)item);
                if (strcmp(item,"   &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;   ") == 0)
                    SendMessage(GetDlgItem(hDlg,3),LVM_DELETEALLITEMS,0,0);
                else if (strcmp(item,"L - Langue vivante 1") == 0)
                    SelectItem(hDlg,0);
                else if (strcmp(item,"L - Langue vivante 2") == 0)
                    SelectItem(hDlg,1);
                else if (strcmp(item,"L - Mathématiques") == 0)
                    SelectItem(hDlg,2);
                else if (strcmp(item,"S - S.I") == 0)
                    SelectItem(hDlg,3);
                else if (strcmp(item,"&#8212; S.V.T") == 0)
                    SelectItem(hDlg,4);
                else if (strcmp(item,"&#8212; Mathématiques") == 0)
                    SelectItem(hDlg,5);
                else if (strcmp(item,"&#8212; Physique/Chimie") == 0)
                    SelectItem(hDlg,6);
                else if (strcmp(item,"S.E.S - Langues viv.") == 0)
                    SelectItem(hDlg,7);
                else if (strcmp(item,"S.E.S - Maths") == 0)
                    SelectItem(hDlg,8);
                else if (strcmp(item,"S.E.S - S.E.S") == 0)
                    SelectItem(hDlg,9);
                if (strcmp(item,"S - S.V.T :") == 0) {
                    popup=1;
                    RECT rct;
                    GetClientRect(hDlg,&rct);
                    int cX=rct.right+1;
                    int cY=rct.bottom-20;
                    MoveWindow(GetDlgItem(hDlg,2),15,65,105,cY-81,TRUE);
                    MoveWindow(GetDlgItem(hDlg,3),122,65,cX-142,cY-81,TRUE);
                    ShowWindow(GetDlgItem(hDlg,1),SW_SHOW);
                }
                else {
                    popup=0;
                    RECT rct;
                    GetClientRect(hDlg,&rct);
                    int cX=rct.right+1;
                    int cY=rct.bottom;
                    MoveWindow(GetDlgItem(hDlg,2),15,65,105,cY-81,TRUE);
                    MoveWindow(GetDlgItem(hDlg,3),122,65,cX-142,cY-81,TRUE);
                    ShowWindow(GetDlgItem(hDlg,1),SW_HIDE);
                }
            }
            break;
        case WM_SIZE:
            int cX=LOWORD(lParam)+1;
            int cY=HIWORD(lParam);
            int cH=(popup)?20:0;
            MoveWindow(GetDlgItem(hDlg,1),15,cY-24,400,cY-10,TRUE);
            MoveWindow(GetDlgItem(hDlg,2),15,65,105,cY-81-cH,TRUE);
            MoveWindow(GetDlgItem(hDlg,3),122,65,cX-142,cY-81-cH,TRUE);
            break;
        case WM_SIZING:
            RECT* wndRect=(RECT*)lParam;
            int cXp=wndRect->right-wndRect->left;
            int cYp=wndRect->bottom-wndRect->top;
            if (cXp < 440) wndRect->right = 440+wndRect->left;
            if (cYp < 320) wndRect->bottom = 320+wndRect->top;
            break;
        default:
            return FALSE;
    }
}
//Enregistrement du graphe
int __stdcall HwndToBmpFile(HWND hwnd,char* pszflname) {
    HDC memdc,hdc;
    HANDLE hfl;
    DWORD dwBytes,dwNumColors;
    void* pBits;
    HBITMAP hbmp;
    BITMAPFILEHEADER fileheader;
    BITMAPINFOHEADER infoheader;
    RGBQUAD colors[256];
    BITMAPINFO bmpinfo;
    HGDIOBJ hret;
    RECT rct;
    hdc=GetWindowDC(hwnd);
    if(!hdc)
        return 0;
    GetWindowRect(hwnd,&rct);
    rct.bottom-=rct.top;
    rct.right-=rct.left;
    rct.top=GetDeviceCaps(hdc,BITSPIXEL);
    if (rct.top <= 8)
        dwNumColors=256;
    else
        dwNumColors=0;
    if (!(memdc=CreateCompatibleDC(hdc)))
        goto relHwndDc;
    bmpinfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
    bmpinfo.bmiHeader.biWidth=rct.right;
    bmpinfo.bmiHeader.biHeight=rct.bottom;
    bmpinfo.bmiHeader.biPlanes=1;
    bmpinfo.bmiHeader.biBitCount=(WORD)rct.top;
    bmpinfo.bmiHeader.biCompression=BI_RGB;
    bmpinfo.bmiHeader.biSizeImage=0;
    bmpinfo.bmiHeader.biXPelsPerMeter=0;
    bmpinfo.bmiHeader.biYPelsPerMeter=0;
    bmpinfo.bmiHeader.biClrUsed=dwNumColors;
    bmpinfo.bmiHeader.biClrImportant=dwNumColors;
    hbmp=CreateDIBSection(hdc,&bmpinfo,DIB_PAL_COLORS,&pBits,NULL,0);
    if (!hbmp)
        goto errato;
    hret=SelectObject(memdc,hbmp);
    if ((!hret) || (hret == HGDI_ERROR))
        goto errato;
    if (!BitBlt(memdc,0,0,rct.right,rct.bottom,hdc,0,0,SRCCOPY))
        goto errato;
    if (dwNumColors)
        dwNumColors=GetDIBColorTable(memdc,0,dwNumColors,colors);
    fileheader.bfType=0x4D42;
    rct.left=dwNumColors*sizeof(RGBQUAD);
    fileheader.bfSize=((rct.right*rct.bottom*rct.top) >> 3)+rct.left+sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
    fileheader.bfReserved1=fileheader.bfReserved2=0;
    fileheader.bfOffBits=rct.left+sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
    infoheader.biSize=sizeof(BITMAPINFOHEADER);
    infoheader.biWidth=rct.right;
    infoheader.biHeight=rct.bottom;
    infoheader.biPlanes=1;
    infoheader.biBitCount=(WORD)rct.top;
    infoheader.biCompression=BI_RGB;
    infoheader.biSizeImage=infoheader.biClrImportant=0;
    infoheader.biXPelsPerMeter=infoheader.biYPelsPerMeter=0;
    infoheader.biClrUsed=dwNumColors;
    hfl=CreateFile(pszflname,GENERIC_WRITE,0,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
    if (hfl == INVALID_HANDLE_VALUE) {
        DeleteObject(hbmp);
        goto errato;
    }
    WriteFile(hfl,&fileheader,sizeof(BITMAPFILEHEADER),&dwBytes,0);
    WriteFile(hfl,&infoheader,sizeof(BITMAPINFOHEADER),&dwBytes,0);
    if(!dwNumColors)
        WriteFile(hfl,colors,rct.left,&dwBytes,0);
    WriteFile(hfl,pBits,(rct.right*rct.bottom*rct.top) >> 3,&dwBytes, 0);
    CloseHandle(hfl);
    DeleteObject(hbmp);
    DeleteDC(memdc);
    return 1;
    errato:
    DeleteDC(memdc);
    relHwndDc:
    ReleaseDC(hwnd,hdc);
    return 0;
}
static HBRUSH ColorStatic(HWND hDlg,WPARAM wParam,LPARAM lParam) {
    if((HWND)lParam == GetDlgItem(hDlg,10)) {
        SetBkMode((HDC)wParam,TRANSPARENT);
        SetBkColor((HDC)wParam,GetSysColor(COLOR_INFOBK));
        SetTextColor((HDC)wParam,GetSysColor(COLOR_INFOTEXT));
        return GetSysColorBrush(COLOR_INFOBK);
    }
    else {
        SetBkMode((HDC)wParam,TRANSPARENT);
		SetBkColor((HDC)wParam,(COLORREF)GetSysColor(COLOR_3DFACE));
		SetTextColor((HDC)wParam,RGB(60,60,60));
		return GetSysColorBrush(COLOR_3DFACE);
    }
}

 Conclusion

Je compte l'intégrer à une "suite" de logiciels de bureautique pour étudiants.
Au passage, si quelqu'un a des idées d'applications à proposer...

 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


 Historique

15 avril 2008 10:02:54 :
problème avec le zip
15 avril 2008 10:03:51 :
problème avec le zip
12 octobre 2008 02:48:06 :
- recodage complet du programme - ajout de fonctions - correction de bogues
12 octobre 2008 02:49:46 :
- recodage complet du programme - ajout de fonctions - correction de bogues

 Sources du même auteur

Source avec Zip Source avec une capture [WIN32] AGENDA / ORGANISEUR (GESTION DU CONTRÔLE "CALENDRIER...
Source avec Zip Source avec une capture [WIN32] PETIT RÉPERTOIRE TÉLÉPHONIQUE ET AUTRES (GESTION LIS...
Source avec Zip Source avec une capture GALAWA, ÉDITEUR DE SCRIPTS MIRC (+ CRÉATEUR DE PICWINS ET DI...

 Sources de la même categorie

CONSTRUCTION D'UNE AUTOMATE FINIS DETERMINISTE par skible
COMPILATEUR BF VERS BF-BYTECODE par Davy974
GESTIONNAIRE DE BIBLIOTHEQUE par eishtein
FICHIER ALBUM MUSICAL par imenouuuuuuuuuche
LOUISDU81 HTTP EDITOR par louisdu81

 Sources en rapport avec celle ci

Source avec Zip EASYLIB WIN32 C++ POUR DU PROTOTYPAGE RAPIDE par gourky
Source avec Zip Source avec une capture USB DETECTION par abandonware
Source avec Zip Source avec une capture CLASSE GRAPH: GESTION DES GRAPHIQUES DANS LES APPLICATIONS W... par Pistol_Pete
Source avec Zip BASE POUR L'UTILISATION DU GDI (API WINDOWS) par _michel
Source avec Zip Source avec une capture PIECHART SUR DIALOG SANS RESSOURCE par yann_lo_san

Commentaires et avis

Commentaire de omnia le 16/04/2008 12:41:17

salut,

sympa comme prog :p

sa me donne envie de faire des graphs :)

Commentaire de bibiyainfo le 19/04/2008 01:38:53

PAS MAL DU TOUS POUR UN DEBUT ,SOF IL M'ANQUE DE VERIFICATION AU NIVEAU DES CHAINE DE CARACTERES PAR EXEMPLE:ON PEUX TAPEZ DES NOMBRE OU DES LETRES C LA MEME CHOSE IL YA PAS DE MESAGE D'ERREUR
SINON TRES BIEN .
ps:qu'elle est la biblioteque ki regroupe les fonctions d'utilisation de graphs sur dev c++

Commentaire de omnia le 19/04/2008 10:12:38

salut, ici dans le contexte

il n'utilise que les fonctions standards Win32.

donc pas de libs externes,


il y a un problème avec l'exe (enfin chez moi) j'ai été obliger de le recompiler pour qu'il fonctionne, je ne sais pas pourquoi.

et puis pas de projet, que le fichier c sources.

Commentaire de uaip le 19/04/2008 12:17:24

hum... oui exact, je vais refaire le zip (en fait j'ai eu des soucis de fichiers qui se sont dispatchés un peu partout).

- pour le problème de l'editbox qui accepte des caractères alpha, en effet au début j'avais précisé l'option 'numérique', mais du coup on ne pouvait plus mettre de virgule. Ensuite j'ai voulu vérifier la syntaxe quand on appuie sur "valider" avec une petite regexp, mais j'ai remarqué que c'était le bordel pour faire une regexp en c/c++, du coup j'ai dû oublier...

- et oui j'ai choisi win32 car, comme je l'ai dit, je n'avais jamais fait de C, puis je suis tombé sur un petit tuto sur le net (très bien expliqué) pour faire des fenêtres avec cette API, et ça mélangé à msdn, ça m'a aidé ^^

Commentaire de bibiyainfo le 20/04/2008 20:27:03

BONSOIR je voudrai avoire
1_le prototype de la fonction clear screen sur le dev c++
2_et une introduction sur la compilation séparé .
merci d'avance a ts

Commentaire de uaip le 21/04/2008 11:21:42

Salut,
1_tu cherches sur google ou msdn
2_tu cherches sur google ou msdn

Ensuite, si tu ne trouves pas, il ya un forum ici prévu pour ça...

Commentaire de bibiyainfo le 21/04/2008 21:28:48

merci coméme

Commentaire de fabricelepro le 24/09/2008 20:11:35

Salut
j'ai un probleme de compilation avec dev c++ je ne sais pas pourquoi mais le compilateur refuse de compiler.

  Merci de vouloir me repondre

Commentaire de uaip le 24/09/2008 20:19:49

Arf oui désolé. J'avais oublié cetet source.
Si tu ne parviens pas à compiler, cela peut venir du fait que j'ai codé cette source avant même de comprendre le "fonctionnement" du langage C. Il y avait plein d'incompatibilités que mon compilo ignorait, mais qui peuvent en effet poser problème autre part.
J'ai refait cette source en y ajoutant des fonctions (charge / sauvegarde des notes + ajout des barèmes officiels selon la filière) mais depuis la rentrée j'ai mis ça de côté :s

Je vais essayer de finir, ou du moins de reposter une version stable.
Encore désolé.

Commentaire de uaip le 24/09/2008 20:21:05

Si tu veux je te tiendrai au courant quand je mettrai la source à jour sur le site.

Commentaire de fabricelepro le 26/09/2008 19:51:21

Salut UIAP
  pas de probleme tiens moi informe quand tu mettras la nouvelle source au net.

   Bye

Commentaire de uaip le 12/10/2008 02:52:06

Okay... j'ai tenté 2fois de changer le screen, mais en vain, il veut pas le bougre.
Voilà l'allure du programme, maintenant :
http://www.picdo.net/Fichiers/c9d8fd874d81c23721213fd88fd12399/screen.JPG

Commentaire de fabricelepro le 11/01/2009 20:46:08

salut
ton lien pour l'image ne fonctionne pas met le à jour

Commentaire de uaip le 11/01/2009 21:33:01

Salut,
en effet le lien ne fonctionne plus mais depuis le temps, le screenshot s'est bien actualisé.
Clique sur l'image en haut de cette page pour l'agrandir, c'est la bonne.

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

Win32 Dialog [ par xarier ] Hi allvoila j'ai creé deux boite de dialog (resource je veut dire au prog quand je cliquerait sur un button dans la premiere fenetre la deusieme souv Tracer graphique en fonction d'un tableau [ par Bobbix ] Bonjour,Dans le cadre d'un projet, j'ai besoin de votre aide sur le graphisme en WIN32. Nous avons réalisé une carte électronique d'un oscilloscope qu Un graphique simple à mettre en place [ par Oeil_de_taupe ] Bonjour les codeurs, J'ai fait un prog qui r&#233;cup&#232;re le son depuis une entr&#233;e audio, jusqu'&#224; la aucun probl&#232;me (je r&#233;cup win32 interface graphique devcpp [ par Stephane ] Salut a tous Voila je fait le pas progressif Visual Basic vers CPP (j'utilise devcpp). Je commence &#224; """"""maitriser"""""" les class et pointeur Win32 affichage graphique fuite mémoire [ par _Jonathan ] Bonjour a tous,j'ai fait une petite application affichant un graphique. Mais lorsque je le lance, le programme me bouffe toutes les ressources sous wi [API WIN32] Création d'une courbe dans un Dialog [ par tarretg ] Bonjour, Je développe actuellement un projet sous Visual C++ avec pluseurs Dialog Box en API. Sur l'une d'entre elles, je voudrais afficher un graph [C++ Win32] un menu avec une fenêtre Dialog [ par F0ra ] Je n'arrive pas à afficher un menu avec une fenêtre Dialog en C++ Win32Comme ceci :http://pages.cpsc.ucalgary.ca/~carman/481/examples/vb.net/menus.2.j Comment insérer un dialog dans un dialog (ou ressource dans un dialog) WIN32 [ par tazmania37 ] Bonjour,Je m'explique mieux.J'ai crée des ressources, correspondants à des modèles graphiques.Ce sont des petites fenêtres avec du texte et des icones MSchart graphique sous Visual C++ [ par The WidoW ] Bonjour,Je suis en stage dans un grand laboratoire de recherche...On m'a demand&#233; de cr&#233;er un logiciel pour une manip...J'ai du mal avec le c Update screen win32 [ par MoDDiB ] Voil&#224; j'ai un probl&#232;me avec le rafraichissement de ma fen&#234;tre en win32 je m'explique : je dessine une ligne &#224; l'aide de : &nbsp;&


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mars 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728
293031    

Consulter la suite du CalendriCode

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

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