SoloCodigo
		Programación General => C/C++ => Visual C++ => Mensaje iniciado por: darkoweb en Martes  9 de Marzo de 2010, 13:24
		
			
			- 
				Necesito ayuda. Estoy haciendo un programa en el que se introduzcan el codigo RGB de un color en 3 controles edit y se pinte un rectangulo del color seleccionado (al pulsar en un button). Para cojer el texto del control edit utilizo un GetWindowText, y para pasar el texto del edit a int (para poner el color en la brocha) uso un atoi. El problema es que el atoi (solo el atoi) me da error. No se si lo estoy utilizando bien o no. A continuación os pongo el codigo (no el codigo del programa entero, si no solo el WM_COMMAND):
 
 case WM_COMMAND :
 
 switch(LOWORD(wParam))
 {
 case 1:
 
 i2 = GetWindowTextLength (b2);
 i2 = i2 + 1;
 GetWindowText (b2, color1, i2);
 
 i3 = GetWindowTextLength (b3);
 i3 = i3 + 1;
 GetWindowText (b3, color2, i3);
 
 i4 = GetWindowTextLength (b4);
 i4 = i4 + 1;
 GetWindowText (b4, color3, i4);
 
 //PINTAR RECTANGULO DE COLOR
 
 
 c1 = atoi(color1);
 c2 = atoi(color2);
 c3 = atoi(color3);
 
 
 hdc = GetDC (hwnd);
 GetClientRect (hwnd, &rect) ;
 hbrush = CreateSolidBrush (RGB (c1, c2, c3));
 SelectObject (hdc, hbrush);
 Rectangle (hdc, 70, 150, 170, 200);
 DeleteObject (hbrush);
 EndPaint (hwnd, &ps) ;
 
 
 break;
 }
 
 return 0;
 
 
 
 
 Y aquí os pongo como e definido las variables:
 
 
 HDC         hdc ;
 PAINTSTRUCT ps ;
 RECT        rect ;
 static HWND b1;
 static HWND b2;
 static HWND b3;
 static HWND b4;
 HBRUSH hbrush;
 
 static LPSTR color1;
 static LPSTR color2;
 static LPSTR color3;
 static int i1, i2, i3, i4;
 static int c1, c2, c3;
 
 
 
 ¡Muchas gracias!