AJA NTV2 SDK  18.0.0.2717
NTV2 SDK 18.0.0.2717
ddmm.cpp
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // File: DDMM.cpp
3 //
4 // Desc: DirectShow base classes - implements routines for using DirectDraw
5 // on a multimonitor system.
6 //
7 // Copyright (c) 1995-2001 Microsoft Corporation. All rights reserved.
8 //------------------------------------------------------------------------------
9 
10 
11 #include <streams.h>
12 #include <ddraw.h>
13 #include "ddmm.h"
14 
15 /*
16  * FindDeviceCallback
17  */
18 typedef struct {
19  LPSTR szDevice;
20  GUID* lpGUID;
21  GUID GUID;
22  BOOL fFound;
24 
25 BOOL CALLBACK FindDeviceCallback(__in_opt GUID* lpGUID, __in LPSTR szName, __in LPSTR szDevice, __in LPVOID lParam)
26 {
27  FindDeviceData *p = (FindDeviceData*)lParam;
28 
29  if (lstrcmpiA(p->szDevice, szDevice) == 0) {
30  if (lpGUID) {
31  p->GUID = *lpGUID;
32  p->lpGUID = &p->GUID;
33  } else {
34  p->lpGUID = NULL;
35  }
36  p->fFound = TRUE;
37  return FALSE;
38  }
39  return TRUE;
40 }
41 
42 
43 BOOL CALLBACK FindDeviceCallbackEx(__in_opt GUID* lpGUID, __in LPSTR szName, __in LPSTR szDevice, __in LPVOID lParam, HMONITOR hMonitor)
44 {
45  FindDeviceData *p = (FindDeviceData*)lParam;
46 
47  if (lstrcmpiA(p->szDevice, szDevice) == 0) {
48  if (lpGUID) {
49  p->GUID = *lpGUID;
50  p->lpGUID = &p->GUID;
51  } else {
52  p->lpGUID = NULL;
53  }
54  p->fFound = TRUE;
55  return FALSE;
56  }
57  return TRUE;
58 }
59 
60 
61 /*
62  * DirectDrawCreateFromDevice
63  *
64  * create a DirectDraw object for a particular device
65  */
66 IDirectDraw * DirectDrawCreateFromDevice(__in_opt LPSTR szDevice, PDRAWCREATE DirectDrawCreateP, PDRAWENUM DirectDrawEnumerateP)
67 {
68  IDirectDraw* pdd = NULL;
69  FindDeviceData find;
70 
71  if (szDevice == NULL) {
72  DirectDrawCreateP(NULL, &pdd, NULL);
73  return pdd;
74  }
75 
76  find.szDevice = szDevice;
77  find.fFound = FALSE;
78  DirectDrawEnumerateP(FindDeviceCallback, (LPVOID)&find);
79 
80  if (find.fFound)
81  {
82  //
83  // In 4bpp mode the following DDraw call causes a message box to be popped
84  // up by DDraw (!?!). It's DDraw's fault, but we don't like it. So we
85  // make sure it doesn't happen.
86  //
87  UINT ErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
88  DirectDrawCreateP(find.lpGUID, &pdd, NULL);
89  SetErrorMode(ErrorMode);
90  }
91 
92  return pdd;
93 }
94 
95 
96 /*
97  * DirectDrawCreateFromDeviceEx
98  *
99  * create a DirectDraw object for a particular device
100  */
101 IDirectDraw * DirectDrawCreateFromDeviceEx(__in_opt LPSTR szDevice, PDRAWCREATE DirectDrawCreateP, LPDIRECTDRAWENUMERATEEXA DirectDrawEnumerateExP)
102 {
103  IDirectDraw* pdd = NULL;
104  FindDeviceData find;
105 
106  if (szDevice == NULL) {
107  DirectDrawCreateP(NULL, &pdd, NULL);
108  return pdd;
109  }
110 
111  find.szDevice = szDevice;
112  find.fFound = FALSE;
113  DirectDrawEnumerateExP(FindDeviceCallbackEx, (LPVOID)&find,
115 
116  if (find.fFound)
117  {
118  //
119  // In 4bpp mode the following DDraw call causes a message box to be popped
120  // up by DDraw (!?!). It's DDraw's fault, but we don't like it. So we
121  // make sure it doesn't happen.
122  //
123  UINT ErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
124  DirectDrawCreateP(find.lpGUID, &pdd, NULL);
125  SetErrorMode(ErrorMode);
126  }
127 
128  return pdd;
129 }
streams.h
NULL
#define NULL
Definition: ntv2caption608types.h:19
PDRAWCREATE
HRESULT(* PDRAWCREATE)(IID *, LPDIRECTDRAW *, LPUNKNOWN)
Definition: ddmm.h:20
FindDeviceData::fFound
BOOL fFound
Definition: ddmm.cpp:22
FindDeviceCallbackEx
BOOL CALLBACK FindDeviceCallbackEx(__in_opt GUID *lpGUID, __in LPSTR szName, __in LPSTR szDevice, __in LPVOID lParam, HMONITOR hMonitor)
Definition: ddmm.cpp:43
FindDeviceData::GUID
GUID GUID
Definition: ddmm.cpp:21
DirectDrawCreateFromDeviceEx
IDirectDraw * DirectDrawCreateFromDeviceEx(__in_opt LPSTR szDevice, PDRAWCREATE DirectDrawCreateP, LPDIRECTDRAWENUMERATEEXA DirectDrawEnumerateExP)
Definition: ddmm.cpp:101
PDRAWENUM
HRESULT(* PDRAWENUM)(LPDDENUMCALLBACKA, LPVOID)
Definition: ddmm.h:21
FindDeviceCallback
BOOL CALLBACK FindDeviceCallback(__in_opt GUID *lpGUID, __in LPSTR szName, __in LPSTR szDevice, __in LPVOID lParam)
Definition: ddmm.cpp:25
ddmm.h
DirectDrawCreateFromDevice
IDirectDraw * DirectDrawCreateFromDevice(__in_opt LPSTR szDevice, PDRAWCREATE DirectDrawCreateP, PDRAWENUM DirectDrawEnumerateP)
Definition: ddmm.cpp:66
FindDeviceData::szDevice
LPSTR szDevice
Definition: ddmm.cpp:19
FindDeviceData::lpGUID
GUID * lpGUID
Definition: ddmm.cpp:20
FindDeviceData
Definition: ddmm.cpp:18
DDENUM_ATTACHEDSECONDARYDEVICES
#define DDENUM_ATTACHEDSECONDARYDEVICES
Definition: ddmm.h:17