touxe | Merci Poireau.
G fait ce que tu as dis mais g l'impression que ma fenetre n'est pas mis a jours mais tt les autres fenetre qui sont derrier ou meme le bureau de windows le sont!!
g appeler mas fonction comme ceci et c dans case WM_LBUTTONDOWN:
InvalidateRect(NULL, NULL, FALSE);
Konar merci a toi aussi mais g pas tout compris
Si ca peut etre utile voila le code
Code :
- LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- int i, tmp, annuler = 0, reserver = 0, j = 0;
- int xpos,ypos;
- static int adresse, taille;
- static BOOL cadre_ant=FALSE, cadre_alloue=FALSE, cadre_libere=FALSE;
- TCHAR buff_taille[15],buff_taille2[15], buff_adresse[15], buff_tmp[15];
- PTCHAR sztemp;
- int wmId, wmEvent;
- PAINTSTRUCT ps;
- HDC hdc;
- static HPEN hpen1,hpen2;
- static HBRUSH hbrush;
- static HWND hwndEdit[3];
- static HWND hwndbutton[3];
- static int pos[6] = {450,100,630,50,630,100};
- switch (message)
- {
- case WM_CREATE: //boite de texte
- hpen1 = CreatePen(PS_SOLID,1,RGB(255,0,0));
- hpen2 = CreatePen(PS_SOLID,1,RGB(128,128,128));
- hbrush = CreateHatchBrush(HS_BDIAGONAL, RGB(0,0,255));
- if ( (reserver == 0) && (annuler == 0))
- {
- }
- else
- if (reserver == 1)
- {
- // cree les boites
- hwndEdit[0] = CreateWindow(TEXT("edit" ),//creation
- NULL, // parametre
- WS_CHILD|WS_VISIBLE|WS_BORDER,
- 50,
- 150,
- 100,
- 20,
- hWnd,
- (HMENU)0,
- ((LPCREATESTRUCT)lParam)->hInstance,NULL);
- hwndEdit[1] = CreateWindow(TEXT("edit" ),//creation
- NULL, // parametre
- WS_CHILD|WS_VISIBLE|WS_BORDER,
- 230,
- 150,
- 100,
- 20,
- hWnd,
- (HMENU)1,
- ((LPCREATESTRUCT)lParam)->hInstance,NULL);
- // cree les boutons valider
- hwndbutton[0] = CreateWindow(TEXT("button" ),
- TEXT("VALIDER" ),
- WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
- 450,
- 150,
- 65,
- 20,
- hWnd,
- (HMENU)0+3,
- ((LPCREATESTRUCT)lParam)->hInstance,NULL);
- }
- else
- if (annuler == 1)
- {
- hwndEdit[0] = CreateWindow(TEXT("edit" ),//creation
- NULL, // parametre
- WS_CHILD|WS_VISIBLE|WS_BORDER,
- 50,
- 150,
- 100,
- 20,
- hWnd,
- (HMENU)0,
- ((LPCREATESTRUCT)lParam)->hInstance,NULL);
- hwndEdit[1] = CreateWindow(TEXT("edit" ),//creation
- NULL, // parametre
- WS_CHILD|WS_VISIBLE|WS_BORDER,
- 230,
- 150,
- 100,
- 20,
- hWnd,
- (HMENU)1,
- ((LPCREATESTRUCT)lParam)->hInstance,NULL);
- }
- return 0;
- case WM_COMMAND:
- wmId = LOWORD(wParam);
- wmEvent = HIWORD(wParam);
- // Parse the menu selections:
- switch (wmId)
- {
- case IDM_ABOUT:
- DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
- break;
- case IDM_INITIALISATION:
- //DialogBox(hInst, (LPCTSTR)IDD_DIALOG_ALGO, hWnd, (DLGPROC)menu_algo);
- break;
- case IDM_EXIT:
- DestroyWindow(hWnd);
- break;
- case 12: // Bouton OK de gauche
- err = FALSE;
- GetWindowText(hwndEdit[0], buff_taille, 15);
- GetWindowText(hwndEdit[1], buff_taille2, 15);
- SetWindowText(hwndEdit[0], TEXT("" ));
- SetWindowText(hwndEdit[1], TEXT("" ));
- strcat(buff_taille, " " );
- strcat(buff_taille, buff_taille2);
- tmp = wsprintf(buff_tmp, "Nom du client : %s", buff_taille);
- hdc = GetDC(hWnd);
- SetTextColor(hdc,0x00000000);
- TextOut(hdc, 60, 190, buff_tmp, tmp);
- aff_etat(hdc);
- aff_bar(hdc, hbrush);
- xpos = 20+adresse*760/TAILLE_MEM;
- MoveToEx(hdc, xpos, 450, NULL);
- SelectObject(hdc, hpen1);
- ReleaseDC(hWnd, hdc);
- if (err)
- MessageBox(hWnd, tab_err[-err], TEXT("ERREUR" ), MB_ICONERROR);
- break;
- }
- case WM_PAINT:
- hdc = BeginPaint(hWnd, &ps);
- if ( (reserver == 0) && (annuler == 0))
- {
- SetTextColor(hdc,0x00008000);
- RoundRect(hdc,290,5,470,35,16,16);
- TextOut(hdc,302,10,TEXT("AEROPORT DE L'EFREI" ),19);
- RoundRect(hdc,5,55,180,80,16,16);
- SelectObject(hdc, GetStockObject(NULL_BRUSH));
- TextOut(hdc,20,59,TEXT("RESERVER UN BILLET" ),18);
- RoundRect(hdc,180,55,355,80,16,16);
- TextOut(hdc,195,59,TEXT("ANNULER UN BILLET" ),17);
- SelectObject(hdc, GetStockObject(LTGRAY_BRUSH));
- Rectangle(hdc,-1,525,800,555);
- TextOut(hdc, 60, 190+5*j, "ICI", 3);
- j++;
- }
- else
- if (reserver == 1)
- {
- //SetBkColor(hdc, NULL);
- SetTextColor(hdc,0x00008000);
- RoundRect(hdc,290,5,470,35,16,16);
- TextOut(hdc,302,10,TEXT("RESERVATION" ),11);
- RoundRect(hdc,5,55,180,80,16,16);
- SelectObject(hdc, GetStockObject(NULL_BRUSH));
- TextOut(hdc,20,59,TEXT("RESERVER UN BILLET" ),18);
- RoundRect(hdc,180,55,355,80,16,16);
- TextOut(hdc,195,59,TEXT("ANNULER UN BILLET" ),17);
- SetTextColor(hdc,0x00000000);
- TextOut(hdc,5,151,TEXT("Nom :" ),5);
- TextOut(hdc,168,151,TEXT("Prenom :" ),8);
- SelectObject(hdc, GetStockObject(LTGRAY_BRUSH));
- Rectangle(hdc,-1,525,800,555);
- }
- else
- if ( annuler == 1)
- {
- SetTextColor(hdc,0x00008000);
- RoundRect(hdc,290,5,470,35,16,16);
- TextOut(hdc,302,10,TEXT("ANNULATION" ),10);
- RoundRect(hdc,5,55,180,80,16,16);
- SelectObject(hdc, GetStockObject(NULL_BRUSH));
- TextOut(hdc,20,59,TEXT("RESERVER UN BILLET" ),18);
- RoundRect(hdc,180,55,355,80,16,16);
- TextOut(hdc,195,59,TEXT("ANNULER UN BILLET" ),17);
- SetTextColor(hdc,0x00000000);
- TextOut(hdc,5,151,TEXT("Nom :" ),5);
- TextOut(hdc,168,151,TEXT("Prenom :" ),8);
- SelectObject(hdc, GetStockObject(LTGRAY_BRUSH));
- Rectangle(hdc,-1,525,800,555);
- }
- EndPaint(hWnd, &ps);
- break;
- case WM_MOUSEMOVE:
- xpos = LOWORD(lParam); // horizontal position of cursor
- ypos = HIWORD(lParam); // vertical position of cursor
- {
- hdc = GetDC(hWnd);
- SelectObject(hdc,GetStockObject(NULL_BRUSH));
- if ((xpos>=5) && (xpos<=180) && (ypos>=55) && (ypos<=80)) {
- SelectObject(hdc, GetStockObject(HOLLOW_BRUSH));
- SetBkColor(hdc, 0xC2C2C2);
- for (i=0; i<300; i++)
- TextOut(hdc,5+i,530,TEXT(" " ),1);
- SelectObject(hdc, GetStockObject(WHITE_BRUSH));
- SetBkColor(hdc, 0xFFFFFF);
- SetTextColor(hdc,0x00008000);
- RoundRect(hdc,180,55,355,80,16,16);
- TextOut(hdc,195,59,TEXT("ANNULER UN BILLET" ),17);
- SelectObject(hdc, GetStockObject(LTGRAY_BRUSH));
- SetBkColor(hdc, 0xC2C2C2);
- RoundRect(hdc,5,55,180,80,16,16);
- TextOut(hdc,20,59,TEXT("RESERVER UN BILLET" ),18);
- SetTextColor(hdc,0x000000FF);
- TextOut(hdc,5,530,TEXT("Cliquez ICI pour reserver un billet :" ),35);
- // }
- }
- else
- if ((xpos>=180) && (xpos<=355) && (ypos>=55) && (ypos<=80)) {
- SetBkColor(hdc, 0xC2C2C2);
- for (i=0; i<300; i++)
- TextOut(hdc,5+i,530,TEXT(" " ),1);
- SetBkColor(hdc, 0xFFFFFF);
- SelectObject(hdc, GetStockObject(WHITE_BRUSH));
- RoundRect(hdc,5,55,180,80,16,16);
- SetTextColor(hdc,0x00008000);
- TextOut(hdc,20,59,TEXT("RESERVER UN BILLET" ),18);
- SelectObject(hdc, GetStockObject(LTGRAY_BRUSH));
- SetBkColor(hdc, 0xC2C2C2);
- RoundRect(hdc,180,55,355,80,16,16);
- TextOut(hdc,195,59,TEXT("ANNULER UN BILLET" ),17);
- SetTextColor(hdc,0x000000FF);
- TextOut(hdc,5,530,TEXT("Cliquez ICI pour annuler un billet :" ),35);
- // }
- }
- else {
- if (cadre_alloue==FALSE) {
- SetBkColor(hdc, 0xC2C2C2);
- for (i=0; i<300; i++)
- TextOut(hdc,5+i,530,TEXT(" " ),1);
- SetBkColor(hdc, 0xFFFFFF);
- SelectObject(hdc, GetStockObject(WHITE_BRUSH));
- RoundRect(hdc,5,55,180,80,16,16);
- SetTextColor(hdc,0x00008000);
- TextOut(hdc,20,59,TEXT("RESERVER UN BILLET" ),18);
- RoundRect(hdc,180,55,355,80,16,16);
- TextOut(hdc,195,59,TEXT("ANNULER UN BILLET" ),17);
- }
- }
- ReleaseDC(hWnd,hdc);
- }
- break;
- case WM_LBUTTONDOWN:
- xpos = LOWORD(lParam); // horizontal position of cursor
- ypos = HIWORD(lParam); // vertical position of cursor
- {
- hdc = GetDC(hWnd);
- SelectObject(hdc,GetStockObject(NULL_BRUSH));
- if ((xpos>=5) && (xpos<=180) && (ypos>=55) && (ypos<=80))
- {
- SelectObject(hdc, GetStockObject(HOLLOW_BRUSH));
- SetBkColor(hdc, 0xC2C2C2);
- for (i=0; i<300; i++)
- TextOut(hdc,5+i,530,TEXT(" " ),1);
- TextOut(hdc,5,530,TEXT("L'utilisateur a clique sur Reserver :" ),35);
- annuler = 0;
- reserver = 1;
- InvalidateRect(NULL, NULL, FALSE);
- }
- else
- if ((xpos>=180) && (xpos<=355) && (ypos>=55) && (ypos<=80))
- {
- SetBkColor(hdc, 0xC2C2C2);
- for (i=0; i<300; i++)
- TextOut(hdc,5+i,530,TEXT(" " ),1);
- TextOut(hdc,5,530,TEXT("L'utilisateur a clique sur Annuler :" ),35);
- annuler = 1;
- reserver = 0;
- InvalidateRect(NULL, NULL, FALSE);
- }
- }
- break;
- case WM_DESTROY:
- DeleteObject(hpen1);
- DeleteObject(hpen2);
- DeleteObject(hbrush);
- PostQuitMessage(0);
- break;
- default:
- return DefWindowProc(hWnd, message, wParam, lParam);
- }
- return 0;
- }
|
Et ca si ca peut aider a comprendre ce que je fais
 Message édité par touxe le 15-04-2003 à 00:33:00
|