請問一個讀取.ffe檔案的問題 |
尚未結案
|
samhum0522
一般會員 發表:26 回覆:12 積分:7 註冊:2004-11-30 發送簡訊給我 |
各位先進:
小弟目前遇到一個讀取.ffe檔的問題
我想以一個簡單的button來做讀取
再以另一個button來做執行
但不知從何下手!
我有找到一個範例但是小弟看不太懂
Ex
// Name: OnReadFile()
//-------------------------------------------------------------------HRESULT OnReadFile( HWND hDlg )
{
HRESULT hr; static TCHAR strFileName[MAX_PATH] = TEXT("");
static TCHAR strPath[MAX_PATH] = TEXT(""); // Setup the OPENFILENAME structure
OPENFILENAME ofn = { sizeof(OPENFILENAME), hDlg, NULL,
TEXT("FEdit Files\0*.ffe\0All Files\0*.*\0
\0"), NULL,
0, 1, strFileName, MAX_PATH, NULL, 0,
strPath,
TEXT("Open FEdit File"),
OFN_FILEMUSTEXIST|OFN_HIDEREADONLY, 0, 0,
TEXT(".ffe"), 0, NULL, NULL }; // Get the default media path (something like
C:\DXSDK\SAMPLES\MULTIMEDIA\DINPUT\MEDIA)
if( '\0' == strPath[0] )
DXUtil_GetDXSDKMediaPathCch( strPath, MAX_PATH ); // Display the OpenFileName dialog. Then, try to load the
specified file
if( FALSE == GetOpenFileName( &ofn ) )
return S_OK; EmptyEffectList(); // Enumerate the effects in the file selected, and create them
in the callback
if( FAILED( hr = g_pFFDevice->EnumEffectsInFile( strFileName,
EnumAndCreateEffectsCallback, NULL, DIFEF_MODIFYIFNEEDED ) ) )
return hr; // Remember the path for next time
_tcscpy( strPath, strFileName );
TCHAR* strLastSlash = _tcsrchr( strPath, '\\' );
if( strLastSlash )
strLastSlash[0] = '\0'; // If list of effects is empty, then we haven't been able to create any effects
if( g_EffectsList.pNext == &g_EffectsList )
{
// Pop up a box informing the user
MessageBox( hDlg, _T("Unable to create any effects."),
_T("ReadFFE"), MB_ICONEXCLAMATION | MB_OK );
EnableWindow( GetDlgItem( hDlg, IDC_PLAY_EFFECTS ), FALSE );
}
else
{
// We have effects so enable the 'play effects' button
EnableWindow( GetDlgItem( hDlg, IDC_PLAY_EFFECTS ), TRUE );
} return S_OK;
} // Name: OnPlayEffects()
// Desc: Plays all of the effects enumerated in the file
//-----------------------------------------------------------------------------
HRESULT OnPlayEffects( HWND hDlg )
{
EFFECTS_NODE* pEffectNode = g_EffectsList.pNext;
LPDIRECTINPUTEFFECT pDIEffect = NULL;
HRESULT hr; // Stop all previous forces
if( FAILED( hr = g_pFFDevice->SendForceFeedbackCommand( DISFFC_STOPALL ) ) )
return hr; while ( pEffectNode != &g_EffectsList )
{
// Play all of the effects enumerated in the file
pDIEffect = pEffectNode->pDIEffect; if( NULL != pDIEffect )
{
if( FAILED( hr = pDIEffect->Start( pEffectNode->dwPlayRepeatCount, 0 ) ) )
return hr;
} pEffectNode = pEffectNode->pNext;
} return S_OK;
}
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |