一段好的代码:
/*==========================================================================
*
* Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
*
* File: ddex2.cpp
* Content: Direct Draw example program 2. Adds functionality to
* example program 1. Changes the video mode to 640x480x8.
* Reads a bitmap file from disk and copies it into the
* back buffer and then slowly flips between the primary
* surface and the back buffer. Press F12 to exit the program.
*
***************************************************************************/
#define NAME "DDExample2"
#define TITLE "Direct Draw Example 2"
/*
* doInit - do work required for every instance of the application:
* create the window, initialize data
*/
static BOOL doInit( HINSTANCE hInstance, int nCmdShow )
{
HWND hwnd;
WNDCLASS wc;
DDSURFACEDESC ddsd;
DDSCAPS ddscaps;
HRESULT ddrval;