设为首页 加入收藏

TOP

Win32 SDK 打砖块游戏(二)
2013-02-08 14:31:29 来源: 作者: 【 】 浏览:1652
Tags:Win32  SDK  砖块 游戏

 
  /* WINMAIN *******************************************************************************/

  int WINAPI WinMain(HINSTANCE hinstance,

  HINSTANCE hprevinstance,

  LPSTR lpcmdline,

  int ncmdshow)

  {

  WNDCLASS    winclass;

  HWND        hwnd;

  MSG         msg;

  HDC         hdc;

  PAINTSTRUCT ps;

  /* CS_DBLCLKS Specifies that the window should be notified of double clicks with

  * WM_xBUTTONDBLCLK messages

  * CS_OWNDC标志,属于此窗口类的窗口实例都有自己的DC(称为私有DC),私有DC仅属于该窗口实例,

  * 所以程序只需要调用一次GetDC或BeginPaint获取DC,系统就为窗口初始化一个DC,并且保存程序

  * 对其进行的改变。ReleaseDC和EndPaint函数不再需要了,因为其他程序无法访问和改变私有DC.

  */

  winclass.style          = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;

  winclass.lpfnWndProc    = WindowProc;

  winclass.cbClsExtra     = 0;

  winclass.cbWndExtra     = 0;

  winclass.hInstance      = hinstance;

  winclass.hIcon          = LoadIcon(NULL, IDI_APPLICATION);

  winclass.hCursor        = LoadCursor(NULL, IDC_ARROW);

  winclass.hbrBackground  = (HBRUSH)GetStockObject(BLACK_BRUSH);

  winclass.lpszMenuName   = NULL;

  winclass.lpszClassName  = WINDOW_CLASS_NAME;

  // register the window class

  if (!RegisterClass(&winclass))

  return 0;

  // Create the window, note the use of WS_POPUP

  hwnd = CreateWindow(

  WINDOW_CLASS_NAME,          // class

  TEXT("WIN32 Game Console"), // title

  WS_OVERLAPPEDWINDOW,        // style

  0, 0,                       // initial x, y

  WINDOW_WIDTH,               // initial width

  WINDOW_HEIGHT,              // initial height

  NULL,                       // handle to parent

  NULL,                       // handle to menu

  hinstance,                  // instance

  NULL);                      // creation parms

  if (! hwnd)

  return 0;

  ShowWindow(hwnd, ncmdshow);

  UpdateWindow(hwnd);

  // hide mouse

  //ShowCursor(FALSE);

  // save the window handle and instance in a global

  main_window_handle  = hwnd;

  main_instance       = hinstance;

  // perform all game console specific initialization

  //Game_Init();

  // enter main event loop

  while (1)

  {

  if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))

  {

  // test if this is a quit msg

  if (msg.message == WM_QUIT)

  break;

  // translate any accelerator keys

  TranslateMessage(&msg);

  // send the message to the window proc

  DispatchMessage(&msg);

  }

  // main game processing goes here

  //Game_Main();

  }

  // shutdown game and release all resources

  //Game_Shutdown();

  // show mouse

  //ShowCursor(TRUE);

  // return to windows like this

  return (msg.wParam);

  }

          

首页 上一页 1 2 3 4 5 6 7 下一页 尾页 2/8/8
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇显示非模式对话框实例 下一篇将integer的bit位翻转

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: