HRESULT DXGIOutputDuplication::AcquireNextFrame(IDXGISurface1** pDXGISurface, DXGIPointerInfo*& pDXGIPointer) { DXGI_OUTDUPL_FRAME_INFO fi; CComPtr<IDXGIResource> spDXGIResource; HRESULT hr = m_DXGIOutputDuplication->AcquireNextFrame(20, &fi, &spDXGIResource); if(FAILED(hr)) { __L_INFO("m_DXGIOutputDuplication->AcquireNextFrame failed with hr=0x%08x", hr); return hr; } CComQIPtr<ID3D11Texture2D> spTextureResource = spDXGIResource; D3D11_TEXTURE2D_DESC desc; spTextureResource->GetDesc(&desc); D3D11_TEXTURE2D_DESC texDesc; ZeroMemory( &texDesc, sizeof(texDesc) ); texDesc.Width = desc.Width; texDesc.Height = desc.Height; texDesc.MipLevels = 1; texDesc.ArraySize = 1; texDesc.SampleDesc.Count = 1; texDesc.SampleDesc.Quality = 0; texDesc.Usage = D3D11_USAGE_STAGING; texDesc.Format = desc.Format; texDesc.BindFlags = 0; texDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; texDesc.MiscFlags = 0; CComPtr<ID3D11Texture2D> spD3D11Texture2D = NULL; hr = m_D3DDevice->CreateTexture2D(&texDesc, NULL, &spD3D11Texture2D); if(FAILED(hr)) return hr; m_D3DDeviceContext->CopyResource(spD3D11Texture2D, spTextureResource); CComQIPtr<IDXGISurface1> spDXGISurface = spD3D11Texture2D; *pDXGISurface = spDXGISurface.Detach(); // Updating mouse pointer, if visible if(fi.PointerPosition.Visible) { BYTE* pPointerShape = new BYTE[fi.PointerShapeBufferSize]; DXGI_OUTDUPL_POINTER_SHAPE_INFO psi = {}; UINT uiPointerShapeBufSize = fi.PointerShapeBufferSize; hr = m_DXGIOutputDuplication->GetFramePointerShape(uiPointerShapeBufSize, pPointerShape, &uiPointerShapeBufSize, &psi); if(hr == DXGI_ERROR_MORE_DATA) { pPointerShape = new BYTE[uiPointerShapeBufSize]; hr = m_DXGIOutputDuplication->GetFramePointerShape(uiPointerShapeBufSize, pPointerShape, &uiPointerShapeBufSize, &psi); } if(hr == S_OK) { __L_INFO("PointerPosition Visible=%d x=%d y=%d w=%d h=%d type=%d\n", fi.PointerPosition.Visible, fi.PointerPosition.Position.x, fi.PointerPosition.Position.y, psi.Width, psi.Height, psi.Type); if((psi.Type == DXGI_OUTDUPL_POINTER_SHAPE_TYPE_MONOCHROME || psi.Type == DXGI_OUTDUPL_POINTER_SHAPE_TYPE_COLOR || psi.Type == DXGI_OUTDUPL_POINTER_SHAPE_TYPE_MASKED_COLOR) && psi.Width <= 128 && psi.Height <= 128) { // Here we can obtain pointer shape if(pDXGIPointer) { delete pDXGIPointer; } pDXGIPointer = new DXGIPointerInfo(pPointerShape, uiPointerShapeBufSize, fi, psi); pPointerShape = NULL; } DXGI_OUTPUT_DESC outDesc; GetDesc(outDesc); if(pDXGIPointer) { pDXGIPointer->GetFrameInfo().PointerPosition.Position.x = outDesc.DesktopCoordinates.left + fi.PointerPosition.Position.x; pDXGIPointer->GetFrameInfo().PointerPosition.Position.y = outDesc.DesktopCoordinates.top + fi.PointerPosition.Position.y; } } if(pPointerShape) { delete [] pPointerShape; } } return hr; }
HRESULT AsdkSheetSet::List(IAcSmDatabase *pDb) { // List the contents of the sheet set at the command line HRESULT hr; if(!pDb) return E_FAIL; CComPtr<IAcSmEnumPersist> pEnum; CComPtr<IAcSmPersist> pItem; pDb->GetEnumerator(&pEnum); pEnum->Reset(); acutPrintf("\n ******** BEGIN ************** "); acutPrintf("\n"); while(SUCCEEDED(hr=pEnum->Next(&pItem)) && pItem) { CComQIPtr<IAcSmSubset> pSubSet = pItem; CComQIPtr<IAcSmSheet> pSheet = pItem; CComQIPtr<IAcSmCustomPropertyBag> pPropertyBag = pItem; CComBSTR bstrTypeName; char name[80]; char desc[255]; if (pSubSet != NULL) { BSTR bstrSubsetName; BSTR bstrSubSetDesc; pSubSet->GetName(&bstrSubsetName); pSubSet->GetDesc(&bstrSubSetDesc); strcpy(name, _bstr_t(bstrSubsetName).operator char*()); strcpy(desc, _bstr_t(bstrSubSetDesc).operator char*()); acutPrintf("\n -------------------------------"); acutPrintf("\n SubSet Name : %s", name); acutPrintf("\n Description : %s", desc); acutPrintf("\n -------------------------------"); } else if(pSheet != NULL) { BSTR bstrSheetName; BSTR bstrSheetDesc; BSTR bstrLayoutName; BSTR bstrFileName; char layout[80]; char fileName[255]; CComPtr<IAcSmAcDbLayoutReference> pLayoutRef; pSheet->GetName(&bstrSheetName); pSheet->GetDesc(&bstrSheetDesc); pSheet->GetLayout(&pLayoutRef); if (pLayoutRef) { pLayoutRef->GetName(&bstrLayoutName); pLayoutRef->GetFileName(&bstrFileName); } strcpy(name, _bstr_t(bstrSheetName).operator char*()); strcpy(desc, _bstr_t(bstrSheetDesc).operator char*()); strcpy(layout, _bstr_t(bstrLayoutName).operator char*()); strcpy(fileName, _bstr_t(bstrFileName).operator char*()); acutPrintf("\n Sheet : %s", name); acutPrintf("\n Sheet Description : %s", desc); acutPrintf("\n Layout Name : %s", layout); acutPrintf("\n FileName Name : %s", fileName); acutPrintf("\n"); } else if(pPropertyBag != NULL) { CComVariant val; CComQIPtr<IAcSmEnumProperty> pEnumProp; pPropertyBag->GetPropertyEnumerator(&pEnumProp); HRESULT hr; BSTR propName; BSTR propValue; pEnumProp->Reset(); CComQIPtr<IAcSmCustomPropertyValue> pValue; while(pEnumProp->Next(&propName,&pValue)== S_OK) { strcpy(name, _bstr_t(propName).operator char*()); acutPrintf("\n Property Name : %s", name); pValue->GetValue(&val); if(V_VT(&val)==VT_BSTR) { // This Value is never VT_BSTR so what is wrong here??? _bstr_t propValue = val; strcpy(desc, _bstr_t(propValue).operator char*()); acutPrintf("\n Property Value : %s", desc); } } } } acutPrintf("\n"); acutPrintf("\n ******** END ************** "); return S_OK; }