   lpBackBuffer is NULL
  Hi again. Ok, this one has me stumped. In the following code,   lpPrimary->GetAttachedSurface(&ddsd.ddsCaps, &lpBackBuffer);lpbackBuffer keeps coming back NULL. I think it has something to do with the dwcaps not being set up correctly, but I can't get it to work. Can someone see the error here?void InitDirectDraw(){// Create the DirectDraw object, through which we will create surfaces.DirectDrawCreateEx(NULL, (void **)&lpDD, IID_IDirectDraw7, NULL);// Set the co-operative level.lpDD->SetCooperativeLevel(hwnd, DDSCL_NORMAL );// Set the display mode.lpDD->SetDisplayMode(500, 300, 16, 0, 0);DDSURFACEDESC2ddsd;// Create the primary surface with two back buffers.ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));ddsd.dwSize = sizeof(DDSURFACEDESC2);ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX ;ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;// Make our off-screen surface 320x240ddsd.dwWidth = 320;ddsd.dwHeight = 240;// Create an offscreen surfaceddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;ddsd.dwBackBufferCount = 2;lpDD->CreateSurface(&ddsd, &lpPrimary, NULL);// Get the back buffer pointer, to which we will do all drawing.ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;lpPrimary->GetAttachedSurface(&ddsd.ddsCaps, &lpBackBuffer);// Load our background.lpA = DDLoadBitmap(lpDD, "sc.bmp", 0, 0);}
  There are a few problems here.1 - I don't think you can set the display mode to an unsupported resolution. You're calling SetDisplayMode with a resolution of 500x300. I don't know of any video card that supports that resolution.2 - First you set dwCaps to DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX. Then, a few lines down you overwrite that with DDSCAPS_OFFSCREENPLAIN before you create the surface. So, you're "primary surface" is really just an offscreen plain surface.3 - You are (attempting) to set the display mode to 500x300, but your offscreen surface (when you fix that bit of code) is 320x240. Is that really what you intended to do?   ;  My intent is to have a simple window in which to display some bitmaps, but evidently there is some disconnect with the intent and the results! Issue #1: SetDisplayMode() can't match my current system settings even when I lpDD->SetDisplayMode(1152, 864, 32, 0, 0) which are my current settings.Issue #2: I'm not sure of the caps and flag settings that are required for what I want to do.Do I need to declare a separate DDSURFACEDESC2 instance for the back buffer?   ;  If you want windowed mode, then do not call SetDisplayMode. That only applies to fullscreen mode.Also, in windowed mode, you don't have an actual backbuffer, so you can't create your primary surface as complex and specify a backbuffer count. You have to create an offscreen plain surface to act as the backbuffer and blit it to the primary surface each frame. Also as a result, you can't get the backbuffer by calling GetAttachedSurface, since there is none for windowed mode (that's why you need to create the offscreen surface).You might want to read this article. It covers setting up DirectDraw in both fullscreen and windowed modes. It should help you get your code working.;  Finally! The article was very helpful. While I still have a lot of code to study, at least I was able to get my card bmp to display in the window. I'm making a blackjack game. The console version works great so I wanted to take the next step to add 2D graphics. After that, I'm going 3D! - ok, back to reality - Thanks again for all your help.   ;  Your welcome. Good luck with your project.