SelectMediaType.cpp

00001 /* 
00002  *      Copyright (C) 2003-2005 Gabest
00003  *      http://www.gabest.org
00004  *
00005  *  This Program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2, or (at your option)
00008  *  any later version.
00009  *   
00010  *  This Program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  *  GNU General Public License for more details.
00014  *   
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with GNU Make; see the file COPYING.  If not, write to
00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
00018  *  http://www.gnu.org/copyleft/gpl.html
00019  *
00020  */
00021 
00022 // SelectMediaType.cpp : implementation file
00023 //
00024 
00025 #include "stdafx.h"
00026 #include "mplayerc.h"
00027 #include "SelectMediaType.h"
00028 #include "..\..\DSUtil\DSUtil.h"
00029 
00030 
00031 // CSelectMediaType dialog
00032 
00033 IMPLEMENT_DYNAMIC(CSelectMediaType, CCmdUIDialog)
00034 CSelectMediaType::CSelectMediaType(CArray<GUID>& guids, GUID guid, CWnd* pParent /*=NULL*/)
00035         : CCmdUIDialog(CSelectMediaType::IDD, pParent)
00036         , m_guids(guids), m_guid(guid)
00037 {
00038         m_guidstr = CStringFromGUID(guid);
00039 }
00040 
00041 CSelectMediaType::~CSelectMediaType()
00042 {
00043 }
00044 
00045 void CSelectMediaType::DoDataExchange(CDataExchange* pDX)
00046 {
00047         __super::DoDataExchange(pDX);
00048         DDX_CBString(pDX, IDC_COMBO1, m_guidstr);
00049         DDX_Control(pDX, IDC_COMBO1, m_guidsctrl);
00050 }
00051 
00052 
00053 BEGIN_MESSAGE_MAP(CSelectMediaType, CCmdUIDialog)
00054         ON_CBN_EDITCHANGE(IDC_COMBO1, OnCbnEditchangeCombo1)
00055         ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOK)
00056 END_MESSAGE_MAP()
00057 
00058 
00059 // CSelectMediaType message handlers
00060 
00061 BOOL CSelectMediaType::OnInitDialog()
00062 {
00063         CCmdUIDialog::OnInitDialog();
00064 
00065         for(int i = 0; i < m_guids.GetCount(); i++)
00066         {
00067                 m_guidsctrl.AddString(GetMediaTypeName(m_guids[i]));
00068         }
00069 
00070         return TRUE;  // return TRUE unless you set the focus to a control
00071         // EXCEPTION: OCX Property Pages should return FALSE
00072 }
00073 
00074 void CSelectMediaType::OnCbnEditchangeCombo1()
00075 {
00076         UpdateData();
00077         int i = m_guidsctrl.FindStringExact(0, m_guidstr);
00078         if(i >= 0)
00079         {
00080                 DWORD sel = m_guidsctrl.GetEditSel();
00081                 m_guidsctrl.SetCurSel(i);
00082                 m_guidsctrl.SetEditSel(sel,sel);
00083         }
00084 }
00085 
00086 void CSelectMediaType::OnUpdateOK(CCmdUI* pCmdUI)
00087 {
00088         UpdateData();
00089 
00090         pCmdUI->Enable(!m_guidstr.IsEmpty() && (m_guidsctrl.GetCurSel() >= 0 || GUIDFromCString(m_guidstr) != GUID_NULL));
00091 }
00092 
00093 void CSelectMediaType::OnOK()
00094 {
00095         UpdateData();
00096 
00097         int i = m_guidsctrl.GetCurSel();
00098         m_guid = i >= 0 ? m_guids[i] : GUIDFromCString(m_guidstr);
00099 
00100         CCmdUIDialog::OnOK();
00101 }

Generated on Tue Dec 13 14:47:04 2005 for guliverkli by  doxygen 1.4.5