bonjour tout le monde ,
je veux faire une petite application win32 qui permet d'afficher un txte chaque seconde dans un emplacement different du l'ecran g ecrit le code suivant mais ca marche pas , aucun teste n'est affiché.
g crée un WM_CREAT dont g ecrit la fonction SetTimer puis un WM_TIMER ou g ecrit ce qui le programme doit faire à chaque seconde
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
   	PAINTSTRUCT ps;
	HDC hdc;
	//TCHAR szHello[MAX_LOADSTRING];
	//LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
	int x;
	switch (message) 
	{
	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_EXIT:
	         DestroyWindow(hWnd);
	         break;
	        default:
	return DefWindowProc(hWnd, message, wParam, lParam);
	}
	break;
 
	case WM_PAINT:
                    RECT rt;
	    hdc = BeginPaint(hWnd, &ps);
	   // TODO: Add any drawing code here...
	   GetClientRect(hWnd, &rt);
	   EndPaint(hWnd, &ps);
	   break;
	case WM_CREATE:
	   SetTimer(hWnd,1,1000,NULL);
                   break;
	case WM_TIMER :
	    x=rand()%4;
                    switch (x)
	      {
	        case 0:
	       DrawText(hdc,"Raiuno",6, &rt, DT_LEFT);
	       break;
	       case 1:
	       DrawText(hdc,"Raiuno",6, &rt, DT_RIGHT);
	       break;
	      case 2:
DrawText(hdc,"Raiuno",6,&rt,DT_SINGLELINE|DT_RIGHT|DT_BOTTOM);
	       break;
	     defualt :
DrawText(hdc,"RaiUno",6, &rt,DT_SINGLELINE|DT_LEFT|DT_BOTTOM);
			}
	     break;	
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
	return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
j'espere que ce code n'est pa trop long et merci d'avance.