api
אני מעוניין לצייר ריבוע על המסך שנע מצד שמאל לצד ימין. כתבתי קוד ב api שמשום מה לא עובד. הריבוע כל הזמן גדל. אם מישהו יודע טוב api אשמח לרעיונות. הנה הקוד: LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc ; PAINTSTRUCT ps ; RECT rect ; HBRUSH hbr; static int x,y; static int x1=0; switch (message) { case WM_SIZE: x=LOWORD(lParam); y=HIWORD(lParam); return 0; case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ; hbr=CreateSolidBrush(RGB(255,0,0)); SelectObject(hdc,hbr); Rectangle(hdc,x1,y/2,x/6,y/4); x1=x1+200; Sleep(1000); EndPaint (hwnd,&ps) ; DeleteObject(hbr); InvalidateRect(hwnd,NULL,TRUE); return 0 ;
אני מעוניין לצייר ריבוע על המסך שנע מצד שמאל לצד ימין. כתבתי קוד ב api שמשום מה לא עובד. הריבוע כל הזמן גדל. אם מישהו יודע טוב api אשמח לרעיונות. הנה הקוד: LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc ; PAINTSTRUCT ps ; RECT rect ; HBRUSH hbr; static int x,y; static int x1=0; switch (message) { case WM_SIZE: x=LOWORD(lParam); y=HIWORD(lParam); return 0; case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ; hbr=CreateSolidBrush(RGB(255,0,0)); SelectObject(hdc,hbr); Rectangle(hdc,x1,y/2,x/6,y/4); x1=x1+200; Sleep(1000); EndPaint (hwnd,&ps) ; DeleteObject(hbr); InvalidateRect(hwnd,NULL,TRUE); return 0 ;