salut j´ai trouver un tableau mait il ne se compile pas aider moi essellier le et di moi si il fonction ok salut merci
- 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_CY
CAPTION)+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);//ca
dre 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_SUNKE
N | 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);
*(l_datasFiche.pLRep)+=plomp;
}
sortieOk=true;
SendMessage(hWnd,WM_CLOSE,0,0);
}
}
break;
case WM_CLOSE:
// Détruire la fenêtre principale:
DestroyWindow(hWnd);
break;
case WM_DESTROY:
// Envoyer le message de sortie du programme:
PostQuitMessage(sortieOk?IDOK:IDCANCEL);
break;
default:
//Retour à la procédure par défaut:
return( DefWindowProc( hWnd, messg, wParam, lParam ) );
}
return 0;
}