   Bitmap is filling the window - need it 'normal' size
  I am trying to display a 73 x 97 bitmap of a playing card using ddraw in window mode (as opposed to full screen). The only problem is that the image is displayed covering the entire window instead of the dimensions that I specify. I have studied the code and I can't see where it is loaded as a background image. I was so happy once the image finally appeared! It would be great to have it display at the correct size.Here's my ddraw code (well, it's hardly 'mine' as I have gotten lots of help with this)// Initialise DirectDraw and go to full screen mode.bool InitDirectDraw(HWND hwnd){  // create the main DirectDraw object  DirectDrawCreateEx( NULL, (VOID**)&lpDD, IID_IDirectDraw7, NULL );  // using DDSCL_NORMAL means we will coexist with GDI    ddrval = lpDD->SetCooperativeLevel( hwnd, DDSCL_NORMAL );    if( ddrval != DD_OK )    {   lpDD->Release();   return(false);    }    memset( &ddsd, 0, sizeof(ddsd) );    ddsd.dwSize = sizeof( ddsd );    ddsd.dwFlags = DDSD_CAPS;    ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;    // The primary surface is not a page flipping surface this time    ddrval = lpDD->CreateSurface( &ddsd, &lpPrimary, NULL );    if( ddrval != DD_OK )    {   lpDD->Release();   return(false);    }    // Create a clipper to ensure that our drawing stays inside our window    ddrval = lpDD->CreateClipper( 0, &lpddclipper, NULL );    if( ddrval != DD_OK )    {   lpPrimary->Release();   lpDD->Release();   return(false);    }    // setting it to our hwnd gives the clipper the coordinates from our window    ddrval = lpddclipper->SetHWnd( 0, hwnd );    if( ddrval != DD_OK )    {   lpddclipper-> Release();   lpPrimary->Release();   lpDD->Release();   return(false);    }    // attach the clipper to the primary surface    ddrval = lpPrimary->SetClipper( lpddclipper );    if( ddrval != DD_OK )    {   lpddclipper-> Release();   lpPrimary->Release();   lpDD->Release();   return(false);    }memset( &ddsd, 0, sizeof(ddsd) );    ddsd.dwSize = sizeof( ddsd );    ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;    ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;    ddsd.dwWidth = 73;    ddsd.dwHeight = 97;    // create the backbuffer separately    ddrval = lpDD->CreateSurface( &ddsd, &lpBackBuffer, NULL );    if( ddrval != DD_OK )    {   lpddclipper-> Release();   lpPrimary->Release();   lpDD->Release();   return(false);    }    return(true);}/* * Creates a DirectDraw palette for a given bitmap on disk. * The parameter szBitmap is the file name of the bitmap. * */IDirectDrawPalette * DDLoadPalette(IDirectDraw *pdd, LPCSTR szBitmap){    IDirectDrawPalette* ddpal;    int i;    int n;    int fh;    PALETTEENTRY ape[256];    if (szBitmap && (fh = _lopen(szBitmap, OF_READ)) != -1)    {   BITMAPFILEHEADER bf;   BITMAPINFOHEADER bi;   _lread(fh, &bf, sizeof(bf));   _lread(fh, &bi, sizeof(bi));   _lread(fh, ape, sizeof(ape));   _lclose(fh);   if (bi.biSize != sizeof(BITMAPINFOHEADER))  n = 0;   else if (bi.biBitCount > 8)  n = 0;   else if (bi.biClrUsed == 0)  n = 1 << bi.biBitCount;   else  n = bi.biClrUsed; // // a DIB color table has its colors stored BGR not RGB // so flip them around. //   for(i=0; i<n; i++ )   {  BYTE r = ape.peRed;  ape.peRed = ape.peBlue;  ape.peBlue = r;   }    }    if (pdd->CreatePalette(DDPCAPS_8BIT, ape, &ddpal, NULL) != DD_OK)    {   return NULL;    } else {   return ddpal;    }}/* * Creates a DirectDraw Surface of a specified size * This surface will be in video memory if enough is * available, otherwise it will be created in system memory */IDirectDrawSurface * CreateOffScreenSurface(IDirectDraw *pdd, int dx, int dy){    DDSURFACEDESC ddsd;    IDirectDrawSurface *pdds;    //    // create a DirectDrawSurface for this bitmap    //    ZeroMemory(&ddsd, sizeof(ddsd));    ddsd.dwSize = sizeof(ddsd);    ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT |DDSD_WIDTH;    ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;    ddsd.dwWidth = dx;    ddsd.dwHeight = dy;    if (pdd->CreateSurface(&ddsd, &pdds, NULL) != DD_OK)    {   return NULL;    } else {   return pdds;    }}/* * This function copies a previously loaded bitmap into a DirectDraw surface. * Notice that we can obtain a GDI style device context for a * DirectDraw surface, with which to BitBlt the bitmap into the * surface. */HRESULT DDCopyBitmap(IDirectDrawSurface *pdds, HBITMAP hbm, int dx, int dy){    HDC hdcImage;    HDC hdc;    HRESULT hr;    HBITMAP hbmOld;    //    // select bitmap into a memoryDC so we can use it.    //    hdcImage = CreateCompatibleDC(NULL);    hbmOld = (HBITMAP)SelectObject(hdcImage, hbm);    if ((hr = pdds->GetDC(&hdc)) == DD_OK)    {   BitBlt(hdc, 0, 0, dx, dy, hdcImage, 0, 0, SRCCOPY);   pdds->ReleaseDC(hdc);    }    SelectObject(hdcImage, hbmOld);    DeleteDC(hdcImage); return hr;}/* * Function to create an offscreen surface and load a bitmap from * disk into it. The szBitmap field is the filename of the Bitmap. */IDirectDrawSurface * DDLoadBitmap(IDirectDraw *pdd, LPCSTR szBitmap){    HBITMAP hbm;    BITMAP bm;    IDirectDrawSurface *pdds;    // LoadImage has some added functionality in Windows 95 that allows    // you to load a bitmap from a file on disk.    hbm = (HBITMAP)LoadImage(NULL, szBitmap, IMAGE_BITMAP, 0, 0,    LR_LOADFROMFILE|LR_CREATEDIBSECTION);    if (hbm == NULL)   return NULL;    GetObject(hbm, sizeof(bm), &bm); // get size of bitmap   /*    * create a DirectDrawSurface for this bitmap    * source to function CreateOffScreenSurface() follows immediately    */bm.bmWidth =  97 ;bm.bmHeight = 73 ;    pdds = CreateOffScreenSurface(pdd, bm.bmWidth, bm.bmHeight);    if (pdds) {   DDCopyBitmap(pdds, hbm, bm.bmWidth, bm.bmHeight);    }    DeleteObject(hbm);    return pdds;} bool Flip(HWND hwnd){    HRESULT ddrval;    RECT rcRectSrc;    RECT rcRectDest;    POINT p;// first we need to figure out where on the primary surface our window lives    p.x = 0; p.y = 0;    ClientToScreen(hwnd, &p);    GetClientRect(hwnd, &rcRectDest);    OffsetRect(&rcRectDest, p.x, p.y);    SetRect(&rcRectSrc, 0, 0, 73, 97);    ddrval = lpPrimary->Blt( &rcRectDest, lpBackBuffer, &rcRectSrc, DDBLT_WAIT, NULL);    return (ddrval == DD_OK);}
  You need to set your dest rectangle to the size of the bitmap, as well. With it set to the size of the client area, it will stretch the source image to fill the destination rectangle.So, just get the top/left values of the dest rect from the client rect, and set the bottom/right values to top+imgheight/left+imgwidth.;  Got it. Isn't it funny how you can stare at a piece of code for hours and completely miss something like that. Makes sense now. This is actually starting to look like a game! Fortunately, the game logic already worked and I have the display logic separated. I'll post it on my site when it's done. I'd really appreciate some feedback.Thanks again for your help.   