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(hwnd, NULL, TRUE);
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 );
if (memDC) DeleteObject(memDC);
break;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDM_OPEN:
memset(&fname, 0, sizeof(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(NULL, fn, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
GetObject(hBitmap, sizeof(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(memDC, hBitmap);
InvalidateRect(hwnd, NULL, FALSE);
break;