
gasougasou
|
moi en fait au départ je faisais comme ca : static int i =0 ; int j =0 ; char buf[20]; char buf1[20]; LRESULT CALLBACK MainProc(HWND Dlg,UINT message,WPARAM wParam,LPARAM lParam); //LRESULT CALLBACK MainProc1(HWND hWnd1, UINT mes1, WPARAM wParam1, LPARAM lParam1) ; int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HWND hWnd; HWND hWnd1; WNDCLASSEX principale; principale.cbSize=sizeof(WNDCLASSEX); principale.style=CS_HREDRAW|CS_VREDRAW; principale.lpfnWndProc=MainProc; principale.cbClsExtra=0; principale.cbWndExtra=0; principale.hInstance=hInstance; principale.hIcon=LoadIcon(NULL,IDI_APPLICATION); principale.hCursor=LoadCursor(NULL,IDC_ARROW); principale.hbrBackground=reinterpret_cast<HBRUSH>(COLOR_WINDOW+1); principale.lpszMenuName=NULL; principale.lpszClassName="std"; principale.hIconSm=LoadIcon(NULL,IDI_APPLICATION); RegisterClassEx(&principale); // HWND hWnd; hWnd=CreateWindowEx( WS_EX_CLIENTEDGE, "std", "Controle des données", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 250, 200, NULL, NULL, hInstance, NULL ); ShowWindow(hWnd,SW_SHOW); // SetTimer(hWnd,NULL,10,NULL); WNDCLASSEX principale1; principale1.cbSize=sizeof(WNDCLASSEX); principale1.style=CS_HREDRAW|CS_VREDRAW; principale1.lpfnWndProc=MainProc; principale1.cbClsExtra=0; principale1.cbWndExtra=0; principale1.hInstance=hInstance; principale1.hIcon=LoadIcon(NULL,IDI_APPLICATION); principale1.hCursor=LoadCursor(NULL,IDC_ARROW); principale1.hbrBackground=reinterpret_cast<HBRUSH>(COLOR_WINDOW+1); principale1.lpszMenuName=NULL; principale1.lpszClassName="std"; principale1.hIconSm=LoadIcon(NULL,IDI_APPLICATION); RegisterClassEx(&principale1); //HWND hWnd1; hWnd1=CreateWindowEx( WS_EX_CLIENTEDGE, "std", "WebCam", WS_OVERLAPPEDWINDOW, 160, 100, 250, 200, hWnd, NULL, hInstance, NULL ); ShowWindow(hWnd1,SW_SHOW); MSG msg; while(GetMessage(&msg,NULL,0,0)==TRUE) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; } LRESULT CALLBACK MainProc(HWND hWnd, UINT mes, WPARAM wParam, LPARAM lParam) { HDC hDC; PAINTSTRUCT paintst; switch (mes) { case WM_PAINT: HFONT hFont; hFont=CreateFont(20,0,0,0,700,FALSE,FALSE,FALSE,0,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,"Comic Sans MS"); hDC=BeginPaint(hWnd,&paintst); SelectObject(hDC,hFont); sprintf(buf,"%d",i); sprintf(buf1,"%d",j) ; TextOut(hDC,0,0,buf,strlen(buf)); TextOut(hDC,0,20,buf1,strlen(buf1)) ; EndPaint(hWnd,&paintst); DeleteObject(hFont); return 0; case WM_KEYDOWN: switch (wParam) { case VK_M: i++ ; RedrawWindow(hWnd,NULL,NULL,RDW_ERASE|RDW_INVALIDATE|RDW_ERASENOW|RDW_NOCHILDREN); hFont=CreateFont(20,0,0,0,700,FALSE,FALSE,FALSE,0,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,"Comic Sans MS"); hDC=BeginPaint(hWnd,&paintst); SelectObject(hDC,hFont); sprintf(buf,"%d",i); sprintf(buf1,"%d",j) ; TextOut(hDC,0,0,buf,strlen(buf)); TextOut(hDC,0,20,buf1,strlen(buf1)) ; EndPaint(hWnd,&paintst); DeleteObject(hFont); return 0; case VK_L: i-- ; RedrawWindow(hWnd,NULL,NULL,RDW_ERASE|RDW_INVALIDATE|RDW_ERASENOW|RDW_NOCHILDREN); hFont=CreateFont(20,0,0,0,700,FALSE,FALSE,FALSE,0,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,"Comic Sans MS"); hDC=BeginPaint(hWnd,&paintst); SelectObject(hDC,hFont); sprintf(buf,"%d",i); sprintf(buf1,"%d",j) ; TextOut(hDC,0,0,buf,strlen(buf)); TextOut(hDC,0,20,buf1,strlen(buf1)) ; EndPaint(hWnd,&paintst); DeleteObject(hFont); return 0; case VK_K: default: return DefWindowProc(hWnd, mes, wParam, lParam); } return 0 ; case WM_DESTROY: PostQuitMessage(0); return 0; default: return DefWindowProc(hWnd, mes, wParam, lParam); } } et j'arrive pas a avoir un changement simultané ds les 2 fenetres
|