Ciao a tutti,
sto creando la mia classe per creare rettangoli.
Il compilatore (DEV C++) non da errori, il programma parte ma la linea non viene disegnata.
e poi chiamo la funzione per disegnare il triangolo all'interno dell'handler grafico della finestra del programma.codice:#include <windows.h> class _RECT { public: const static COLORREF redColor = RGB(255,0,0); const static COLORREF blueColor = RGB(0,0,255); const static COLORREF greenColor = RGB(0,255,0); void Draw(HWND hwnd,int x,int y) { for(int i = 0; i < 100; i++) DrawPixel(hwnd,x,y,blueColor); } void DrawPixel(HWND hwnd,int x,int y,COLORREF color=redColor) { if(hwnd == NULL) { exit(0); } HDC hdc = GetDC(hwnd); SetPixel(hdc,x,y,color); ReleaseDC(hwnd,hdc); return; } };
codice:LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) /* handle the messages */ { case WM_PAINT: _RECT my_Rect; my_Rect.Draw(hwnd,100,100); break; case WM_DESTROY: PostQuitMessage (0); /* send a WM_QUIT to the message queue */ break; default: /* for messages that we don't deal with */ return DefWindowProc (hwnd, message, wParam, lParam); } return 0; }

Rispondi quotando