Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/06/2008, 05:47
ZeroZ
 
Fecha de Ingreso: junio-2002
Ubicación: España
Mensajes: 348
Antigüedad: 22 años, 9 meses
Puntos: 8
Error al redimensionar ventana WinAPI

Hola, el objetivo es que quiero que se cargue una imagen y siempre quede en medio de la ventana, la imagen la carga bien pero al cambiar el tamaño de la ventana desaparece la imagen, ¿me podeis decir cual es el error? Os pongo la parte de código que corresponde:
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);

         
InvalidateRect(hwndNULLTRUE);
         break;
case 
WM_PAINT:
         
hdc BeginPainthwnd, &ps );  //obtiene el contexto de dispositivo de la ventana donde queremos dibujar
         
BitBlthdcxCenteryCenterbm.bmWidthbm.bmHeightmemDC00SRCCOPY );
         
EndPainthwnd, &ps );
         if (
memDCDeleteObject(memDC);
         break;
case 
WM_COMMAND:
         switch(
LOWORD(wParam)) {
            case 
IDM_OPEN:
               
memset(&fname0sizeof(OPENFILENAME));
               
fname.lStructSize sizeof(OPENFILENAME);
               
fname.hwndOwner hwnd;
               
fname.lpstrFilter = ("Bitmap Files (*.bmp)\0*.bmp\0\0");
               
fname.nFilterIndex 1;
               
fname.lpstrFile fn;
               
fname.nMaxFile sizeof(fn);
               
fname.lpstrFileTitle filename;
               
fname.nMaxFileTitle sizeof(filename)-1;
               
fname.Flags OFN_FILEMUSTEXIST OFN_HIDEREADONLY;

               if(!
GetOpenFileName(&fname))
                  break;

               
hBitmap LoadImage(NULLfnIMAGE_BITMAP00LR_LOADFROMFILE);
               
GetObject(hBitmapsizeof(BITMAP), &bm);

               
xCenter = ((coords.right coords.left)/2) - (bm.bmWidth/2);
               
yCenter = ((coords.bottom coords.top)/2) - (bm.bmHeight/2);

               
hdc GetDC(hwnd);
               
memDC CreateCompatibleDC(hdc);
               
SelectObject(memDChBitmap);

               
InvalidateRect(hwndNULLFALSE);
               break; 
Gracias
__________________
Bicis nuevas y de segunda mano: Bicibid