home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 November / CMCD1104.ISO / Software / Shareware / Programare / skincraft / SkinCrafter_v1.4.12_Demo.msi / _49E29CB9A65AABBF653C1037E1AA74B6 / _8B97D85EFEA44BE0A3426FF4EE509442 < prev    next >
Encoding:
Text File  |  2004-03-17  |  5.4 KB  |  229 lines

  1. // PlayListDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "SCPlayer.h"
  6. #include "PlayListDlg.h"
  7. #include "PlayerControlDlg.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. //////////////////////////////////////////////////////////////////////////
  16. LRESULT CPlayListBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
  17. {
  18.     switch(message) 
  19.     {
  20.         case WM_LBUTTONDBLCLK:
  21.             ((CPlayListDlg*)GetParent())->SetCurFileID(GetCurSel());
  22.             ((CPlayerControlDlg*)AfxGetMainWnd())->PlayNew();
  23.             break;
  24.     }
  25.     return CListBox::WindowProc(message, wParam, lParam);
  26. }
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CPlayListDlg dialog
  29.  
  30.  
  31. CPlayListDlg::CPlayListDlg(CWnd* pParent /*=NULL*/)
  32.     : CDialog(CPlayListDlg::IDD, pParent),m_CurFileID(-1)
  33. {
  34.     //{{AFX_DATA_INIT(CPlayListDlg)
  35.         // NOTE: the ClassWizard will add member initialization here
  36.     //}}AFX_DATA_INIT
  37. }
  38.  
  39.  
  40. void CPlayListDlg::DoDataExchange(CDataExchange* pDX)
  41. {
  42.     CDialog::DoDataExchange(pDX);
  43.     //{{AFX_DATA_MAP(CPlayListDlg)
  44.         // NOTE: the ClassWizard will add DDX and DDV calls here
  45.     //}}AFX_DATA_MAP
  46. }
  47.  
  48.  
  49. BEGIN_MESSAGE_MAP(CPlayListDlg, CDialog)
  50.     //{{AFX_MSG_MAP(CPlayListDlg)
  51.     ON_BN_CLICKED(IDC_ADDTOPLAYLIST, OnAddFiles)
  52.     ON_BN_CLICKED(IDC_DELFORMPLAYLIST, OnDeleteFiles)
  53.     ON_WM_SIZE()
  54.     ON_WM_CLOSE()
  55.     //}}AFX_MSG_MAP
  56. END_MESSAGE_MAP()
  57.  
  58. /////////////////////////////////////////////////////////////////////////////
  59. // CPlayListDlg message handlers
  60.  
  61. void CPlayListDlg::OnAddFiles() 
  62. {
  63.     CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT);
  64.     if(dlg.DoModal()==IDOK)
  65.     {
  66.         POSITION pos = dlg.GetStartPosition();
  67.         while (pos) 
  68.         {
  69.             CString path = dlg.GetNextPathName(pos);
  70.             AddFile(path);
  71.         }
  72.         FillPlayList();
  73.         if(m_CurFileID<0)
  74.         {
  75.             SetCurFileID(0);
  76.         }
  77.     }
  78. }
  79.  
  80. void CPlayListDlg::OnDeleteFiles() 
  81. {
  82.     CListBox* pList = ((CListBox*)GetDlgItem(IDC_THELIST));
  83.     CString key;
  84.  
  85.     int i = pList->GetCurSel();
  86.     if(i>LB_ERR)
  87.     {
  88.         pList->GetText(i,key);
  89.         m_PlayListMap.RemoveKey(key);
  90.     }
  91.  
  92.     FillPlayList();
  93. }
  94. void CPlayListDlg::OnSize(UINT nType, int cx, int cy) 
  95. {
  96.     CDialog::OnSize(nType, cx, cy);
  97.     
  98.     CWnd* pWnd = GetDlgItem(IDC_THELIST);
  99.     if (pWnd)
  100.         pWnd->MoveWindow(0,0,cx,cy-12);
  101.     pWnd = GetDlgItem(IDC_ADDTOPLAYLIST);
  102.     if (pWnd) 
  103.         pWnd->MoveWindow(0,cy-11,32,10);
  104.     pWnd = GetDlgItem(IDC_DELFORMPLAYLIST);
  105.     if (pWnd) 
  106.         pWnd->MoveWindow(33,cy-11,32,10);
  107. }
  108.  
  109. BOOL CPlayListDlg::OnInitDialog() 
  110. {
  111.     CDialog::OnInitDialog();
  112.     
  113.     theApp.m_pSkin->IncludeWnd((long)m_hWnd,TRUE);
  114.     theApp.m_pSkin->SetCustomSkinWnd((long)m_hWnd,"PlayerFrame",TRUE);
  115.     theApp.m_pSkin->SetCustomSkinWnd((long)m_hWnd,"PlayListDialog",FALSE);
  116.     
  117.     //Do it only to have a button name in dialog editor
  118.     GetDlgItem(IDC_ADDTOPLAYLIST)->SetWindowText("");
  119.     theApp.m_pSkin->SetCustomSkinWnd((long)GetDlgItem(IDC_ADDTOPLAYLIST)->m_hWnd,"AddButton",FALSE);
  120.  
  121.     //Do it only to have a button name in dialog editor
  122.     GetDlgItem(IDC_DELFORMPLAYLIST)->SetWindowText("");
  123.     theApp.m_pSkin->SetCustomSkinWnd((long)GetDlgItem(IDC_DELFORMPLAYLIST)->m_hWnd,"DelButton",FALSE);
  124.  
  125.     CRect r;
  126.     GetWindowRect(&r);
  127.  
  128.     r.left+=1;
  129.     MoveWindow(r);
  130.     
  131.     CListBox* pList = ((CListBox*)GetDlgItem(IDC_THELIST));
  132.     
  133.     m_myLb.SubclassDlgItem(IDC_THELIST,this);
  134.  
  135.     return TRUE;  // return TRUE unless you set the focus to a control
  136.                   // EXCEPTION: OCX Property Pages should return FALSE
  137. }
  138.  
  139. void CPlayListDlg::OnClose() 
  140. {
  141.     ShowWindow(SW_HIDE)    ;
  142.     //CDialog::OnClose();
  143. }
  144.  
  145. CString CPlayListDlg::GetCurMediaPath()
  146. {
  147.     if(m_CurFileID<0)
  148.         return "";
  149.     CListBox* pList = ((CListBox*)GetDlgItem(IDC_THELIST));    
  150.     CString str;
  151.     pList->GetText(m_CurFileID,str);
  152.     CString thepath;
  153.     if(!m_PlayListMap.Lookup(str, thepath))
  154.         return "";
  155.     else
  156.         return thepath;
  157. }
  158.  
  159. CString CPlayListDlg::GetNextMediaPath()
  160. {
  161.     if(m_CurFileID<0)
  162.         return "";
  163.     if(m_CurFileID<m_PlayListMap.GetCount()-1)
  164.     m_CurFileID++;
  165.     
  166.     CListBox* pList = ((CListBox*)GetDlgItem(IDC_THELIST));    
  167.     CString str;
  168.     pList->GetText(m_CurFileID,str);
  169.     CString thepath;
  170.     if(!m_PlayListMap.Lookup(str, thepath))
  171.         return "";
  172.     else
  173.         return thepath;
  174. }
  175. CString CPlayListDlg::GetPrevMediaPath()
  176. {
  177.     if(m_CurFileID<0)
  178.         return "";
  179.     if (m_CurFileID>0) 
  180.         m_CurFileID--;
  181.     
  182.     CListBox* pList = ((CListBox*)GetDlgItem(IDC_THELIST));    
  183.     CString str;
  184.     pList->GetText(m_CurFileID,str);
  185.     CString thepath;
  186.     if(!m_PlayListMap.Lookup(str, thepath))
  187.         return "";
  188.     else
  189.         return thepath;
  190. }
  191.  
  192. void CPlayListDlg::FillPlayList()
  193. {
  194.     CListBox* pList = ((CListBox*)GetDlgItem(IDC_THELIST));    
  195.     pList->ResetContent();
  196.     POSITION pos = m_PlayListMap.GetStartPosition();
  197.     CString fname, path; 
  198.     int i=0;
  199.     while (pos) 
  200.     {
  201.         m_PlayListMap.GetNextAssoc(pos,fname,path);
  202.         pList->InsertString(i++,fname);
  203.     }
  204.  
  205.     if(m_PlayListMap.GetCount() == 0)
  206.         SetCurFileID(-1);
  207. }
  208.  
  209. void CPlayListDlg::SetCurFileID(int curId)
  210. {
  211.     m_CurFileID = curId;
  212.     CListBox* pList = ((CListBox*)GetDlgItem(IDC_THELIST));
  213.     CString str;
  214.     pList->GetText(m_CurFileID,str);
  215.     pList->SelectString(m_CurFileID,str);
  216. }
  217.  
  218. void CPlayListDlg::AddFile(CString fullpath)
  219. {
  220.     char drive[_MAX_DRIVE]="";
  221.     char dir[_MAX_DIR]="";
  222.     char fname[_MAX_FNAME]="";
  223.     char ext[_MAX_EXT]="";
  224.  
  225.     CString fkeyname;
  226.     _splitpath(fullpath,drive,dir,fname,ext);
  227.     fkeyname.Format("%s%s",fname,ext);
  228.     m_PlayListMap.SetAt(fkeyname,fullpath);
  229. }