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: 22 años, 9 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(hwndhBitmap);
         }
         break;
      case 
WM_PAINT:
         
hdc BeginPaint(hwnd, &ps);  //obtiene el contexto de dispositivo de la ventana donde queremos dibujar
         
BitBlt(hdcxCenteryCenterbm.bmWidthbm.bmHeightmemDC00SRCCOPY);
         
EndPaint(hwnd, &ps);
         break;
......

void RepintarImagen(HWND hwndHBITMAP hBitmap){
   
HDC tempDC;

   if (
memDC) {
      
SelectObject(memDCmemBitmapOld);
      
DeleteObject(memBitmap);
      
DeleteObject(memDC);
   }

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

   
memBitmapOld SelectObject(memDC,hBitmap);

   
StretchBlt(memDC0,0anchoaltotempDC00bm.bmWidth,bm.bmHeight,SRCCOPY);
   
InvalidateRect(hwnd, &coordsTRUE);

   
ReleaseDC(hwnd,tempDC);


__________________
Bicis nuevas y de segunda mano: Bicibid