ReactOS  0.4.12-dev-918-g6c6e7b8
helper.cpp
Go to the documentation of this file.
1 #include "ddrawtest.h"
2 
4 {
5  switch (message)
6  {
7  case WM_DESTROY:
8  {
9  PostQuitMessage (0);
10  return 0;
11  } break;
12  }
13 
15 }
16 
18 {
19  WNDCLASS wndclass = {0};
20  wndclass.lpfnWndProc = BasicWindowProc;
21  wndclass.hInstance = GetModuleHandle(NULL);
22  wndclass.lpszClassName = "DDrawTest";
23  RegisterClass(&wndclass);
24 
25  return CreateWindow("DDrawTest", "ReactOS DirectDraw Test", WS_POPUP, 0, 0, 10, 10, NULL, NULL, GetModuleHandle(NULL), NULL);
26 }
27 
29 {
31  LPDIRECTDRAWSURFACE7 Surface;
32  HWND hwnd;
33 
34  // Create DDraw Object
35  if (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw7, NULL) != DD_OK)
36  {
37  printf("ERROR: Failed to set up ddraw\n");
38  return FALSE;
39  }
40 
41  if(!( hwnd = CreateBasicWindow() ))
42  {
43  printf("ERROR: Failed to create window\n");
44  DirectDraw->Release();
45  return FALSE;
46  }
47 
48  if (DirectDraw->SetCooperativeLevel (hwnd, DDSCL_NORMAL) != DD_OK)
49  {
50  printf("ERROR: Could not set cooperative level\n");
51  DirectDraw->Release();
52  return 0;
53  }
54 
55  // Creat Surface
56  DDSURFACEDESC2 Desc = { 0 };
57  Desc.dwHeight = 200;
58  Desc.dwWidth = 200;
59  Desc.dwSize = sizeof (DDSURFACEDESC2);
62 
63  if(DirectDraw->CreateSurface(&Desc, &Surface, NULL) != DD_OK)
64  {
65  printf("ERROR: Faild to create Surface\n");
66  return FALSE;
67  }
68 
69  DirectDraw->Release();
70 
71  *pSurface = Surface;
72  return TRUE;
73 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
Definition: tftpd.h:59
DWORD dwFlags
Definition: ddraw.h:1153
#define TRUE
Definition: types.h:120
#define CreateWindow
Definition: winuser.h:5620
UINT_PTR WPARAM
Definition: windef.h:207
HRESULT WINAPI DirectDrawCreateEx(LPGUID lpGUID, LPVOID *lplpDD, REFIID id, LPUNKNOWN pUnkOuter)
Definition: main.c:139
WPARAM wParam
Definition: combotst.c:138
BOOL CreateSurface(LPDIRECTDRAWSURFACE7 *pSurface)
Definition: helper.cpp:28
DWORD dwWidth
Definition: ddraw.h:1155
#define DD_OK
Definition: ddraw.h:186
#define DDSD_CAPS
Definition: ddraw.h:208
LRESULT WINAPI BasicWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: helper.cpp:3
unsigned int BOOL
Definition: ntddk_ex.h:94
DDSCAPS2 ddsCaps
Definition: ddraw.h:1188
DWORD dwCaps
Definition: ddraw.h:732
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
#define DDSD_HEIGHT
Definition: ddraw.h:209
_In_ DD_SURFACE_LOCAL * pSurface
Definition: winddi.h:3481
#define WINAPI
Definition: msvc.h:8
DWORD dwSize
Definition: ddraw.h:1152
LPCSTR lpszClassName
Definition: winuser.h:3125
DWORD dwHeight
Definition: ddraw.h:1154
#define DDSD_WIDTH
Definition: ddraw.h:210
LPDIRECTDRAW7 DirectDraw
Definition: create.cpp:3
#define GetModuleHandle
Definition: winbase.h:3641
HINSTANCE hInstance
Definition: winuser.h:3120
#define WS_POPUP
Definition: pedump.c:616
unsigned int UINT
Definition: ndis.h:50
WNDPROC lpfnWndProc
Definition: winuser.h:3117
DWORD * LPDIRECTDRAW7
Definition: vmrender.idl:4
HWND CreateBasicWindow(VOID)
Definition: helper.cpp:17
struct _DDSURFACEDESC2 DDSURFACEDESC2
#define DDSCAPS_OFFSCREENPLAIN
Definition: ddraw.h:255
#define DDSCL_NORMAL
Definition: ddraw.h:535
#define RegisterClass
Definition: winuser.h:5702
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
DWORD * LPDIRECTDRAWSURFACE7
Definition: vmrender.idl:7
#define printf
Definition: config.h:203