Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.7 KiB

  1. #define INITGUID
  2. #include <windows.h>
  3. #include <ddraw.h>
  4. #include "..\ddrawex.h"
  5. int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
  6. LPSTR lpCmdLine, int nCmdShow)
  7. {
  8. CoInitialize(NULL);
  9. IDirectDrawFactory *pFactory;
  10. HRESULT hr = CoCreateInstance(CLSID_DirectDrawFactory, NULL, CLSCTX_INPROC_SERVER, IID_IDirectDrawFactory, (void **)&pFactory);
  11. if (SUCCEEDED(hr))
  12. {
  13. IDirectDraw *pDD;
  14. if (SUCCEEDED(pFactory->CreateDirectDraw(NULL, GetDesktopWindow(), DDSCL_NORMAL, 0, NULL, &pDD))) {
  15. DDSURFACEDESC ddsd;
  16. IDirectDrawSurface *pPrimarySurface;
  17. ddsd.dwSize = sizeof(ddsd);
  18. ddsd.dwFlags = DDSD_CAPS;
  19. ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
  20. if (SUCCEEDED(pDD->CreateSurface(&ddsd, &pPrimarySurface, NULL))) {
  21. IDirectDrawSurface *pSurface;
  22. ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
  23. ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OWNDC;
  24. ddsd.dwHeight = 100;
  25. ddsd.dwWidth = 100;
  26. pDD->CreateSurface(&ddsd, &pSurface, NULL);
  27. HDC hdc;
  28. pSurface->GetDC(&hdc);
  29. TextOut(hdc, 0, 0, "Testing 1..2..3", 15);
  30. IDirectDrawSurface *pFoundSurf;
  31. IDirectDrawDC *pGetDCThingie;
  32. pDD->QueryInterface(IID_IDirectDrawDC, (void **)&pGetDCThingie);
  33. pGetDCThingie->GetSurfaceFromDC(hdc, &pFoundSurf);
  34. RECT r = {0,0,100,100};
  35. pPrimarySurface->Blt(&r, pFoundSurf, &r, DDBLT_WAIT, NULL);
  36. pFoundSurf->ReleaseDC(hdc);
  37. Sleep(3000);
  38. pSurface->Release();
  39. pFoundSurf->Release();
  40. pPrimarySurface->Release();
  41. pGetDCThingie->Release();
  42. }
  43. }
  44. pDD->Release();
  45. }
  46. else
  47. {
  48. MessageBox( NULL, "CCI FAILED!!!!!!!!!", "FUUUUUUUCCCCCCCK", MB_OK );
  49. }
  50. return 0;
  51. }