Soyez le premier à donner votre avis sur cette source.
Vue 9 573 fois - Téléchargée 650 fois
#include "../Bibli/BListeIndir.hpp" #include <windows.h> struct { BLBString*pLDatas; BLBString*pLModele; BLBString*pLRep; LPTSTR pIntro; }l_datasFiche={NULL,NULL,NULL}; LRESULT CALLBACK WndProcFillFiche( HWND hWnd, UINT messg, WPARAM wParam, LPARAM lParam ); bool fillTableEntries(LPTSTR titre, LPTSTR intro, BLBString *paChps, BLBString *pRep,BLBString* paModele) { //20/09/05 //crééer une fenetre pôur remplir une 'fiche' (nb d'elts param) //fonction de remplissage de fiche: bool ok=false; //init datas l_datasFiche.pLDatas=paChps; l_datasFiche.pLModele=paModele; l_datasFiche.pLRep=pRep; l_datasFiche.pIntro=intro; //init fenetre HINSTANCE hInst=NULL; // Déclarer notre classe de fenêtre et définir ses membres: WNDCLASS wc; char NomClasse[] = "Ma_Fiche"; wc.lpszClassName = NomClasse; wc.hInstance = hInst; wc.lpfnWndProc = WndProcFillFiche; wc.hCursor = LoadCursor( 0, IDC_ARROW ); wc.hIcon = LoadIcon( hInst, "ID_ICO" ); wc.lpszMenuName = 0; wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE); wc.style = 0; wc.cbClsExtra = 0; wc.cbWndExtra = 0; // Enregistrer la classe de notre fenêtre: // if (! RegisterClass(&wc) // ) // return 0 ; // Obtenir la hauteur de la barre de titre: int barre=GetSystemMetrics(SM_CYCAPTION); // Créer notre fenêtre principale: //TODO : calculer hauteur... HWND hWnd = CreateWindow( NomClasse,titre,WS_SYSMENU | WS_MINIMIZEBOX ,0,0,640,460+barre, 0, 0, hInst,0); // Montrer la fenêtre: ShowWindow(hWnd, SW_SHOW ); UpdateWindow( hWnd ); CreateWindow("STATIC","123",WS_CHILD | WS_VISIBLE ,0,0,0,0,hWnd,0,0,0); // Boucle des messages: MSG Msg; while( GetMessage(&Msg, 0, 0, 0)) { TranslateMessage( &Msg ); DispatchMessage( &Msg ); } // Quitter le programme: ok=IDOK==Msg.wParam; l_datasFiche.pLDatas=NULL; l_datasFiche.pLRep=NULL; l_datasFiche.pIntro=NULL; return ok; } LRESULT CALLBACK WndProcFillFiche( HWND hWnd, UINT messg, WPARAM wParam, LPARAM lParam ) { //gestion fenetre associée à fillTableEntries() ASSERT(l_datasFiche.pLDatas&&l_datasFiche.pLRep&&l_datasFiche.pIntro); const unsigned int l=l_datasFiche.pLDatas->getNbElts(); unsigned int i; // Déclaration des variables: static HWND hReset,hCancel,hOK; static BListeIndir<HWND>lHItems; static BListeIndir<HWND>lHRep; static bool sortieOk=false; // Interception et traitement des messages: switch(messg) { case WM_CREATE: { int largeur=500;//arbitraire int hauteur=450;//a calculer en fonction du nb d'elts hauteur=120+l*30; //GetWindowPos(hWnd,cx-78,cy-30,0,0,SWP_NOZORDER |SWP_NOOWNERZORDER |SWP_NOSIZE |SWP_SHOWWINDOW ); // Créer tous les controles: //SetWindowPos(); MoveWindow(hWnd,0,0,largeur,GetSystemMetrics(SM_CYCAPTION)+hauteur+5,true); hReset=CreateWindow("BUTTON","Reset",WS_CHILD | WS_VISIBLE,20,hauteur-27,90,20,hWnd,0,0,0); hCancel=CreateWindow("BUTTON","Cancel",WS_CHILD | WS_VISIBLE,largeur/2-45,hauteur-27,90,20,hWnd,0,0,0); hOK=CreateWindow("BUTTON","OK",WS_CHILD | WS_VISIBLE,largeur-115,hauteur-27,90,20,hWnd,0,0,0); CreateWindow("STATIC","",SS_SUNKEN | SS_CENTER | WS_CHILD | WS_VISIBLE,0,0,largeur,hauteur-42,hWnd,0,0,0);//cadre haut CreateWindow("BUTTON","",BS_GROUPBOX | WS_CHILD | WS_VISIBLE,15,hauteur-40,largeur-30,37,hWnd,0,0,0);//cadre bas CreateWindow("STATIC",l_datasFiche.pIntro,SS_SUNKEN | SS_LEFT |WS_CHILD | WS_VISIBLE,20,10,largeur-40,40,hWnd,0,0,0); lHItems.vide();lHRep.vide(); CString plomp;int mi; for(i=0;i<l;i++) { // 20 ******* 20 ********************* 20 //TODO : custumiser mi plomp=l_datasFiche.pLDatas->getAt(i); //TODO BETER avec les infos de la police et du HBrush //mi=(plomp.GetLength())*15; mi=6*15;//actu, arbitraire lHItems+=CreateWindow("STATIC",plomp,SS_SUNKEN | SS_LEFT |WS_CHILD | WS_VISIBLE,20,60+i*30,mi-30,20,hWnd,0,0,0); if(l_datasFiche.pLModele&&i<l_datasFiche.pLModele->getNbElts()) plomp=l_datasFiche.pLModele->getAt(i); else plomp.Format("%d",i); // plomp=""; lHRep+=CreateWindow("EDIT",plomp,SS_SUNKEN | SS_LEFT |WS_CHILD | WS_VISIBLE,mi+10,60+i*30,largeur-mi-30,20,hWnd,0,0,0); } sortieOk=false; break; } case WM_COMMAND: { CString plomp; if((HWND)lParam==hReset) for(i=0;i<l;i++) { if(l_datasFiche.pLModele&&i<l_datasFiche.pLModele->getNbElts()) plomp=l_datasFiche.pLModele->getAt(i); else plomp.Format("%d",i); // plomp=""; SetWindowText(lHRep.getAt(i),plomp); } else if((HWND)lParam==hCancel) SendMessage(hWnd,WM_CLOSE,0,0); else if((HWND)lParam==hOK) { char plomp[500]; l_datasFiche.pLRep->vide(); for(i=0;i<l;i++) { //suppose 500 car max.... GetWindowText(lHRep.getAt(i),plomp,500);
19 oct. 2008 à 03:30
Pour compilation avec 2005
- faire migrer le projet
- au premier essai de compilation
ajouter "std::" devant exception
- au second essai, commenter la fonction
toLString()const
non utilisée dans ce projet.
- ça compile
évolutions principales apportées :
Zones multilignes
Navigation par touche TAB,
dimensions plus dynamiques et spécifiables en largeur,
mode modal complet : désactivation de la fenêtre appelante si spécifiée.
(dans ce programme de test, on peut réussir à créer une exception récupérée par visual )
23 sept. 2005 à 01:27
BListeIndir
http://www.cppfrance.com/code.aspx?ID=18584
Magicalement
22 sept. 2005 à 16:59
22 sept. 2005 à 13:32
22 sept. 2005 à 12:10
le gérant sous forme de liste
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.