Пример #1
0
BOOL CALLBACK RecordDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
 switch(uMsg)
  {
   //--------------------------------------------------// init
   case WM_INITDIALOG:
    {
     SetDlgItemText(hW,IDC_WAVFILE,"C:\\PEOPS.WAV");   // init filename edit
     ShowCursor(TRUE);                                 // mmm... who is hiding it? main emu? tsts
     return TRUE;
    }
   //--------------------------------------------------// destroy
   case WM_DESTROY:
    {
     RecordStop();
    }break;
   //--------------------------------------------------// command
   case WM_COMMAND:
    {
     if(wParam==IDCANCEL) iRecordMode=2;               // cancel? raise flag for destroying the dialog

     if(wParam==IDC_RECORD)                            // record start/stop?
      {
       if(IsWindowEnabled(GetDlgItem(hW,IDC_WAVFILE))) // not started yet (edit is not disabled):
        {
         GetDlgItemText(hW,IDC_WAVFILE,szFileName,255);// get filename

         RecordStart();                                // start recording

         if(hWaveFile)                                 // start was ok?
          {                                            // -> disable filename edit, change text, raise flag
           EnableWindow(GetDlgItem(hW,IDC_WAVFILE),FALSE);
           SetDlgItemText(hW,IDC_RECORD,"Stop recording");
           iDoRecord=1;
          }
         else MessageBeep(0xFFFFFFFF);                 // error starting recording? BEEP
        }
       else                                            // stop recording?
        {
         RecordStop();                                 // -> just do it
         EnableWindow(GetDlgItem(hW,IDC_WAVFILE),TRUE);// -> enable filename edit again
         SetDlgItemText(hW,IDC_RECORD,"Start recording");
        }
       SetFocus(hWMain);
      }
    }break;
   //--------------------------------------------------// size
   case WM_SIZE:
    if(wParam==SIZE_MINIMIZED) SetFocus(hWMain);       // if we get minimized, set the foxus to the main window
    break;
   //--------------------------------------------------// setcursor
   case WM_SETCURSOR:
    {
     SetCursor(LoadCursor(NULL,IDC_ARROW));            // force the arrow 
     return TRUE;
    }
   //--------------------------------------------------//
  }
 return FALSE;
}
Пример #2
0
void RemoveSound(void)
{
 int iRes;

 if(iDoRecord) RecordStop();

 if(lpDSBSECONDARY1!=NULL)
  {
   IDirectSoundBuffer_Stop(lpDSBSECONDARY1);
   iRes=IDirectSoundBuffer_Release(lpDSBSECONDARY1);
   // FF says such a loop is bad... Demo says it's good... Pete doesn't care
   while(iRes!=0) iRes=IDirectSoundBuffer_Release(lpDSBSECONDARY1);
   lpDSBSECONDARY1=NULL;
  }

 if(lpDSBPRIMARY!=NULL)
  {
   IDirectSoundBuffer_Stop(lpDSBPRIMARY);
   iRes=IDirectSoundBuffer_Release(lpDSBPRIMARY);
   // FF says such a loop is bad... Demo says it's good... Pete doesn't care
   while(iRes!=0) iRes=IDirectSoundBuffer_Release(lpDSBPRIMARY);
   lpDSBPRIMARY=NULL;
  }

 if(lpDS!=NULL)
  {
   iRes=IDirectSound_Release(lpDS);
   // FF says such a loop is bad... Demo says it's good... Pete doesn't care
   while(iRes!=0) iRes=IDirectSound_Release(lpDS);
   lpDS=NULL;
  }

}