void CPPageFormats::OnBnClickedButton12() { int i = m_list.GetSelectionMark(); if(i < 0) return; i = (int)m_list.GetItemData(i); CMediaFormats& mf = AfxGetAppSettings().Formats; mf[i].RestoreDefaultExts(); m_exts = mf[i].GetExtsWithPeriod(); SetListItemState(m_list.GetSelectionMark()); UpdateData(FALSE); SetModified(); }
void CPPageFormats::OnBnVistaModify() { CString strCmd; TCHAR strApp [_MAX_PATH]; strCmd.Format (_T("/adminoption %d"), IDD); GetModuleFileNameEx (GetCurrentProcess(), AfxGetMyApp()->m_hInstance, strApp, MAX_PATH); AfxGetMyApp()->RunAsAdministrator (strApp, strCmd, true); for(int i = 0; i < m_list.GetItemCount(); i++) SetListItemState(i); }
BOOL CPPageFormats::OnInitDialog() { __super::OnInitDialog(); m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT); m_list.InsertColumn(COL_CATEGORY, _T("Category"), LVCFMT_LEFT, 300); m_list.InsertColumn(COL_ENGINE, _T("Engine"), LVCFMT_RIGHT, 60); m_onoff.Create(IDB_ONOFF, 12, 3, 0xffffff); m_list.SetImageList(&m_onoff, LVSIL_SMALL); CMediaFormats& mf = AfxGetAppSettings().Formats; mf.UpdateData(FALSE); for(int i = 0; i < (int)mf.GetCount(); i++) { CString label; label.Format (_T("%s (%s)"), mf[i].GetLabel(), mf[i].GetExts()); int iItem = m_list.InsertItem(i, label); m_list.SetItemData(iItem, i); engine_t e = mf[i].GetEngineType(); m_list.SetItemText(iItem, COL_ENGINE, e == DirectShow ? _T("DirectShow") : e == RealMedia ? _T("RealMedia") : e == QuickTime ? _T("QuickTime") : e == ShockWave ? _T("ShockWave") : _T("-")); } // m_list.SetColumnWidth(COL_CATEGORY, LVSCW_AUTOSIZE); m_list.SetColumnWidth(COL_ENGINE, LVSCW_AUTOSIZE_USEHEADER); m_list.SetSelectionMark(0); m_list.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED); m_exts = mf[(int)m_list.GetItemData(0)].GetExtsWithPeriod(); AppSettings& s = AfxGetAppSettings(); bool fRtspFileExtFirst; engine_t e = s.Formats.GetRtspHandler(fRtspFileExtFirst); m_iRtspHandler = (e==RealMedia?0:e==QuickTime?1:2); m_fRtspFileExtFirst = fRtspFileExtFirst; UpdateData(FALSE); f_setContextFiles = 0; for(int i = 0; i < m_list.GetItemCount(); i++) { SetListItemState(i); } m_fContextFiles.SetCheck(f_setContextFiles); if(AfxGetAppSettings().fXpOrBetter) { m_apvideo.SetCheck(IsAutoPlayRegistered(AP_VIDEO)); m_apmusic.SetCheck(IsAutoPlayRegistered(AP_MUSIC)); m_apaudiocd.SetCheck(IsAutoPlayRegistered(AP_AUDIOCD)); m_apdvd.SetCheck(IsAutoPlayRegistered(AP_DVDMOVIE)); } else { m_autoplay.ShowWindow(SW_HIDE); m_apvideo.ShowWindow(SW_HIDE); m_apmusic.ShowWindow(SW_HIDE); m_apaudiocd.ShowWindow(SW_HIDE); m_apdvd.ShowWindow(SW_HIDE); } CreateToolTip(); if (IsVistaOrAbove() && !IsUserAnAdmin()) { GetDlgItem(IDC_BUTTON1)->ShowWindow (SW_HIDE); GetDlgItem(IDC_BUTTON3)->ShowWindow (SW_HIDE); GetDlgItem(IDC_BUTTON4)->ShowWindow (SW_HIDE); GetDlgItem(IDC_CHECK1)->EnableWindow (FALSE); GetDlgItem(IDC_CHECK2)->EnableWindow (FALSE); GetDlgItem(IDC_CHECK3)->EnableWindow (FALSE); GetDlgItem(IDC_CHECK4)->EnableWindow (FALSE); GetDlgItem(IDC_CHECK5)->EnableWindow (FALSE); GetDlgItem(IDC_RADIO1)->EnableWindow (FALSE); GetDlgItem(IDC_RADIO2)->EnableWindow (FALSE); GetDlgItem(IDC_RADIO3)->EnableWindow (FALSE); GetDlgItem(IDC_BUTTON5)->ShowWindow (SW_SHOW); GetDlgItem(IDC_BUTTON5)->SendMessage (BCM_SETSHIELD, 0, 1); m_bInsufficientPrivileges = true; } else GetDlgItem(IDC_BUTTON5)->ShowWindow (SW_HIDE); CRegKey key; TCHAR buff[_MAX_PATH]; ULONG len = sizeof(buff); int fContextDir = 0; if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.play\\command"), KEY_READ)) { CString strCommand = GetOpenCommand(); if (ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len)) fContextDir = (strCommand.CompareNoCase(CString(buff)) == 0); } m_fContextDir.SetCheck(fContextDir); m_fAssociatedWithIcons.SetCheck(s.fAssociatedWithIcons); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
BOOL CPPageFormats::OnApply() { UpdateData(); { int i = m_list.GetSelectionMark(); if(i >= 0) i = (int)m_list.GetItemData(i); if(i >= 0) { CMediaFormats& mf = AfxGetAppSettings().Formats; mf[i].SetExts(m_exts); m_exts = mf[i].GetExtsWithPeriod(); UpdateData(FALSE); } } CMediaFormats& mf = AfxGetAppSettings().Formats; CString AppIcon = _T(""); TCHAR buff[_MAX_PATH]; if(::GetModuleFileName(AfxGetInstanceHandle(), buff, MAX_PATH)) { AppIcon = buff; AppIcon = "\""+AppIcon+"\""; AppIcon += _T(",0"); } if (m_pAAR) { // Register MPC for the windows "Default application" manager CRegKey key; if(ERROR_SUCCESS == key.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\RegisteredApplications"))) { key.SetStringValue(_T("Media Player Classic"), g_strRegisteredKey); if(ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE, g_strRegisteredKey)) return(false); // ==>> TODO icon !!! key.SetStringValue(_T("ApplicationDescription"), ResStr(IDS_APP_DESCRIPTION), REG_EXPAND_SZ); key.SetStringValue(_T("ApplicationIcon"), AppIcon, REG_EXPAND_SZ); key.SetStringValue(_T("ApplicationName"), ResStr(IDR_MAINFRAME), REG_EXPAND_SZ); } } f_setContextFiles = m_fContextFiles.GetCheck(); f_setAssociatedWithIcon = m_fAssociatedWithIcons.GetCheck(); for(int i = 0; i < m_list.GetItemCount(); i++) { int iChecked = GetChecked(i); if(iChecked == 2) continue; CAtlList<CString> exts; Explode(mf[(int)m_list.GetItemData(i)].GetExtsWithPeriod(), exts, ' '); POSITION pos = exts.GetHeadPosition(); while(pos) RegisterExt(exts.GetNext(pos), mf[(int)m_list.GetItemData(i)].GetLabel(), !!iChecked); } CRegKey key; if(m_fContextDir.GetCheck()) { if(ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.enqueue"))) { key.SetStringValue(NULL, ResStr(IDS_ADD_TO_PLAYLIST)); } if(ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.enqueue\\command"))) { key.SetStringValue(NULL, GetEnqueueCommand()); } if(ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.play"))) { key.SetStringValue(NULL, ResStr(IDS_OPEN_WITH_MPC)); } if(ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.play\\command"))) { key.SetStringValue(NULL, GetOpenCommand()); } } else { key.Attach(HKEY_CLASSES_ROOT); key.RecurseDeleteKey(_T("Directory\\shell\\mplayerc.enqueue")); key.RecurseDeleteKey(_T("Directory\\shell\\mplayerc.play")); } { SetListItemState(m_list.GetSelectionMark()); } AddAutoPlayToRegistry(AP_VIDEO, !!m_apvideo.GetCheck()); AddAutoPlayToRegistry(AP_MUSIC, !!m_apmusic.GetCheck()); AddAutoPlayToRegistry(AP_AUDIOCD, !!m_apaudiocd.GetCheck()); AddAutoPlayToRegistry(AP_DVDMOVIE, !!m_apdvd.GetCheck()); AppSettings& s = AfxGetAppSettings(); s.Formats.SetRtspHandler(m_iRtspHandler==0?RealMedia:m_iRtspHandler==1?QuickTime:DirectShow, !!m_fRtspFileExtFirst); s.fAssociatedWithIcons = !!m_fAssociatedWithIcons.GetCheck(); SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); return __super::OnApply(); }
BOOL CPPageFormats::OnApply() { UpdateData(); { int i = m_list.GetSelectionMark(); if (i >= 0) { i = (int)m_list.GetItemData(i); } if (i >= 0) { CMediaFormats& mf = AfxGetAppSettings().m_Formats; mf[i].SetExts(m_exts); m_exts = mf[i].GetExtsWithPeriod(); UpdateData(FALSE); } } CMediaFormats& mf = AfxGetAppSettings().m_Formats; RegisterApp(); f_setContextFiles = m_fContextFiles.GetCheck(); f_setAssociatedWithIcon = m_fAssociatedWithIcons.GetCheck(); if (m_bFileExtChanged) { for (int i = 0; i < m_list.GetItemCount(); i++) { int iChecked = GetChecked(i); if (iChecked == 2) { continue; } CAtlList<CString> exts; Explode(mf[(int)m_list.GetItemData(i)].GetExtsWithPeriod(), exts, ' '); POSITION pos = exts.GetHeadPosition(); while (pos) { RegisterExt(exts.GetNext(pos), mf[(int)m_list.GetItemData(i)].GetDescription(), !!iChecked); } } } CRegKey key; if (m_fContextDir.GetCheck()) { if (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\") PROGID _T(".enqueue"))) { key.SetStringValue(NULL, ResStr(IDS_ADD_TO_PLAYLIST)); } if (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\") PROGID _T(".enqueue\\command"))) { key.SetStringValue(NULL, GetEnqueueCommand()); } if (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\") PROGID _T(".play"))) { key.SetStringValue(NULL, ResStr(IDS_OPEN_WITH_MPC)); } if (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\") PROGID _T(".play\\command"))) { key.SetStringValue(NULL, GetOpenCommand()); } } else { key.Attach(HKEY_CLASSES_ROOT); key.RecurseDeleteKey(_T("Directory\\shell\\") PROGID _T(".enqueue")); key.RecurseDeleteKey(_T("Directory\\shell\\") PROGID _T(".play")); } { SetListItemState(m_list.GetSelectionMark()); } AddAutoPlayToRegistry(AP_VIDEO, !!m_apvideo.GetCheck()); AddAutoPlayToRegistry(AP_MUSIC, !!m_apmusic.GetCheck()); AddAutoPlayToRegistry(AP_AUDIOCD, !!m_apaudiocd.GetCheck()); AddAutoPlayToRegistry(AP_DVDMOVIE, !!m_apdvd.GetCheck()); AppSettings& s = AfxGetAppSettings(); s.m_Formats.SetRtspHandler(m_iRtspHandler==0?RealMedia:m_iRtspHandler==1?QuickTime:DirectShow, !!m_fRtspFileExtFirst); s.fAssociatedWithIcons = !!m_fAssociatedWithIcons.GetCheck(); SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); return __super::OnApply(); }