WHDefProcess.cpp
上传用户:cydong117
上传日期:2009-11-10
资源大小:638k
文件大小:2k
源码类别:

模拟服务器

开发平台:

Visual C++

  1. #include "StdAfx.h"
  2. CWHDefProcess::CWHDefProcess()
  3. {
  4. m_pxDXGWnd = (CWHDXGraphicWindow*)GetDXGWindowPtr();
  5. assert(m_pxDXGWnd);
  6. }
  7. CWHDefProcess::~CWHDefProcess()
  8. {
  9. }
  10. HRESULT CWHDefProcess::Clear(DWORD dwColor)
  11. {
  12.     DDBLTFX ddbltfx;
  13.     if (NULL == ((CWHDXGraphicWindow*)m_pxDXGWnd)->GetBackBuffer())
  14. {
  15.         return E_POINTER;
  16. }
  17.     ZeroMemory(&ddbltfx, sizeof(ddbltfx));
  18.     ddbltfx.dwSize      = sizeof(ddbltfx);
  19.     ddbltfx.dwFillColor = dwColor;
  20.     return (((CWHDXGraphicWindow*)m_pxDXGWnd)->GetBackBuffer())->Blt(NULL, NULL, NULL, DDBLT_COLORFILL, &ddbltfx);
  21. }
  22. VOID CWHDefProcess::ShowStatus(INT nStartX, INT nStartY)
  23. {
  24.     TCHAR szBuff[MAX_PATH];
  25.     static DWORD dwFPS  = 0;
  26.     static DWORD dwLastTime = 0;
  27.     static DWORD dwFrames = 0;
  28.     DWORD dwTime = timeGetTime();
  29.     ++dwFrames;
  30.     if ( dwTime - dwLastTime > 1000 )
  31.     {
  32.         dwFPS      = dwFrames / ( (dwTime - dwLastTime) / 1000 );
  33.         dwLastTime = dwTime;
  34.         dwFrames   = 0;
  35.     }
  36.     sprintf(szBuff, "FPS : %d", dwFPS);
  37. ((CWHDXGraphicWindow*)m_pxDXGWnd)->PutsHan(((CWHDXGraphicWindow*)m_pxDXGWnd)->GetBackBuffer(), nStartX, nStartY, RGB(250, 250, 250), RGB(0, 0, 0), szBuff);
  38. }
  39. LRESULT CWHDefProcess::DefMainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  40. {
  41. switch ( uMsg )
  42. {
  43. case WM_KEYDOWN:
  44. switch ( wParam )
  45. {
  46. case VK_ESCAPE:
  47. // SendMessage(((CWHDXGraphicWindow*)m_pxDXGWnd)->GetSafehWnd(), WM_DESTROY, wParam, lParam);
  48. break;
  49. }
  50. break;
  51. default:
  52. break;
  53. }
  54. return ((CWHDXGraphicWindow*)m_pxDXGWnd)->MainWndProcDXG(hWnd, uMsg, wParam, lParam);
  55. }