当前位置: 首页>>代码示例>>C++>>正文


C++ FAILED函数代码示例

本文整理汇总了C++中FAILED函数的典型用法代码示例。如果您正苦于以下问题:C++ FAILED函数的具体用法?C++ FAILED怎么用?C++ FAILED使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了FAILED函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LOCKWRITE

//*****************************************************************************
// Using the existing RegMeta and reopen with another chuck of memory. Make sure that all stgdb
// is still kept alive.
//*****************************************************************************
HRESULT RegMeta::ReOpenWithMemory(
    LPCVOID     pData,                  // [in] Location of scope data.
    ULONG       cbData,                 // [in] Size of the data pointed to by pData.
    DWORD       dwReOpenFlags)           // [in] ReOpen flags
{
    HRESULT hr = NOERROR;

    // Only allow the ofCopyMemory and ofTakeOwnership flags 
    if (dwReOpenFlags != 0 && ((dwReOpenFlags & (~(ofCopyMemory|ofTakeOwnership))) > 0))
        return E_INVALIDARG;

    LOCKWRITE();

    
    // put the current m_pStgdb to the free list
    m_pStgdb->m_pNextStgdb = m_pStgdbFreeList;
    m_pStgdbFreeList = m_pStgdb;
    m_pStgdb = new (nothrow) CLiteWeightStgdbRW;
    IfNullGo( m_pStgdb );
    IfFailGo( OpenExistingMD(0 /* szFileName */, const_cast<void*>(pData), cbData, ofReOpen|dwReOpenFlags /* flags */) );

#ifdef FEATURE_METADATA_INTERNAL_APIS
    // We've created a new Stgdb, but may still have an Internal Importer hanging around accessing the old Stgdb.
    // The free list ensures we don't have a dangling pointer, but the 
    // If we have a corresponding InternalInterface, need to clear it because it's now using stale data.
    // Others will need to update their Internal interface to get the new data.
    {
        HRESULT hrIgnore = SetCachedInternalInterface(NULL);
        (void)hrIgnore; //prevent "unused variable" error from GCC
        _ASSERTE(hrIgnore == NOERROR); // clearing the cached interface should always succeed.
    }
#endif //FEATURE_METADATA_INTERNAL_APIS

    // we are done!
ErrExit:
    if (FAILED(hr))
    {
        // recover to the old state
        if (m_pStgdb)
            delete m_pStgdb;
        m_pStgdb = m_pStgdbFreeList;
        m_pStgdbFreeList = m_pStgdbFreeList->m_pNextStgdb;
    }
#ifdef FEATURE_METADATA_RELEASE_MEMORY_ON_REOPEN
    else
    {
        if( !(CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_MD_PreserveDebuggerMetadataMemory)) && IsSafeToDeleteStgdb())
        {
            // now that success is assured, delete the old block of memory
            // This isn't normally a safe operation because we would have given out
            // internal pointers to the memory. However when this feature is enabled
            // we track calls that might have given out internal pointers. If none
            // of the APIs were ever called then we can safely delete.
            CLiteWeightStgdbRW* pStgdb = m_pStgdbFreeList;
            m_pStgdbFreeList = m_pStgdbFreeList->m_pNextStgdb;
            delete pStgdb;
        }

        MarkSafeToDeleteStgdb(); // As of right now, no APIs have given out internal pointers
                                 // to the newly allocated stgdb
    }
#endif

    return hr;
} // RegMeta::ReOpenWithMemory
开发者ID:0-wiz-0,项目名称:coreclr,代码行数:69,代码来源:regmeta.cpp

示例2: SAFE_RELEASE

//
// D3DSkyNode9::VOnRestore				- 3rd Edition, Chapter 14, page 500
//
HRESULT D3DSkyNode9::VOnRestore(Scene *pScene)
{

	// Call the base class's restore
	SceneNode::VOnRestore(pScene);

	m_camera = pScene->GetCamera();					// added post press!

	m_numVerts = 20;

	SAFE_RELEASE(m_pVerts);
    if( FAILED( DXUTGetD3D9Device()->CreateVertexBuffer( 
		m_numVerts*sizeof(D3D9Vertex_ColoredTextured),
		D3DUSAGE_WRITEONLY, D3D9Vertex_ColoredTextured::FVF,
        D3DPOOL_MANAGED, &m_pVerts, NULL ) ) )
    {
        return E_FAIL;
    }

    // Fill the vertex buffer. We are setting the tu and tv texture
    // coordinates, which range from 0.0 to 1.0
    D3D9Vertex_ColoredTextured* pVertices;
    if( FAILED( m_pVerts->Lock( 0, 0, (void**)&pVertices, 0 ) ) )
        return E_FAIL;

	// Loop through the grid squares and calc the values
	// of each index. Each grid square has two triangles:
	//
	//		A - B
	//		| / |
	//		C - D

	D3D9Vertex_ColoredTextured skyVerts[4];
	D3DCOLOR skyVertColor = 0xffffffff;
	float dim = 50.0f;

	skyVerts[0].position = Vec3( dim, dim, dim ); skyVerts[0].color=skyVertColor; skyVerts[0].tu=1; skyVerts[0].tv=0; 
	skyVerts[1].position = Vec3(-dim, dim, dim ); skyVerts[1].color=skyVertColor; skyVerts[1].tu=0; skyVerts[1].tv=0; 
	skyVerts[2].position = Vec3( dim,-dim, dim ); skyVerts[2].color=skyVertColor; skyVerts[2].tu=1; skyVerts[2].tv=1; 
	skyVerts[3].position = Vec3(-dim,-dim, dim ); skyVerts[3].color=skyVertColor; skyVerts[3].tu=0; skyVerts[3].tv=1; 

	Vec3 triangle[3];
	triangle[0] = Vec3(0.f,0.f,0.f);
	triangle[1] = Vec3(5.f,0.f,0.f);
	triangle[2] = Vec3(5.f,5.f,0.f);

	Vec3 edge1 = triangle[1]-triangle[0];
	Vec3 edge2 = triangle[2]-triangle[0];

	Vec3 normal;
	normal = edge1.Cross(edge2);
	normal.Normalize();

	Mat4x4 rotY;
	rotY.BuildRotationY(GCC_PI/2.0f);
	Mat4x4 rotX;
	rotX.BuildRotationX(-GCC_PI/2.0f);
	
	m_sides = 5;

	for (DWORD side = 0; side < m_sides; side++)
	{
		for (DWORD v = 0; v < 4; v++)
		{
			Vec4 temp;
			if (side < m_sides-1)
			{
				temp = rotY.Xform(Vec3(skyVerts[v].position));
			}
			else
			{
				skyVerts[0].tu=1; skyVerts[0].tv=1; 
				skyVerts[1].tu=1; skyVerts[1].tv=0; 
				skyVerts[2].tu=0; skyVerts[2].tv=1; 
				skyVerts[3].tu=0; skyVerts[3].tv=0; 

				temp = rotX.Xform(Vec3(skyVerts[v].position));
			}
			skyVerts[v].position = Vec3(temp.x, temp.y, temp.z);
		}
		memcpy(&pVertices[side*4], skyVerts, sizeof(skyVerts));
	}

	m_pVerts->Unlock();
	return S_OK;
}
开发者ID:AsbjoernS,项目名称:gamecode4,代码行数:89,代码来源:Sky.cpp

示例3: load_region

static HRESULT load_region(IDirectMusicInstrumentImpl *This, IStream *stream, instrument_region *region, ULONG length)
{
    HRESULT ret;
    DMUS_PRIVATE_CHUNK chunk;

    TRACE("(%p, %p, %p, %u)\n", This, stream, region, length);

    while (length)
    {
        ret = read_from_stream(stream, &chunk, sizeof(chunk));
        if (FAILED(ret))
            return ret;

        length = subtract_bytes(length, sizeof(chunk));

        switch (chunk.fccID)
        {
            case FOURCC_RGNH:
                TRACE("RGNH chunk (region header): %u bytes\n", chunk.dwSize);

                ret = read_from_stream(stream, &region->header, sizeof(region->header));
                if (FAILED(ret))
                    return ret;

                length = subtract_bytes(length, sizeof(region->header));
                break;

            case FOURCC_WSMP:
                TRACE("WSMP chunk (wave sample): %u bytes\n", chunk.dwSize);

                ret = read_from_stream(stream, &region->wave_sample, sizeof(region->wave_sample));
                if (FAILED(ret))
                    return ret;
                length = subtract_bytes(length, sizeof(region->wave_sample));

                if (!(region->loop_present = (chunk.dwSize != sizeof(region->wave_sample))))
                    break;

                ret = read_from_stream(stream, &region->wave_loop, sizeof(region->wave_loop));
                if (FAILED(ret))
                    return ret;

                length = subtract_bytes(length, sizeof(region->wave_loop));
                break;

            case FOURCC_WLNK:
                TRACE("WLNK chunk (wave link): %u bytes\n", chunk.dwSize);

                ret = read_from_stream(stream, &region->wave_link, sizeof(region->wave_link));
                if (FAILED(ret))
                    return ret;

                length = subtract_bytes(length, sizeof(region->wave_link));
                break;

            default:
                TRACE("Unknown chunk %s (skipping): %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);

                ret = advance_stream(stream, chunk.dwSize);
                if (FAILED(ret))
                    return ret;

                length = subtract_bytes(length, chunk.dwSize);
                break;
        }
    }

    return S_OK;
}
开发者ID:Barrell,项目名称:wine,代码行数:69,代码来源:instrument.c

示例4: sprintf

bool AVIDump::CreateFile()
{
	m_totalBytes = 0;
	m_frameCount = 0;
	char movie_file_name[255];
	sprintf(movie_file_name, "%sframedump%d.avi", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), m_fileCount);
	// Create path
	File::CreateFullPath(movie_file_name);

	// Ask to delete file
	if (File::Exists(movie_file_name))
	{
		if (AskYesNoT("Delete the existing file '%s'?", movie_file_name))
			File::Delete(movie_file_name);
	}

	AVIFileInit();
	NOTICE_LOG(VIDEO, "Opening AVI file (%s) for dumping", movie_file_name);
	// TODO: Make this work with AVIFileOpenW without it throwing REGDB_E_CLASSNOTREG
	HRESULT hr = AVIFileOpenA(&m_file, movie_file_name, OF_WRITE | OF_CREATE, NULL);
	if (FAILED(hr))
	{
		if (hr == AVIERR_BADFORMAT) NOTICE_LOG(VIDEO, "The file couldn't be read, indicating a corrupt file or an unrecognized format."); 
		if (hr == AVIERR_MEMORY)  NOTICE_LOG(VIDEO, "The file could not be opened because of insufficient memory."); 
		if (hr == AVIERR_FILEREAD) NOTICE_LOG(VIDEO, "A disk error occurred while reading the file."); 
		if (hr == AVIERR_FILEOPEN) NOTICE_LOG(VIDEO, "A disk error occurred while opening the file.");
		if (hr == REGDB_E_CLASSNOTREG) NOTICE_LOG(VIDEO, "AVI class not registered");
		Stop();
		return false;
	}

	SetBitmapFormat();
	NOTICE_LOG(VIDEO, "Setting video format...");
	if (!SetVideoFormat())
	{
		NOTICE_LOG(VIDEO, "Setting video format failed");
		Stop();
		return false;
	}

	if (!m_fileCount) {
		if (!SetCompressionOptions()) {
			NOTICE_LOG(VIDEO, "SetCompressionOptions failed");
			Stop();
			return false;
		}
	}

	if (FAILED(AVIMakeCompressedStream(&m_streamCompressed, m_stream, &m_options, NULL)))
	{
		NOTICE_LOG(VIDEO, "AVIMakeCompressedStream failed");
		Stop();
		return false;
	}

	if (FAILED(AVIStreamSetFormat(m_streamCompressed, 0, &m_bitmap, m_bitmap.biSize)))
	{
		NOTICE_LOG(VIDEO, "AVIStreamSetFormat failed");
		Stop();
		return false;
	}

	return true;
}
开发者ID:Everscent,项目名称:dolphin-emu,代码行数:64,代码来源:AVIDump.cpp

示例5: SendSMS

void CDisplayGPSData::SendSMS(BOOL bSendConfirmation, BOOL bUseDefaultSMSC, LPCTSTR lpszSMSC, LPCTSTR lpszRecipient, LPCTSTR lpszMessage)
{
	SMS_HANDLE smshHandle;
	SMS_ADDRESS smsaSource;
	SMS_ADDRESS smsaDestination;
	TEXT_PROVIDER_SPECIFIC_DATA tpsd;
	SMS_MESSAGE_ID smsmidMessageID;

	// try to open an SMS Handle
	if(FAILED(SmsOpen(SMS_MSGTYPE_TEXT, SMS_MODE_SEND, &smshHandle, NULL)))
	{
/*		MessageBox(NULL,
					(LPCTSTR)LoadString(ghInstance, IDS_ERROR_SMSOPEN, 0, 0), 
					(LPCTSTR)LoadString(ghInstance, IDS_CAPTION_ERROR, 0, 0),
					MB_OK | MB_ICONERROR);*/
		return;
	}

	// Create the source address
	if(!bUseDefaultSMSC)
	{
		smsaSource.smsatAddressType = SMSAT_INTERNATIONAL;
		_tcsncpy(smsaSource.ptsAddress, lpszSMSC, SMS_MAX_ADDRESS_LENGTH);
	}

	// Create the destination address
	if( lstrlen(lpszRecipient) < 11 ){
		smsaDestination.smsatAddressType = SMSAT_ABBREVIATED;
	}
	else{
		smsaDestination.smsatAddressType = SMSAT_INTERNATIONAL;
	}
	_tcsncpy(smsaDestination.ptsAddress, lpszRecipient, SMS_MAX_ADDRESS_LENGTH);

	// Set up provider specific data
    memset(&tpsd, 0, sizeof(tpsd));
	tpsd.dwMessageOptions = bSendConfirmation ? PS_MESSAGE_OPTION_STATUSREPORT : PS_MESSAGE_OPTION_NONE;
	tpsd.psMessageClass = PS_MESSAGE_CLASS1;
	tpsd.psReplaceOption = PSRO_NONE;
	tpsd.dwHeaderDataSize = 0;

	// Send the message, indicating success or failure
	if(SUCCEEDED(SmsSendMessage(smshHandle, ((bUseDefaultSMSC) ? NULL : &smsaSource), 
								 &smsaDestination, NULL, (PBYTE) lpszMessage, 
								 _tcslen(lpszMessage) * sizeof(TCHAR), (PBYTE) &tpsd, 
								 sizeof(TEXT_PROVIDER_SPECIFIC_DATA), SMSDE_OPTIMAL, 
								 SMS_OPTION_DELIVERY_NONE, &smsmidMessageID)))
	{
	/*	MessageBox(NULL,
					(LPCTSTR)LoadString(ghInstance, IDS_SMSSENT, 0, 0), 
					(LPCTSTR)LoadString(ghInstance, IDS_CAPTION_SUCCESS, 0, 0),
					MB_OK);*/
	}
	else
	{
	/*	MessageBox(NULL,
					(LPCTSTR)LoadString(ghInstance, IDS_ERROR_SMSSEND, 0, 0), 
					(LPCTSTR)LoadString(ghInstance, IDS_CAPTION_ERROR, 0, 0),
					MB_OK | MB_ICONERROR);
					*/
	}

	// clean up
	VERIFY(SUCCEEDED(SmsClose(smshHandle)));
}
开发者ID:kevinejohn,项目名称:BlackJack2-Phone-Finder,代码行数:65,代码来源:DisplayGPSData.cpp

示例6: ARRAYSIZE

bool scRenderSystem::Initialize( HWND hwnd, int width, int height )
{
	mHwnd = hwnd;
	mWindowWidth = width;
	mWindowHeight = height;
    HRESULT hr;
	
	// 创建设备

    D3D_DRIVER_TYPE driverTypes[] =
    {
        D3D_DRIVER_TYPE_HARDWARE, D3D_DRIVER_TYPE_WARP, D3D_DRIVER_TYPE_SOFTWARE
    };
    unsigned int totalDriverTypes = ARRAYSIZE( driverTypes );

    D3D_FEATURE_LEVEL featureLevels[] =
    {
        D3D_FEATURE_LEVEL_11_0
    };
    unsigned int totalFeatureLevels = ARRAYSIZE( featureLevels );

    DXGI_SWAP_CHAIN_DESC swapChainDesc;
    ZeroMemory( &swapChainDesc, sizeof( swapChainDesc ) );
    swapChainDesc.BufferCount = 1;
    swapChainDesc.BufferDesc.Width = width;
    swapChainDesc.BufferDesc.Height = height;
    swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    swapChainDesc.BufferDesc.RefreshRate.Numerator = 60;
    swapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
    swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
    swapChainDesc.OutputWindow = hwnd;
    swapChainDesc.Windowed = true;
    swapChainDesc.SampleDesc.Count = 1;
    swapChainDesc.SampleDesc.Quality = 0;
	
    for (unsigned int i = 0; i < totalDriverTypes; ++i)
    {
		// 尝试创建
		hr = D3D11CreateDeviceAndSwapChain(0, driverTypes[i], 0, 0,
                                                featureLevels, totalFeatureLevels,
                                                D3D11_SDK_VERSION, &swapChainDesc, &mSwapChain,
                                                &mDevice, &mFeatureLevel, &mContext);
        if(SUCCEEDED(hr))
        {
            mDriverType = driverTypes[i];
            break;
        }
    }
    if(FAILED(hr))
    {
		scErrMsg("Failed to create the Direct3D device!");
        return false;
    }


	// 创建backbuffer

    ID3D11Texture2D* backBufferTexture;
    hr = mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&backBufferTexture);
    if(FAILED(hr))
    {
		scErrMsg("Failed to get the swap chain back buffer!");
        return false;
    }

    hr = mDevice->CreateRenderTargetView(backBufferTexture, 0, &mBackBuffer);
    if(backBufferTexture)
        backBufferTexture->Release();
    if(FAILED(hr))
    {
		scErrMsg("Failed to create back buffer!");
        return false;
    }

	// 创建depthbuffer

	D3D11_TEXTURE2D_DESC depthTexDesc;
	ZeroMemory(&depthTexDesc, sizeof(depthTexDesc));
	depthTexDesc.Width = width;
	depthTexDesc.Height = height;
	depthTexDesc.MipLevels = 1;
	depthTexDesc.ArraySize = 1;
	depthTexDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
	depthTexDesc.SampleDesc.Count = 1;
	depthTexDesc.SampleDesc.Quality = 0;
	depthTexDesc.Usage = D3D11_USAGE_DEFAULT;
	depthTexDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
	depthTexDesc.CPUAccessFlags = 0;
	depthTexDesc.MiscFlags = 0;

	ID3D11Texture2D* depthTexture;
	hr = mDevice->CreateTexture2D(&depthTexDesc, NULL, &depthTexture);
	if(FAILED(hr))
	{
		scErrMsg("Failed to create the depth texture!");
		return false;
	}

	D3D11_DEPTH_STENCIL_VIEW_DESC descDSV;
	ZeroMemory(&descDSV, sizeof(descDSV));
//.........这里部分代码省略.........
开发者ID:kidsang,项目名称:SaberCore,代码行数:101,代码来源:scRenderSystem.cpp

示例7: Debug_ReportError

HRESULT 
MDFormat::VerifySignature(
    PSTORAGESIGNATURE pSig,     // The signature to check.
    ULONG             cbData)
{
    HRESULT hr = S_OK;
    
    // If signature didn't match, you shouldn't be here.
    ULONG dwSignature = pSig->GetSignature();
    if (dwSignature == STORAGE_MAGIC_OLD_SIG)
    {
        Debug_ReportError("Invalid MetaData storage signature - old magic signature +MOC.");
        return PostError(CLDB_E_FILE_OLDVER, 1, 0);
    }
    if (dwSignature != STORAGE_MAGIC_SIG)
    {
        Debug_ReportError("Invalid MetaData storage signature - unrecognized magic signature, should be BSJB.");
        return PostError(CLDB_E_FILE_CORRUPT);
    }
    
    // Check for overflow
    ULONG lVersionString = pSig->GetVersionStringLength();
    ULONG sum = sizeof(STORAGESIGNATURE) + lVersionString;
    if ((sum < sizeof(STORAGESIGNATURE)) || (sum < lVersionString))
    {
        Debug_ReportError("Invalid MetaData storage signature - version string too long, integer overflow.");
        return PostError(CLDB_E_FILE_CORRUPT);
    }
    
    // Check for invalid version string size
    if ((sizeof(STORAGESIGNATURE) + lVersionString) > cbData)
    {
        Debug_ReportError("Invalid MetaData storage signature - version string too long.");
        return PostError(CLDB_E_FILE_CORRUPT);
    }
    
    // Check that the version string is null terminated. This string
    // is ANSI, so no double-null checks need to be made.
    {
        BYTE *pStart = &pSig->pVersion[0];
        BYTE *pEnd = pStart + lVersionString + 1; // Account for terminating NULL
        BYTE *pCur;
        
        for (pCur = pStart; pCur < pEnd; pCur++)
        {
            if (*pCur == 0)
                break;
        }
        
        // If we got to the end without hitting a NULL, we have a bad version string
        if (pCur == pEnd)
        {
            Debug_ReportError("Invalid MetaData storage signature - version string has not null-terminator.");
            return PostError(CLDB_E_FILE_CORRUPT);
        }
    }
    
#if !defined(FEATURE_METADATA_STANDALONE_WINRT)
    // Only a specific version of the 0.x format is supported by this code
    // in order to support the NT 5 beta clients which used this format.
    if (pSig->GetMajorVer() == FILE_VER_MAJOR_v0)
    {
        if (pSig->GetMinorVer() < FILE_VER_MINOR_v0)
        {
            Debug_ReportError("Invalid MetaData storage signature - unrecognized version, should be 1.1.");
            hr = CLDB_E_FILE_OLDVER;
        }
    }
    else
#endif  // !defined(FEATURE_METADATA_STANDALONE_WINRT)
    // There is currently no code to migrate an old format of the 1.x.  This
    // would be added only under special circumstances.
    if ((pSig->GetMajorVer() != FILE_VER_MAJOR) || (pSig->GetMinorVer() != FILE_VER_MINOR))
    {
        Debug_ReportError("Invalid MetaData storage signature - unrecognized version, should be 1.1.");
        hr = CLDB_E_FILE_OLDVER;
    }

    if (FAILED(hr))
        hr = PostError(hr, (int)pSig->GetMajorVer(), (int)pSig->GetMinorVer());
    return hr;
} // MDFormat::VerifySignature
开发者ID:Afshintm,项目名称:coreclr,代码行数:82,代码来源:mdfileformat.cpp

示例8: SAFE_DELETE_ARRAY

//-----------------------------------------------------------------------------
// Name: CWaveFile::Open()
// Desc: Opens a wave file for reading
//-----------------------------------------------------------------------------
HRESULT CWaveFile::Open( LPWSTR strFileName, WAVEFORMATEX* pwfx, DWORD dwFlags )
{
    HRESULT hr;

    m_dwFlags = dwFlags;
    m_bIsReadingFromMemory = FALSE;

    if( m_dwFlags == WAVEFILE_READ )
    {
        if( strFileName == NULL )
            return E_INVALIDARG;
        SAFE_DELETE_ARRAY( m_pwfx );

        m_hmmio = mmioOpen( strFileName, NULL, MMIO_ALLOCBUF | MMIO_READ );

        if( NULL == m_hmmio )
        {
            HRSRC   hResInfo;
            HGLOBAL hResData;
            DWORD   dwSize;
            VOID*   pvRes;

            // Loading it as a file failed, so try it as a resource
            if( NULL == ( hResInfo = FindResource( NULL, strFileName, L"WAVE" ) ) )
            {
                if( NULL == ( hResInfo = FindResource( NULL, strFileName, L"WAV" ) ) )
                    return DXTRACE_ERR( L"FindResource", E_FAIL );
            }

            if( NULL == ( hResData = LoadResource( GetModuleHandle(NULL), hResInfo ) ) )
                return DXTRACE_ERR( L"LoadResource", E_FAIL );

            if( 0 == ( dwSize = SizeofResource( GetModuleHandle(NULL), hResInfo ) ) )
                return DXTRACE_ERR( L"SizeofResource", E_FAIL );

            if( NULL == ( pvRes = LockResource( hResData ) ) )
                return DXTRACE_ERR( L"LockResource", E_FAIL );

            m_pResourceBuffer = new CHAR[ dwSize ];
            if( m_pResourceBuffer == NULL )
                return DXTRACE_ERR( L"new", E_OUTOFMEMORY );
            memcpy( m_pResourceBuffer, pvRes, dwSize );

            MMIOINFO mmioInfo;
            ZeroMemory( &mmioInfo, sizeof(mmioInfo) );
            mmioInfo.fccIOProc = FOURCC_MEM;
            mmioInfo.cchBuffer = dwSize;
            mmioInfo.pchBuffer = (CHAR*) m_pResourceBuffer;

            m_hmmio = mmioOpen( NULL, &mmioInfo, MMIO_ALLOCBUF | MMIO_READ );
        }

        if( FAILED( hr = ReadMMIO() ) )
        {
            // ReadMMIO will fail if its an not a wave file
            mmioClose( m_hmmio, 0 );
            return DXTRACE_ERR( L"ReadMMIO", hr );
        }

        if( FAILED( hr = ResetFile() ) )
            return DXTRACE_ERR( L"ResetFile", hr );

        // After the reset, the size of the wav file is m_ck.cksize so store it now
        m_dwSize = m_ck.cksize;
    }
    else
    {
        m_hmmio = mmioOpen( strFileName, NULL, MMIO_ALLOCBUF  |
                                                  MMIO_READWRITE |
                                                  MMIO_CREATE );
        if( NULL == m_hmmio )
            return DXTRACE_ERR( L"mmioOpen", E_FAIL );

        if( FAILED( hr = WriteMMIO( pwfx ) ) )
        {
            mmioClose( m_hmmio, 0 );
            return DXTRACE_ERR( L"WriteMMIO", hr );
        }

        if( FAILED( hr = ResetFile() ) )
            return DXTRACE_ERR( L"ResetFile", hr );
    }

    return hr;
}
开发者ID:SeaOfTea,项目名称:cavesimulation,代码行数:89,代码来源:SDKwavefile.cpp

示例9: DSoundOpenPlayback


//.........这里部分代码省略.........
            OutputType.dwChannelMask = SPEAKER_FRONT_LEFT |
                                       SPEAKER_FRONT_RIGHT |
                                       SPEAKER_BACK_LEFT |
                                       SPEAKER_BACK_RIGHT;
        }
        else if(speakers == DSSPEAKER_5POINT1)
        {
            if(aluBytesFromFormat(device->Format) == 1)
                device->Format = AL_FORMAT_51CHN8;
            else
                device->Format = AL_FORMAT_51CHN16;
            OutputType.dwChannelMask = SPEAKER_FRONT_LEFT |
                                       SPEAKER_FRONT_RIGHT |
                                       SPEAKER_FRONT_CENTER |
                                       SPEAKER_LOW_FREQUENCY |
                                       SPEAKER_BACK_LEFT |
                                       SPEAKER_BACK_RIGHT;
        }
        else if(speakers == DSSPEAKER_7POINT1)
        {
            if(aluBytesFromFormat(device->Format) == 1)
                device->Format = AL_FORMAT_71CHN8;
            else
                device->Format = AL_FORMAT_71CHN16;
            OutputType.dwChannelMask = SPEAKER_FRONT_LEFT |
                                       SPEAKER_FRONT_RIGHT |
                                       SPEAKER_FRONT_CENTER |
                                       SPEAKER_LOW_FREQUENCY |
                                       SPEAKER_BACK_LEFT |
                                       SPEAKER_BACK_RIGHT |
                                       SPEAKER_SIDE_LEFT |
                                       SPEAKER_SIDE_RIGHT;
        }
        frameSize = aluBytesFromFormat(device->Format) *
                    aluChannelsFromFormat(device->Format);

        OutputType.Format.wFormatTag = WAVE_FORMAT_PCM;
        OutputType.Format.nChannels = aluChannelsFromFormat(device->Format);
        OutputType.Format.wBitsPerSample = aluBytesFromFormat(device->Format) * 8;
        OutputType.Format.nBlockAlign = OutputType.Format.nChannels*OutputType.Format.wBitsPerSample/8;
        OutputType.Format.nSamplesPerSec = device->Frequency;
        OutputType.Format.nAvgBytesPerSec = OutputType.Format.nSamplesPerSec*OutputType.Format.nBlockAlign;
        OutputType.Format.cbSize = 0;

        device->UpdateSize /= DS_FRAGS;
    }

    if(OutputType.Format.nChannels > 2)
    {
        OutputType.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
        OutputType.Samples.wValidBitsPerSample = OutputType.Format.wBitsPerSample;
        OutputType.Format.cbSize = 22;
        OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
    }
    else
    {
        if(SUCCEEDED(hr))
        {
            memset(&DSBDescription,0,sizeof(DSBUFFERDESC));
            DSBDescription.dwSize=sizeof(DSBUFFERDESC);
            DSBDescription.dwFlags=DSBCAPS_PRIMARYBUFFER;
            hr = IDirectSound_CreateSoundBuffer(pData->lpDS, &DSBDescription, &pData->DSpbuffer, NULL);
        }
        if(SUCCEEDED(hr))
            hr = IDirectSoundBuffer_SetFormat(pData->DSpbuffer,&OutputType.Format);
    }

    if(SUCCEEDED(hr))
    {
        memset(&DSBDescription,0,sizeof(DSBUFFERDESC));
        DSBDescription.dwSize=sizeof(DSBUFFERDESC);
        DSBDescription.dwFlags=DSBCAPS_GLOBALFOCUS|DSBCAPS_GETCURRENTPOSITION2;
        DSBDescription.dwBufferBytes=device->UpdateSize * DS_FRAGS * frameSize;
        DSBDescription.lpwfxFormat=&OutputType.Format;
        hr = IDirectSound_CreateSoundBuffer(pData->lpDS, &DSBDescription, &pData->DSsbuffer, NULL);
    }

    if(SUCCEEDED(hr))
        hr = IDirectSoundBuffer_Play(pData->DSsbuffer, 0, 0, DSBPLAY_LOOPING);

    device->ExtraData = pData;
    pData->thread = StartThread(DSoundProc, device);
    if(!pData->thread)
        hr = E_FAIL;

    if(FAILED(hr))
    {
        if (pData->DSsbuffer)
            IDirectSoundBuffer_Release(pData->DSsbuffer);
        if (pData->DSpbuffer)
            IDirectSoundBuffer_Release(pData->DSpbuffer);
        if (pData->lpDS)
            IDirectSound_Release(pData->lpDS);

        free(pData);
        return ALC_FALSE;
    }

    return ALC_TRUE;
}
开发者ID:m64,项目名称:PEG,代码行数:101,代码来源:dsound.c

示例10: _ASSERTE

RegMeta::~RegMeta()
{
    BEGIN_CLEANUP_ENTRYPOINT;
    
    _ASSERTE(!m_bCached);

    HRESULT hr = S_OK;

    LOCKWRITENORET();
    
#ifdef FEATURE_METADATA_INTERNAL_APIS
    // This should have worked if we've cached the public interface in the past
    _ASSERTE(SUCCEEDED(hr) || (m_pInternalImport == NULL) || (m_pInternalImport->GetCachedPublicInterface(false) == NULL));
#endif //FEATURE_METADATA_INTERNAL_APIS

    if (SUCCEEDED(hr))
    {
#ifdef FEATURE_METADATA_INTERNAL_APIS
        if (m_pInternalImport != NULL)
        {
            // RegMeta is going away. Make sure we clear up the pointer from MDInternalRW to this RegMeta.
            if (FAILED(m_pInternalImport->SetCachedPublicInterface(NULL)))
            {   // Do nothing on error
            }
            m_pInternalImport = NULL;
            m_fOwnSem = false;
        }
#endif //FEATURE_METADATA_INTERNAL_APIS

        UNLOCKWRITE();
    }

    if (m_pFreeThreadedMarshaler)
    {
        m_pFreeThreadedMarshaler->Release();
        m_pFreeThreadedMarshaler = NULL;
    }

    if (m_pSemReadWrite && m_fOwnSem)
        delete m_pSemReadWrite;

    // If this RegMeta is a wrapper on an external StgDB, release it.
    if (IsOfExternalStgDB(m_OpenFlags))
    {
        _ASSERTE(m_pUnk != NULL);   // Owning IUnknown for external StgDB.
        if (m_pUnk)
            m_pUnk->Release();
        m_pUnk = 0;
    }
    else
    {   // Not a wrapper, so free our StgDB.
        _ASSERTE(m_pUnk == NULL); 
        // It's possible m_pStdbg is NULL in OOM scenarios
        if (m_pStgdb != NULL)
            delete m_pStgdb;
        m_pStgdb = 0;
    }

    // Delete the old copies of Stgdb list. This is the list track all of the 
    //  old snapshuts with ReOpenWithMemory call.
    CLiteWeightStgdbRW  *pCur; 
    while (m_pStgdbFreeList)
    {
        pCur = m_pStgdbFreeList;
        m_pStgdbFreeList = m_pStgdbFreeList->m_pNextStgdb;
        delete pCur;
    }

    if (m_pVEHandler)
        m_pVEHandler->Release();

    // If This RegMeta spun up the runtime (probably to process security 
    //  attributes), shut it down now.
    if (m_fStartedEE) 
    {
        m_pAppDomain->Release();
#ifdef FEATURE_INCLUDE_ALL_INTERFACES
        m_pCorHost->Stop();
        m_pCorHost->Release();
#endif // FEATURE_INCLUDE_ALL_INTERFACES
    }

    if (m_pFilterManager != NULL)
        delete m_pFilterManager;


    if (m_OptionValue.m_RuntimeVersion != NULL)
        delete[] m_OptionValue.m_RuntimeVersion;

    END_CLEANUP_ENTRYPOINT;
    
} // RegMeta::~RegMeta()
开发者ID:0-wiz-0,项目名称:coreclr,代码行数:92,代码来源:regmeta.cpp

示例11: LoadModuleIntoBuffer

bool LoadModuleIntoBuffer(std::wstring plyFileName, std::wstring &error)
{

	// Load our ply file... in a moment...
	CPlyFile5nt_DX11 myPly;
	if ( !myPly.OpenPLYFile( plyFileName, error ) )	//ply\\bun_zipper_res3.ply
	{
		MessageBox(NULL, error.c_str(), L"Error", MB_OK );
		return false;
	}


	//Check if model has been already loaded
	if (g_mapPlyInfo.find(plyFileName) != g_mapPlyInfo.end())
	{
		//Already exist
		error = L"PLY file already loaded.";
		return false;
	}

	g_mapPlyInfo[plyFileName].numberOfElementsToDraw = myPly.GetNumberOfElements();
	g_mapPlyInfo[plyFileName].numberOfVertices = myPly.GetNumberOfVerticies();
	g_mapPlyInfo[plyFileName].maxExtent = myPly.getMaxExtent();

	myPly.normalizeTheModelBaby();

	//Week 9
	// Calculate texture coordinates...if there weren't any.
	myPly.GenTextureCoordsSpherical( CPlyFile5nt_DX11::POSITIVE_X, 
		CPlyFile5nt_DX11::POSITIVE_Y, 
		true, 1.0f, false );

	int totalNumberOfVertices = myPly.GetNumberOfVerticies() * 2;	// Make it a bit bigger.
	SimpleVertex* tempVertexArray = new SimpleVertex[ totalNumberOfVertices ];
	memset( tempVertexArray, 0, totalNumberOfVertices * sizeof( SimpleVertex ) );

	// Create a temporary "local" index array
	int totalNumberOfElements = myPly.GetNumberOfElements() * 2;
	DWORD* tempIndexArray = new DWORD[ totalNumberOfElements * 3 ];
	memset( tempIndexArray, 0, totalNumberOfElements * 3 * sizeof(DWORD) );

	for ( int index = 0; index != myPly.GetNumberOfVerticies(); index++ )
	{
		tempVertexArray[index].Pos.x = myPly.getVertex_at( index ).xyz.x;
		tempVertexArray[index].Pos.y = myPly.getVertex_at( index ).xyz.y;
		tempVertexArray[index].Pos.z = myPly.getVertex_at( index ).xyz.z;
		tempVertexArray[index].Pos.w = 1.0f;	// W is almost alway 1.0f;

		tempVertexArray[index].Normal.x = myPly.getVertex_at( index ).nx;
		tempVertexArray[index].Normal.y = myPly.getVertex_at( index ).ny;
		tempVertexArray[index].Normal.z = myPly.getVertex_at( index ).nz;
		tempVertexArray[index].Normal.w = 1.0f;	// W is almost alway 1.0f;
		// week 9
		tempVertexArray[index].Tex.x = myPly.getVertex_at(index).tex0u;
		tempVertexArray[index].Tex.y = myPly.getVertex_at(index).tex0v;
		std::wostringstream  wss;
		wss << L"x: " << tempVertexArray[index].Tex.x << std::endl;

		//OutputDebugString(wss.str().c_str());
		//wss << L"";
		//wss << L"y: " << tempVertexArray[index].Tex.y << std::endl;
		//OutputDebugString(wss.str().c_str());
		//

	}

	// Now the maddness starts when we copy the index buffer...
	for ( int triNum = 0; triNum != myPly.GetNumberOfElements(); triNum++ )
	{
		int arrayIndex = triNum * 3;		// Because it's triangles (3 side)

		tempIndexArray[arrayIndex + 0] = myPly.getElement_at( triNum ).vertex_index_1;
		tempIndexArray[arrayIndex + 1] = myPly.getElement_at( triNum ).vertex_index_2;
		tempIndexArray[arrayIndex + 2] = myPly.getElement_at( triNum ).vertex_index_3;
	}

	D3D11_BUFFER_DESC bd;
	bd.Usage = D3D11_USAGE_DEFAULT;
	bd.ByteWidth = sizeof( SimpleVertex ) * totalNumberOfVertices;
	bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
	bd.CPUAccessFlags = 0;
	bd.MiscFlags = 0;
	D3D11_SUBRESOURCE_DATA InitData;
	InitData.pSysMem = tempVertexArray;

	HRESULT hr = g_pd3dDevice->CreateBuffer( &bd, &InitData, &(g_mapPlyInfo[plyFileName].vertexBuffer));
	if( FAILED( hr ) )
	{
		error = L"ERROR: Unable to create vertex buffer.";
		return false;
	}

	// Same thing, but with the index buffer...
	bd.Usage = D3D11_USAGE_DEFAULT;
	bd.ByteWidth = sizeof( DWORD ) * totalNumberOfElements * 3;       
	bd.BindFlags = D3D11_BIND_INDEX_BUFFER;
	bd.CPUAccessFlags = 0;
	bd.MiscFlags = 0;
	InitData.pSysMem = tempIndexArray;
	hr = g_pd3dDevice->CreateBuffer( &bd, &InitData, &(g_mapPlyInfo[plyFileName].indexBuffer));
//.........这里部分代码省略.........
开发者ID:itguy327,项目名称:Slipetz_DirectX,代码行数:101,代码来源:LoadModelIntoBuffer.cpp

示例12: IfFailGo

//---------------------------------------------------------------------------------------
// 
// Returns the memory region of the mapped file and type of its mapping. The choice of the file mapping type 
// for each scope is CLR implementation specific and user cannot explicitly set it.
// 
// The memory is valid only as long as the underlying MetaData scope is opened (there's a reference to 
// a MetaData interface for this scope).
// 
// Implements public API code:IMetaDataInfo::GetFileMapping.
// 
// Arguments:
//    ppvData - Fills with pointer to the start of the mapped file.
//    pcbData - Fills with the size of the mapped memory region (for flat-mapping it is the size of the 
//              file).
//    pdwMappingType - Fills with type of file mapping (code:CorFileMapping).
//        Current CLR implementation returns always code:fmFlat. The other value(s) are reserved for future 
//        usage. See code:StgIO::MapFileToMem#CreateFileMapping_SEC_IMAGE for more details.
// 
// Return Value:
//    S_OK               - All output data are filled.
//    COR_E_NOTSUPPORTED - CLR cannot (or doesn't want to) provide the memory region.
//        This can happen when:
//          - The MetaData scope was opened with flag code:ofWrite or code:ofCopyMemory.
//            Note: code:ofCopyMemory could be supported in future CLR versions. For example if we change 
//            code:CLiteWeightStgdbRW::OpenForRead to copy whole file (or add a new flag ofCopyWholeFile).
//          - The MetaData scope was opened without flag code:ofReadOnly.
//            Note: We could support this API without code:ofReadOnly flag in future CLR versions. We just 
//            need some test coverage and user scenario for it.
//          - Only MetaData part of the file was opened using code:OpenScopeOnMemory.
//          - The file is not NT PE file (e.g. it is NT OBJ = .obj file produced by managed C++).
//    E_INVALIDARG       - NULL was passed as an argument value.
// 
HRESULT 
RegMeta::GetFileMapping(
    const void ** ppvData, 
    ULONGLONG *   pcbData, 
    DWORD *       pdwMappingType)
{
    HRESULT hr = S_OK;
    
    if ((ppvData == NULL) || (pcbData == NULL) || (pdwMappingType == NULL))
    {
        return E_INVALIDARG;
    }
    
    // Note: Some of the following checks are duplicit (as some combinations are invalid and ensured by CLR 
    // implementation), but it is easier to check them all
    
    // OpenScope flags have to be (ofRead | ofReadOnly) and not ofCopyMemory 
    // (as code:CLiteWeightStgdbRW::OpenForRead will copy only the MetaData part of the file)
    if (((m_OpenFlags & ofReadWriteMask) != ofRead) || 
        ((m_OpenFlags & ofReadOnly) == 0) || 
        ((m_OpenFlags & ofCopyMemory) != 0))
    {
        IfFailGo(COR_E_NOTSUPPORTED);
    }
    // The file has to be NT PE file (not CLDB = managed C++ .obj file) and we have to have its full mapping 
    // (see code:CLiteWeightStgdbRW::OpenForRead)
    if ((m_pStgdb->m_pImage == NULL) || 
        (m_pStgdb->m_dwImageSize == 0) || 
        (m_pStgdb->GetFileType() != FILETYPE_NTPE))
    {
        IfFailGo(COR_E_NOTSUPPORTED);
    }
    if (m_pStgdb->m_pStgIO->GetFlags() != DBPROP_TMODEF_READ)
    {
        IfFailGo(COR_E_NOTSUPPORTED);
    }
    // The file has to be flat-mapped, or copied to memory (file mapping code:MTYPE_IMAGE is not currently 
    // supported - see code:StgIO::MapFileToMem#CreateFileMapping_SEC_IMAGE)
    // Note: Only small files (<=64K) are copied to memory - see code:StgIO::MapFileToMem#CopySmallFiles
    if ((m_pStgdb->m_pStgIO->GetMemoryMappedType() != MTYPE_FLAT) && 
        (m_pStgdb->m_pStgIO->GetMemoryMappedType() != MTYPE_NOMAPPING))
    {
        IfFailGo(COR_E_NOTSUPPORTED);
    }
    // All necessary conditions are satisfied
    
    *ppvData = m_pStgdb->m_pImage;
    *pcbData = m_pStgdb->m_dwImageSize;
    // We checked that the file was flat-mapped above
    *pdwMappingType = fmFlat;
    
ErrExit:
    if (FAILED(hr))
    {
        *ppvData = NULL;
        *pcbData = 0;
        *pdwMappingType = 0;
    }
    
    return hr;
} // RegMeta::GetFileMapping
开发者ID:0-wiz-0,项目名称:coreclr,代码行数:93,代码来源:regmeta.cpp

示例13: if


//.........这里部分代码省略.........
    {
        *ppUnk = (IMetaDataHelper *)this;
    }
    else if (riid == IID_IMDInternalEmit)
    {
        *ppUnk = static_cast<IMDInternalEmit *>(this);
    }
    else if (riid == IID_IGetIMDInternalImport)
    {
        *ppUnk = static_cast<IGetIMDInternalImport *>(this);
    }
#endif //FEATURE_METADATA_INTERNAL_APIS

#if defined(FEATURE_METADATA_EMIT) && defined(FEATURE_METADATA_INTERNAL_APIS)
    else if (riid == IID_IMetaDataEmitHelper)
    {
        *ppUnk = (IMetaDataEmitHelper *)this;
        fIsInterfaceRW = true;
    }
#endif //FEATURE_METADATA_EMIT && FEATURE_METADATA_INTERNAL_APIS

#ifdef FEATURE_METADATA_IN_VM
#ifdef FEATURE_COMINTEROP
    else if (riid == IID_IMarshal)
    {
        // We will only repond to this interface if scope is opened for ReadOnly
        if (IsOfReadOnly(m_OpenFlags))
        {
            if (m_pFreeThreadedMarshaler == NULL)
            {
                // Guard ourselves against first time QI on IMarshal from two different threads..
                LOCKWRITE();
                if (m_pFreeThreadedMarshaler == NULL)
                {
                    // First time! Create the FreeThreadedMarshaler
                    IfFailGo(CoCreateFreeThreadedMarshaler((IUnknown *)(IMetaDataEmit2 *)this, &m_pFreeThreadedMarshaler));
                }                
            }
            
            _ASSERTE(m_pFreeThreadedMarshaler != NULL);
            
            IfFailGo(m_pFreeThreadedMarshaler->QueryInterface(riid, ppUnk));
            
            // AddRef has happened in the QueryInterface and thus should just return
            goto ErrExit;
        }
        else
        {
            IfFailGo(E_NOINTERFACE);
        }
    }
#endif // FEATURE_COMINTEROP
#ifdef FEATURE_PREJIT
    else if (riid == IID_IMetaDataCorProfileData)
    {
        *ppUnk = (IMetaDataCorProfileData *)this;
    }
    else if (riid == IID_IMDInternalMetadataReorderingOptions)
    {
        *ppUnk = (IMDInternalMetadataReorderingOptions *)this;
    }
#endif //FEATURE_PREJIT
#endif //FEATURE_METADATA_IN_VM
    else
    {
        IfFailGo(E_NOINTERFACE);
    }

    if (fIsInterfaceRW && IsOfReadOnly(m_OpenFlags))
    {
        // They are asking for a read/write interface and this scope was
        // opened as Read-Only

        *ppUnk = NULL;
        IfFailGo(CLDB_E_INCOMPATIBLE);
    }

    if (fIsInterfaceRW)
    {
        LOCKWRITENORET();

        if (SUCCEEDED(hr))
        {
            hr = m_pStgdb->m_MiniMd.ConvertToRW();
        }

        if (FAILED(hr))
        {
            *ppUnk = NULL;
            goto ErrExit;
        }
    }

    AddRef();
ErrExit:
    
    END_ENTRYPOINT_NOTHROW;

    return hr;
} // RegMeta::QueryInterface
开发者ID:0-wiz-0,项目名称:coreclr,代码行数:101,代码来源:regmeta.cpp

示例14: OnThreadStartPlay

//
// DoBufferProcessingLoop
//
// Grabs a buffer and calls the users processing function.
// Overridable, so that different delivery styles can be catered for.
HRESULT CSourceStream::DoBufferProcessingLoop(void) {

    Command com;

    OnThreadStartPlay();

    do {
        while (!CheckRequest(&com)) {

            IMediaSample *pSample;

            HRESULT hr = GetDeliveryBuffer(&pSample,NULL,NULL,0);
            if (FAILED(hr)) {
                Sleep(1);
                continue;	// go round again. Perhaps the error will go away
                // or the allocator is decommited & we will be asked to
                // exit soon.
            }

            // Virtual function user will override.
            hr = FillBuffer(pSample);

            if (hr == S_OK) {
                hr = Deliver(pSample);
                pSample->Release();

                // downstream filter returns S_FALSE if it wants us to
                // stop or an error if it's reporting an error.
                if(hr != S_OK)
                {
                    DbgLog((LOG_TRACE, 2, TEXT("Deliver() returned %08x; stopping"), hr));
                    return S_OK;
                }

            } else if (hr == S_FALSE) {
                // derived class wants us to stop pushing data
                pSample->Release();
                DeliverEndOfStream();
                return S_OK;
            } else {
                // derived class encountered an error
                pSample->Release();
                DbgLog((LOG_ERROR, 1, TEXT("Error %08lX from FillBuffer!!!"), hr));
                DeliverEndOfStream();
                m_pFilter->NotifyEvent(EC_ERRORABORT, hr, 0);
                return hr;
            }

            // all paths release the sample
        }

        // For all commands sent to us there must be a Reply call!

        if (com == CMD_RUN || com == CMD_PAUSE) {
            Reply(NOERROR);
        } else if (com != CMD_STOP) {
            Reply((DWORD) E_UNEXPECTED);
            DbgLog((LOG_ERROR, 1, TEXT("Unexpected command!!!")));
        }
    } while (com != CMD_STOP);

    return S_FALSE;
}
开发者ID:BenitoJedai,项目名称:jslibs,代码行数:68,代码来源:source.cpp

示例15: defined

int CTRiASView::OnToolHitTest (CPoint point, TOOLINFO* pTI) const
{
//	VERIFY(CView::OnToolHitTest(point, pTI) == -1);
	if (-1 != CView::OnToolHitTest(point, pTI))		// ChildWindows, die die MFC nicht kennt, verderben alles
		return -1;

	if (DEXI_isDrawing() || DEXI_isPrinting()
#if defined(_USE_WHEELMOUSE)
		|| m_fIsPanning
#endif // _USE_WHEELMOUSE
		) 
		return -1;		// während des Zeichnens nichts machen

int iTool = DEX_GetActiveTool();

	if (NUMARROW != iTool && NUMZOOM != iTool && NUMLUPE != iTool)
		return -1;		// nur für Selektionswerkzeug u.ä.

	{	// Testen, ob Objekteigenschaft überhaupt gebraucht wird
	WObjectProperty ObjProp;
	HRESULT hr = DEX_GetActObjProp (ObjProp.ppv());

		if (FAILED(hr) || !ObjProp) 
			return -1;
	}

// Punktobjekt muß gültig sein
	if (!m_ptToolTest.IsValid()) {
		ASSERT(m_ptToolTest.IsValid());
		return -1;
	}

LONG lPrevObject = m_lToolTipObject;

	m_lToolTipObject = 0L;		// aktives Objekt rücksetzen

CRect rc;
	
	GetClientRect(rc);			// Y-Koordinate kippen

// Koordinaten in DB-Koordinaten umsetzen
CPoint pt;

	pt.x = point.x;
	pt.y = rc.bottom - rc.top - point.y;
	DCtoOCEx (pt, &m_ptToolTest);       // Device --> Objekt
	
FINDOBJECT FO;
CObjRectMaxPriority obj;

	INITSTRUCT(FO, FINDOBJECT);
	FO.Pt = pt;
	FO.iFOMode = FOPunkt|FOKante|FOFlaeche|FOText;
	FO.eFcn = (FINDOBJECTPROC)FindObjectsForToolTip;
	FO.pData = (void *)&obj;
	if (!DEX_FindObjectsFromPoint(FO) || 0L == obj.IsValid())
		return -1;		// irgend ein Fehler oder nichts gefunden

// das Objekt mit der höchsten ZeichenPriorität verwenden
	m_lToolTipObject = obj.ObjNr();
	m_rcToolTipObject = obj.ObjRect();

// wenn ein neues Objekt geliefert wurde, alten Tooltip ausblenden
	if (lPrevObject != m_lToolTipObject)
		CancelToolTips(TRUE);

// if there were any area's that are not hits, then we could return -1
// immiediately, but in this example, every grid square fires.
	pTI->rect.left = m_rcToolTipObject.left;
	pTI->rect.right = m_rcToolTipObject.right;
	pTI->rect.bottom = rc.bottom - rc.top - m_rcToolTipObject.bottom;
	pTI->rect.top = rc.bottom - rc.top - m_rcToolTipObject.top;

// if using callbacks - store enough info in a static variable so
// we can produce the text later on a TTN_NEEDTEXT notification.
	pTI->lpszText = LPSTR_TEXTCALLBACK;
	AccessToolHit() = point;
	
// set up the rest of the flags. Not all of these are required, but it seems
// safer to supply them.
	pTI->hwnd = m_hWnd;				// window where TTN_NEEDTEXT will be sent.
	
	pTI->uFlags = 0; //TTF_ALWAYSTIP ;
	pTI->cbSize = sizeof TOOLINFO;
	pTI->uId = (UINT)(m_lToolTipObject | ~0x7fffffffL);		// dummy id, so we can tell it's not a standard command
								// if you want standard tooltip processing, you should
								// put the command id here
	// need a return value that is different for every grid square. 
	return int(m_lToolTipObject);
}
开发者ID:hkaiser,项目名称:TRiAS,代码行数:90,代码来源:TRiASView.cpp


注:本文中的FAILED函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。