Selecting ltmmPlay Object Processors for C

The following example shows how to enumerate and select ltmmPlay object processors.

// define helper macros for using interfaces under C
#ifndef COBJMACROS
   #define COBJMACROS
#endif

#include "ltmm.h"
#include "resource.h"
#include "tchar.h"
#include "stdio.h"

HINSTANCE g_hInstance; // application instance handle
IltmmPlay* g_pPlay; // play object's interface pointer

//
// BuildProcessorList
// fills the registered processor listbox to match the contents of the collection
//
// pProcessors = processor collection's interface pointer
// hwndListBox = listbox window handle
//
void BuildProcessorList(IltmmProcessors* pProcessors, HWND hwndListBox) 
{
   long i; 
   long count; 

   // reset the listbox contents
   SendMessage(hwndListBox, LB_RESETCONTENT, 0, 0); 

   // get the collection's item count
   IltmmProcessors_get_Count (pProcessors, &count); 

   for(i = 0; i < count; i++)
   {
      IltmmProcessor* pProcessor; 
      BSTR bstr; 
      TCHAR sz[256]; 
      int index; 

      // retrieve collection item
      IltmmProcessors_Item (pProcessors, i, &pProcessor); 

      // get displayable name
      IltmmProcessor_get_FriendlyName (pProcessor, &bstr); 

      // convert from unicode
      _stprintf(sz, _T("%ls"), bstr); 

      // free name
      SysFreeString(bstr); 

      // add the name to the listbox
      index = SendMessage(hwndListBox, LB_ADDSTRING, 0, (LPARAM) (LPCTSTR) sz); 

      // associate the listbox item with the collection item index
      SendMessage(hwndListBox, LB_SETITEMDATA, index, i); 


      // free the collection item
      IUnknown_Release(pProcessor); 
   }


}

//
// BuildSelectedProcessorList
// fills the selected processor listbox to match the contents of the collection
//
// pSelProcessors = selected processor collection's interface pointer
// hwndSelListBox = selected listbox window handle
//
void BuildSelectedProcessorList(IltmmProcessors* pSelProcessors, HWND hwndSelListBox) 
{
   long i; 
   long count; 

   // reset the listbox contents
   SendMessage(hwndSelListBox, LB_RESETCONTENT, 0, 0); 

   // get the collection's item count
   IltmmProcessors_get_Count (pSelProcessors, &count); 

   for(i = 0; i < count; i++)
   {
      IltmmProcessor* pProcessor; 
      BSTR bstr; 
      TCHAR sz[256]; 

      // retrieve collection item
      IltmmProcessors_Item (pSelProcessors, i, &pProcessor); 

      // get displayable name
      IltmmProcessor_get_FriendlyName (pProcessor, &bstr); 

      // convert from unicode
      _stprintf(sz, _T("%ls"), bstr); 

      // free name
      SysFreeString(bstr); 

      // add the name to the listbox
      SendMessage(hwndSelListBox, LB_ADDSTRING, 0, (LPARAM) (LPCTSTR) sz); 


      // free the collection item
      IUnknown_Release(pProcessor); 
   }

   // add a blank entry at the end of the list and select it
   SendMessage(hwndSelListBox, LB_ADDSTRING, 0, (LPARAM) (LPVOID) _T(""));
   SendMessage(hwndSelListBox, LB_SETCURSEL, count, 0); 

}

//
// RemoveSelectedProcessor
// removes the currently selected processor
//
// pSelProcessors = selected processor collection's interface pointer
// hwndSelListBox = selected listbox window handle
//
void RemoveSelectedProcessor(IltmmProcessors* pSelProcessors, HWND hwndSelListBox) 
{
   int index; 
   int count; 


   // get the number of selected processor listbox items
   count = (int) SendMessage(hwndSelListBox, LB_GETCOUNT, 0, 0); 

   // get the deletion point from the selected processor listbox
   index = (int) SendMessage(hwndSelListBox, LB_GETCURSEL, 0, 0); 

   // if not a valid processor, then return
   if(index < 0 || index >= (count - 1)) 
      return; 

   // remove the processor from the selected processor collection
   IltmmProcessors_Remove (pSelProcessors, index); 

   // remove the name from the the selected processor listbox
   SendMessage(hwndSelListBox, LB_DELETESTRING, index, 0); 

   // select the next item in the listbox
   SendMessage(hwndSelListBox, LB_SETCURSEL, index, 0); 
}

//
// RemoveAllSelectedProcessors
// removes all selected processors
//
// pSelProcessors = selected processor collection's interface pointer
// hwndSelListBox = selected listbox window handle
//
void RemoveAllSelectedProcessors(IltmmProcessors* pSelProcessors, HWND hwndSelListBox) 
{
   IltmmProcessors_RemoveAll (pSelProcessors); 

   BuildSelectedProcessorList(pSelProcessors, hwndSelListBox); 
}

//
// InsertSelectedProcessor
// inserts the currently selected registerd processor into te selected processor collection
//
// pProcessors = registered processor collection's interface pointer
// hwndListBox = registered listbox window handle
// pSelProcessors = selected processor collection's interface pointer
// hwndSelListBox = selected listbox window handle
//
void InsertSelectedProcessor(IltmmProcessors* pProcessors, HWND hwndListBox, 
                             IltmmProcessors* pSelProcessors, HWND hwndSelListBox) 
{
   int index; 
   int selindex; 
   long item; 
   IltmmProcessor* pProcessor; 
   BSTR bstr; 
   TCHAR sz[256]; 


   // get the selection from the registered processor listbox
   index = (int) SendMessage(hwndListBox, LB_GETCURSEL, 0, 0); 
   if(index < 0) 
      return; 

   // get the collection item index
   item = (long) SendMessage(hwndListBox, LB_GETITEMDATA, index, 0); 

   // get the actual item
   IltmmProcessors_Item (pProcessors, item, &pProcessor); 

   // get the insertion point from the selected processor listbox
   selindex = (int) SendMessage(hwndSelListBox, LB_GETCURSEL, 0, 0); 

   // insert the processor into the selected processor collection
   IltmmProcessors_Add(pSelProcessors, pProcessor, selindex); 

   // get the displayable name
   IltmmProcessor_get_FriendlyName(pProcessor, &bstr); 

   // release the processor
   IUnknown_Release(pProcessor); 

   // convert from unicode
   _stprintf(sz, _T("%ls"), bstr); 

   // free name
   SysFreeString(bstr); 

   // insert the name into the selected processor listbox
   SendMessage(hwndSelListBox, LB_INSERTSTRING, selindex, (LPARAM) (LPCTSTR) sz); 


}


//
// RefreshProcessorList
// called to completely rebuild the collection
//
// pProcessors = processor collection's interface pointer
// hwndListBox = listbox window handle
//
void RefreshProcessorList(IltmmProcessors* pProcessors, HWND hwndListBox) 
{
   IltmmProcessor* pProcessor; 
   long item; 
   BSTR bstr; 
   long i; 
   long count; 

   // get the currently selected item   
   i = (int) SendMessage(hwndListBox, LB_GETCURSEL, 0, 0); 

   if(i >= 0) 
   {
      item = (long) SendMessage(hwndListBox, LB_GETITEMDATA, i, 0); 
      // get it's unique name
      IltmmProcessors_Item (pProcessors, item, &pProcessor); 
      IltmmProcessor_get_Name (pProcessor, &bstr); 
      IUnknown_Release(pProcessor); 
   }
   else
   {
      bstr = NULL; 
   }


   // rebuild the collection
   IltmmProcessors_Refresh (pProcessors); 


   // rebuild the listbox
   BuildProcessorList(pProcessors, hwndListBox); 

   if(bstr) 
   {
      // find the previously selected item
      IltmmProcessors_Find (pProcessors, bstr, &item); 

      // make it the current selection
      if(item >= 0) 
      {   
         IltmmProcessors_get_Count (pProcessors, &count); 

         // select the appropriate listbox item
         for(i = 0; i < count; i++)
         {
            if(item == (long) SendMessage(hwndListBox, LB_GETITEMDATA, i, 0)) 
            {
               SendMessage(hwndListBox, LB_SETCURSEL, i, 0); 
               break; 
            }
         }

      }      
      SysFreeString(bstr); 
   }


}


//
// ProcessorSelectionChanged
// called when the registered processor selection has changed
//
// pProcessors = processor collection's interface pointer
// hwndListBox = listbox window handle
// hwndAddBtn = add button window handle
//
void ProcessorSelectionChanged(IltmmProcessors* pProcessors, HWND hwndListBox, HWND hwndAddBtn) 
{
   int index; 

   pProcessors = pProcessors ;

   // get the currently selected listbox item
   index = (int) SendMessage(hwndListBox, LB_GETCURSEL, 0, 0); 

   // enable add, if a filter is selected
   EnableWindow(hwndAddBtn, index >= 0); 
}

//
// SelectedProcessorSelectionChanged
// called when the selected processor selection has changed
//
// pSelProcessors = processor collection's interface pointer
// hwndSelListBox = listbox window handle
// hwndRemoveBtn = remove button window handle
// hwndRemoveAllBtn = remove all button window handle
// hwndPropBtn = properties button window handle
//
void SelectedProcessorSelectionChanged(IltmmProcessors* pSelProcessors, HWND hwndSelListBox, HWND hwndRemoveBtn, HWND hwndRemoveAllBtn, HWND hwndPropBtn) 
{
   int index; 
   int count; 
   BOOL fFilter; 
   VARIANT_BOOL fHasDialog = VARIANT_FALSE; 
   HRESULT hr; 

   // get the currently selected listbox item
   index = (int) SendMessage(hwndSelListBox, LB_GETCURSEL, 0, 0); 

   // get the total item count
   count = (int) SendMessage(hwndSelListBox, LB_GETCOUNT, 0, 0); 

   // is this a filter? 
   fFilter = (index >= 0 && index < (count - 1)); 

   // enable remove all button, if there is a filter in the list
   EnableWindow(hwndRemoveAllBtn, count > 1); 

   // enable remove button, if it is a filter
   EnableWindow(hwndRemoveBtn, fFilter); 

   if(fFilter) 
   {
      // check for the availablility of a filter property dialog box
      IltmmProcessor* pProcessor; 
      hr = IltmmProcessors_Item (pSelProcessors, index, &pProcessor); 
      if(SUCCEEDED(hr)) 
      {
         IltmmProcessor_HasDialog (pProcessor, ltmmProcessor_Dlg_Properties, &fHasDialog); 
         IUnknown_Release(pProcessor); 
      }
   }
   else
   {
      fHasDialog = VARIANT_FALSE; 
   }

   // enable properties button, if dialog box is available
   EnableWindow(hwndPropBtn, fHasDialog != VARIANT_FALSE); 
}

//
// InvokeProcessorProperties
// invokes the currently selected processor's properties dialog box
//
// pSelProcessors = processor collection's interface pointer
// hwndSelListBox = listbox window handle
// hwndParent = parent window handle
//
void InvokeProcessorProperties(IltmmProcessors* pSelProcessors, HWND hwndSelListBox, HWND hwndParent) 
{
   int index; 
   int count; 
   IltmmProcessor* pProcessor; 
   HRESULT hr; 

   // get the currently selected listbox item
   index = (int) SendMessage(hwndSelListBox, LB_GETCURSEL, 0, 0); 

   // get the total item count
   count = (int) SendMessage(hwndSelListBox, LB_GETCOUNT, 0, 0); 

   // is this a filter? 
   if(index >= 0 && index < (count - 1)) 
   {
      // invoke the processor's dialog
      hr = IltmmProcessors_Item (pSelProcessors, index, &pProcessor); 
      if(SUCCEEDED(hr)) 
      {
         IltmmProcessor_ShowDialog (pProcessor, ltmmProcessor_Dlg_Properties, (long) hwndParent); 
         IUnknown_Release(pProcessor); 
      }
   }

}   

//
// ProcessorDlgProc
// selects object processors
//
BOOL CALLBACK ProcessorDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 
{
   IltmmProcessors* pProcessors; 
   IltmmProcessors* pSelProcessors; 

   lParam = lParam ;

   switch (msg) 
   {
   case WM_INITDIALOG: 
      // initialize the audio processor listbox
      IltmmPlay_get_AudioProcessors(g_pPlay, &pProcessors); 
      BuildProcessorList(pProcessors, GetDlgItem(hwnd, IDC_AUDIOPROCESSORS)); 
      ProcessorSelectionChanged(pProcessors, GetDlgItem(hwnd, IDC_AUDIOPROCESSORS), 
         GetDlgItem(hwnd, IDC_ADDAUDIOPROCESSOR)); 
      IUnknown_Release(pProcessors); 

      // initialize the selected audio processor listbox
      IltmmPlay_get_SelectedAudioProcessors(g_pPlay, &pSelProcessors); 
      BuildSelectedProcessorList(pSelProcessors, GetDlgItem(hwnd, IDC_SELAUDIOPROCESSORS)); 
      SelectedProcessorSelectionChanged(pSelProcessors, GetDlgItem(hwnd, IDC_SELAUDIOPROCESSORS), 
         GetDlgItem(hwnd, IDC_REMOVEAUDIOPROCESSOR), 
         GetDlgItem(hwnd, IDC_REMOVEALLAUDIOPROCESSORS), 
         GetDlgItem(hwnd, IDC_AUDIOPROCESSORPROPERTIES)); 
      IUnknown_Release(pSelProcessors); 

      // initialize the video processor listbox
      IltmmPlay_get_VideoProcessors (g_pPlay, &pProcessors); 
      BuildProcessorList(pProcessors, GetDlgItem(hwnd, IDC_VIDEOPROCESSORS)); 
      ProcessorSelectionChanged(pProcessors, GetDlgItem(hwnd, IDC_VIDEOPROCESSORS), 
         GetDlgItem(hwnd, IDC_ADDVIDEOPROCESSOR)); 
      IUnknown_Release(pProcessors); 

      // initialize the selected video processor listbox
      IltmmPlay_get_SelectedVideoProcessors(g_pPlay, &pSelProcessors); 
      BuildSelectedProcessorList(pSelProcessors, GetDlgItem(hwnd, IDC_SELVIDEOPROCESSORS)); 
      SelectedProcessorSelectionChanged(pSelProcessors, GetDlgItem(hwnd, IDC_SELVIDEOPROCESSORS), 
         GetDlgItem(hwnd, IDC_REMOVEVIDEOPROCESSOR), 
         GetDlgItem(hwnd, IDC_REMOVEALLVIDEOPROCESSORS), 
         GetDlgItem(hwnd, IDC_VIDEOPROCESSORPROPERTIES)); 
      IUnknown_Release(pSelProcessors); 

      return TRUE; 
      break; 

   case WM_COMMAND: 
      switch(LOWORD(wParam)) 
      {
      case IDC_ADDAUDIOPROCESSOR: 
         // insert processor into selected audio processor collection
         IltmmPlay_get_AudioProcessors(g_pPlay, &pProcessors); 
         IltmmPlay_get_SelectedAudioProcessors(g_pPlay, &pSelProcessors); 
         InsertSelectedProcessor(pProcessors, GetDlgItem(hwnd, IDC_AUDIOPROCESSORS), 
            pSelProcessors, GetDlgItem(hwnd, IDC_SELAUDIOPROCESSORS)); 
         SelectedProcessorSelectionChanged(pSelProcessors, GetDlgItem(hwnd, IDC_SELAUDIOPROCESSORS), 
            GetDlgItem(hwnd, IDC_REMOVEAUDIOPROCESSOR), 
            GetDlgItem(hwnd, IDC_REMOVEALLAUDIOPROCESSORS), 
            GetDlgItem(hwnd, IDC_AUDIOPROCESSORPROPERTIES)); 
         IUnknown_Release(pSelProcessors); 
         IUnknown_Release(pProcessors); 
         return TRUE; 
         break; 
      case IDC_REMOVEAUDIOPROCESSOR: 
         // remove processor from the selected audio processor collection
         IltmmPlay_get_SelectedAudioProcessors(g_pPlay, &pSelProcessors); 
         RemoveSelectedProcessor(pSelProcessors, GetDlgItem(hwnd, IDC_SELAUDIOPROCESSORS)); 
         SelectedProcessorSelectionChanged(pSelProcessors, GetDlgItem(hwnd, IDC_SELAUDIOPROCESSORS), 
            GetDlgItem(hwnd, IDC_REMOVEAUDIOPROCESSOR), 
            GetDlgItem(hwnd, IDC_REMOVEALLAUDIOPROCESSORS), 
            GetDlgItem(hwnd, IDC_AUDIOPROCESSORPROPERTIES)); 
         IUnknown_Release(pSelProcessors); 
         return TRUE; 
         break; 
      case IDC_REMOVEALLAUDIOPROCESSORS: 
         // remove all selected audio processors
         IltmmPlay_get_SelectedAudioProcessors(g_pPlay, &pSelProcessors); 
         RemoveAllSelectedProcessors(pSelProcessors, GetDlgItem(hwnd, IDC_SELAUDIOPROCESSORS)); 
         SelectedProcessorSelectionChanged(pSelProcessors, GetDlgItem(hwnd, IDC_SELAUDIOPROCESSORS), 
            GetDlgItem(hwnd, IDC_REMOVEAUDIOPROCESSOR), 
            GetDlgItem(hwnd, IDC_REMOVEALLAUDIOPROCESSORS), 
            GetDlgItem(hwnd, IDC_AUDIOPROCESSORPROPERTIES)); 
         IUnknown_Release(pSelProcessors); 
         return TRUE; 
         break; 
      case IDC_REFRESHAUDIOPROCESSORS: 
         // rebuild the registered audio processor collection
         IltmmPlay_get_AudioProcessors(g_pPlay, &pProcessors); 
         RefreshProcessorList(pProcessors, GetDlgItem(hwnd, IDC_AUDIOPROCESSORS)); 
         ProcessorSelectionChanged(pProcessors, GetDlgItem(hwnd, IDC_AUDIOPROCESSORS), 
            GetDlgItem(hwnd, IDC_ADDAUDIOPROCESSOR)); 
         IUnknown_Release(pProcessors); 
         return TRUE; 
         break; 
      case IDC_AUDIOPROCESSORPROPERTIES: 
         // invoke the selected audio processor's properties dialog box
         IltmmPlay_get_SelectedAudioProcessors(g_pPlay, &pSelProcessors); 
         InvokeProcessorProperties(pSelProcessors, GetDlgItem(hwnd, IDC_SELAUDIOPROCESSORS), hwnd); 
         IUnknown_Release(pSelProcessors); 
         return TRUE; 
         break; 
      case IDC_SELAUDIOPROCESSORS: 
         if(HIWORD(wParam) == LBN_SELCHANGE) 
         {
            // selection changed, update buttons
            IltmmPlay_get_SelectedAudioProcessors(g_pPlay, &pSelProcessors); 
            SelectedProcessorSelectionChanged(pSelProcessors, GetDlgItem(hwnd, IDC_SELAUDIOPROCESSORS), 
               GetDlgItem(hwnd, IDC_REMOVEAUDIOPROCESSOR), 
               GetDlgItem(hwnd, IDC_REMOVEALLAUDIOPROCESSORS), 
               GetDlgItem(hwnd, IDC_AUDIOPROCESSORPROPERTIES)); 
            IUnknown_Release(pSelProcessors); 
         }
         break; 
      case IDC_AUDIOPROCESSORS: 
         if(HIWORD(wParam) == LBN_SELCHANGE) 
         {
            // selection changed, update buttons
            IltmmPlay_get_AudioProcessors(g_pPlay, &pProcessors); 
            ProcessorSelectionChanged(pProcessors, GetDlgItem(hwnd, IDC_AUDIOPROCESSORS), 
               GetDlgItem(hwnd, IDC_ADDAUDIOPROCESSOR)); 
            IUnknown_Release(pProcessors); 
         }
         break; 
      case IDC_ADDVIDEOPROCESSOR: 
         // insert processor into selected video processor collection
         IltmmPlay_get_VideoProcessors (g_pPlay, &pProcessors); 
         IltmmPlay_get_SelectedVideoProcessors(g_pPlay, &pSelProcessors); 
         InsertSelectedProcessor(pProcessors, GetDlgItem(hwnd, IDC_VIDEOPROCESSORS), 
            pSelProcessors, GetDlgItem(hwnd, IDC_SELVIDEOPROCESSORS)); 
         SelectedProcessorSelectionChanged(pSelProcessors, GetDlgItem(hwnd, IDC_SELVIDEOPROCESSORS), 
            GetDlgItem(hwnd, IDC_REMOVEVIDEOPROCESSOR), 
            GetDlgItem(hwnd, IDC_REMOVEALLVIDEOPROCESSORS), 
            GetDlgItem(hwnd, IDC_VIDEOPROCESSORPROPERTIES)); 
         IUnknown_Release(pSelProcessors); 
         IUnknown_Release(pProcessors); 
         return TRUE; 
         break; 
      case IDC_REMOVEVIDEOPROCESSOR: 
         // remove processor from the selected video processor collection
         IltmmPlay_get_SelectedVideoProcessors(g_pPlay, &pSelProcessors); 
         RemoveSelectedProcessor(pSelProcessors, GetDlgItem(hwnd, IDC_SELVIDEOPROCESSORS)); 
         SelectedProcessorSelectionChanged(pSelProcessors, GetDlgItem(hwnd, IDC_SELVIDEOPROCESSORS), 
            GetDlgItem(hwnd, IDC_REMOVEVIDEOPROCESSOR), 
            GetDlgItem(hwnd, IDC_REMOVEALLVIDEOPROCESSORS), 
            GetDlgItem(hwnd, IDC_VIDEOPROCESSORPROPERTIES)); 
         IUnknown_Release(pSelProcessors); 
         return TRUE; 
         break; 
      case IDC_REMOVEALLVIDEOPROCESSORS: 
         // remove all selected video processors
         IltmmPlay_get_SelectedVideoProcessors(g_pPlay, &pSelProcessors); 
         RemoveAllSelectedProcessors(pSelProcessors, GetDlgItem(hwnd, IDC_SELVIDEOPROCESSORS)); 
         SelectedProcessorSelectionChanged(pSelProcessors, GetDlgItem(hwnd, IDC_SELVIDEOPROCESSORS), 
            GetDlgItem(hwnd, IDC_REMOVEVIDEOPROCESSOR), 
            GetDlgItem(hwnd, IDC_REMOVEALLVIDEOPROCESSORS), 
            GetDlgItem(hwnd, IDC_VIDEOPROCESSORPROPERTIES)); 
         IUnknown_Release(pSelProcessors); 
         return TRUE; 
         break; 
      case IDC_REFRESHVIDEOPROCESSORS: 
         // rebuild the registered video processor collection
         IltmmPlay_get_VideoProcessors (g_pPlay, &pProcessors); 
         RefreshProcessorList(pProcessors, GetDlgItem(hwnd, IDC_VIDEOPROCESSORS)); 
         ProcessorSelectionChanged(pProcessors, GetDlgItem(hwnd, IDC_VIDEOPROCESSORS), 
            GetDlgItem(hwnd, IDC_ADDVIDEOPROCESSOR)); 
         IUnknown_Release(pProcessors); 
         return TRUE; 
         break; 
      case IDC_VIDEOPROCESSORPROPERTIES: 
         // invoke the selected video processor's properties dialog box
         IltmmPlay_get_SelectedVideoProcessors(g_pPlay, &pSelProcessors); 
         InvokeProcessorProperties(pSelProcessors, GetDlgItem(hwnd, IDC_SELVIDEOPROCESSORS), hwnd); 
         IUnknown_Release(pSelProcessors); 
         return TRUE; 
         break; 
      case IDC_SELVIDEOPROCESSORS: 
         if(HIWORD(wParam) == LBN_SELCHANGE) 
         {
            // selection changed, update buttons
            IltmmPlay_get_SelectedVideoProcessors(g_pPlay, &pSelProcessors); 
            SelectedProcessorSelectionChanged(pSelProcessors, GetDlgItem(hwnd, IDC_SELVIDEOPROCESSORS), 
               GetDlgItem(hwnd, IDC_REMOVEVIDEOPROCESSOR), 
               GetDlgItem(hwnd, IDC_REMOVEALLVIDEOPROCESSORS), 
               GetDlgItem(hwnd, IDC_VIDEOPROCESSORPROPERTIES)); 
            IUnknown_Release(pSelProcessors); 
         }
         break; 
      case IDC_VIDEOPROCESSORS: 
         if(HIWORD(wParam) == LBN_SELCHANGE) 
         {
            // selection changed, update buttons
            IltmmPlay_get_VideoProcessors (g_pPlay, &pProcessors); 
            ProcessorSelectionChanged(pProcessors, GetDlgItem(hwnd, IDC_VIDEOPROCESSORS), 
               GetDlgItem(hwnd, IDC_ADDVIDEOPROCESSOR)); 
            IUnknown_Release(pProcessors); 
         }
         break; 

      case IDOK: 
         EndDialog(hwnd, IDOK); 
         return TRUE; 
         break; 
      }
      break; 
   }
   return FALSE; 

}

void SelectingltmmPlayObjectProcessors_Example ( HINSTANCE hInstance /*application instance handle*/ )
{
   HRESULT hr; 

   g_hInstance = hInstance; 

   // initialize COM library
   hr = CoInitialize(NULL); 
   if(FAILED(hr)) 
      goto error; 

   // create the play object
   hr = CoCreateInstance(&CLSID_ltmmPlay, NULL, CLSCTX_INPROC_SERVER, &IID_IltmmPlay, (void**) &g_pPlay); 
   if(FAILED(hr)) 
      goto error; 


   DialogBox(g_hInstance, (LPCTSTR)IDD_PROCESSORDLG, NULL, ProcessorDlgProc); 


error: 
   // cleanup

   if(g_pPlay) 
      IUnknown_Release(g_pPlay); 

   CoUninitialize();
}