Ver Mensaje Individual
  #2 (permalink)  
Antiguo 11/06/2008, 07:37
ZeroZ
 
Fecha de Ingreso: junio-2002
Ubicación: España
Mensajes: 348
Antigüedad: 24 años, 4 meses
Puntos: 8
Respuesta: Error al redimensionar ventana WinAPI

Arreglado, lo dejo por si a alguien le hace falta:

Código PHP:
 case WM_SIZE:
         
GetClientRect(hwnd, &coords); // obtenemos las coordenadas de la ventana
         
xCenter = ((coords.right - coords.left)/2) - (bm.bmWidth/2);
         
yCenter = ((coords.bottom - coords.top)/2) - (bm.bmHeight/2);
         if(
hBitmap){
            
RepintarImagen(hwnd, hBitmap);
         }
         break;
      case 
WM_PAINT:
         
hdc = BeginPaint(hwnd, &ps);  //obtiene el contexto de dispositivo de la ventana donde queremos dibujar
         
BitBlt(hdc, xCenter, yCenter, bm.bmWidth, bm.bmHeight, memDC, 0, 0, SRCCOPY);
         
EndPaint(hwnd, &ps);
         break;
......

void RepintarImagen(HWND hwnd, HBITMAP hBitmap){
   
HDC tempDC;

   if (
memDC) {
      
SelectObject(memDC, memBitmapOld);
      
DeleteObject(memBitmap);
      
DeleteObject(memDC);
   }

   
tempDC = GetDC(hwnd);
   
memDC = CreateCompatibleDC(tempDC);

   
memBitmapOld = SelectObject(memDC,hBitmap);

   
StretchBlt(memDC, 0,0, ancho, alto, tempDC, 0, 0, bm.bmWidth,bm.bmHeight,SRCCOPY);
   
InvalidateRect(hwnd, &coords, TRUE);

   
ReleaseDC(hwnd,tempDC);

} 
__________________
Bicis nuevas y de segunda mano: Bicibid