📄 aencodeproperties.cpp
字号:
tmpSavedProps.SelectSavedParams(string); tmpSavedProps.ParamsRestore(); // check if the values from the DLG are the same as the one saved in the config file // if yes, just do nothing/* if (tmpDlgProps != tmpSavedProps) { int save; if (strcmp(string,"Current") == 0) { // otherwise, prompt the user if he wants to overwrite the settings TCHAR tmpStr[250]; ::LoadString(AOut::GetInstance(),IDS_STRING_PROMPT_REPLACE_CURRENT,tmpStr,250); save = AOut::MyMessageBox( tmpStr, MB_OKCANCEL|MB_ICONQUESTION, parentWnd); } else { // otherwise, prompt the user if he wants to overwrite the settings TCHAR tmpStr[250]; ::LoadString(AOut::GetInstance(),IDS_STRING_PROMPT_REPLACE_SETING,tmpStr,250); TCHAR tmpDsp[500]; wsprintf(tmpDsp,tmpStr,string); save = AOut::MyMessageBox( tmpDsp, MB_YESNOCANCEL|MB_ICONQUESTION, parentWnd); } if (save == IDCANCEL) bShouldEnd = false; else if (save == IDNO) { // save the values in 'current' UpdateValueFromDlg(parentWnd); SaveValuesToStringKey("Current"); SelectSavedParams("Current"); } else { // do so and save in XML UpdateValueFromDlg(parentWnd); SaveValuesToStringKey(string); } }*///#endif // OLDmy_debug.OutPut("before : nChannelIndex %d, bCRC %d, bCopyright %d, bOriginal %d, bPrivate %d",nChannelIndex, bCRC, bCopyright, bOriginal, bPrivate);my_debug.OutPut("call UpdateValueFromDlg"); UpdateValueFromDlg(parentWnd);my_debug.OutPut("call SaveValuesToStringKey"); SaveValuesToStringKey("Current"); // only Current config is supported now// SaveParams(parentWnd);//my_debug.OutPut("call SelectSavedParams");// SelectSavedParams(string);// UpdateDlgFromValue(parentWnd);my_debug.OutPut("finished saving"); if (bShouldEnd) { RemoveProp(parentWnd, "AEncodeProperties-Config"); EndDialog(parentWnd, true); } } break; case IDCANCEL: RemoveProp(parentWnd, "AEncodeProperties-Config"); EndDialog(parentWnd, false); break;/* case IDC_FIND_DLL: { OPENFILENAME file; char DllLocation[512]; wsprintf(DllLocation,"%s",GetDllLocation()); memset(&file, 0, sizeof(file)); file.lStructSize = sizeof(file); file.hwndOwner = parentWnd; file.Flags = OFN_FILEMUSTEXIST | OFN_NODEREFERENCELINKS | OFN_ENABLEHOOK | OFN_EXPLORER ;/// file.lpstrFile = AOut::the_AOut->DllLocation; file.lpstrFile = DllLocation; file.lpstrFilter = "Lame DLL (lame_enc.dll)\0LAME_ENC.DLL\0DLL (*.dll)\0*.DLL\0All (*.*)\0*.*\0"; file.nFilterIndex = 1; file.nMaxFile = sizeof(DllLocation); file.lpfnHook = DLLFindCallback; // use to validate the DLL chosen GetOpenFileName(&file); SetDllLocation(DllLocation); // use this filename if necessary } break;*//* case IDC_BUTTON_OUTPUT: {#ifndef SIMPLE_FOLDER BROWSEINFO info; memset(&info,0,sizeof(info)); char FolderName[MAX_PATH]; info.hwndOwner = parentWnd; info.pszDisplayName = FolderName; info.lpfn = BrowseFolderCallbackroc; info.lParam = (LPARAM) this; // get the localised window title TCHAR output[250]; ::LoadString(AOut::GetInstance(),IDS_STRING_DIR_SELECT,output,250); info.lpszTitle = output;#ifdef BIF_EDITBOX info.ulFlags |= BIF_EDITBOX;#else // BIF_EDITBOX info.ulFlags |= 0x0010;#endif // BIF_EDITBOX#ifdef BIF_VALIDATE info.ulFlags |= BIF_VALIDATE;#else // BIF_VALIDATE info.ulFlags |= 0x0020;#endif // BIF_VALIDATE#ifdef BIF_NEWDIALOGSTYLE info.ulFlags |= BIF_NEWDIALOGSTYLE;#else // BIF_NEWDIALOGSTYLE info.ulFlags |= 0x0040;#endif // BIF_NEWDIALOGSTYLE ITEMIDLIST *item = SHBrowseForFolder(&info); if (item != NULL) { char tmpOutputDir[MAX_PATH]; wsprintf(tmpOutputDir,"%s",GetOutputDirectory()); SHGetPathFromIDList( item,tmpOutputDir ); SetOutputDirectory( tmpOutputDir ); ::SetWindowText(GetDlgItem( parentWnd, IDC_EDIT_OUTPUTDIR), tmpOutputDir);// wsprintf(OutputDir,FolderName); }#else // SIMPLE_FOLDER OPENFILENAME file; memset(&file, 0, sizeof(file)); file.lStructSize = sizeof(file); file.hwndOwner = parentWnd; file.Flags = OFN_FILEMUSTEXIST | OFN_NODEREFERENCELINKS | OFN_ENABLEHOOK | OFN_EXPLORER ;// file.lpstrFile = GetDllLocation();// file.lpstrFile = GetOutputDirectory(); file.lpstrInitialDir = GetOutputDirectory(); file.lpstrFilter = "A Directory\0.*\0";// file.nFilterIndex = 1; file.nMaxFile = MAX_PATH;// file.lpfnHook = DLLFindCallback; // use to validate the DLL chosen// file.Flags = OFN_ENABLESIZING | OFN_NOREADONLYRETURN | OFN_HIDEREADONLY; file.Flags = OFN_NOREADONLYRETURN | OFN_HIDEREADONLY | OFN_EXPLORER; TCHAR output[250]; ::LoadString(AOut::GetInstance(),IDS_STRING_DIR_SELECT,output,250); file.lpstrTitle = output; GetSaveFileName(&file);#endif // SIMPLE_FOLDER } break;*/ case IDC_CHECK_ENC_ABR: EnableAbrOptions(parentWnd, ::IsDlgButtonChecked( parentWnd, IDC_CHECK_ENC_ABR) == BST_CHECKED); break;/* case IDC_RADIO_BITRATE_CBR: AEncodeProperties::DisplayVbrOptions(parentWnd, AEncodeProperties::BR_CBR); break; case IDC_RADIO_BITRATE_VBR: AEncodeProperties::DisplayVbrOptions(parentWnd, AEncodeProperties::BR_VBR); break; case IDC_RADIO_BITRATE_ABR: AEncodeProperties::DisplayVbrOptions(parentWnd, AEncodeProperties::BR_ABR); break; case IDC_CHECK_RESAMPLE: { bool tmp_bResampleUsed = (::IsDlgButtonChecked( parentWnd, IDC_CHECK_RESAMPLE) == BST_CHECKED); if (tmp_bResampleUsed) { ::EnableWindow(::GetDlgItem(parentWnd,IDC_COMBO_SAMPLEFREQ), TRUE); } else { ::EnableWindow(::GetDlgItem(parentWnd,IDC_COMBO_SAMPLEFREQ), FALSE); } } break;*//* case IDC_COMBO_SETTINGS:// if (CBN_SELCHANGE == GET_WM_COMMAND_CMD(wParam, lParam)) if (CBN_SELENDOK == GET_WM_COMMAND_CMD(wParam, lParam)) { char string[MAX_PATH]; int nIdx = SendMessage(HWND(lParam), CB_GETCURSEL, NULL, NULL); SendMessage(HWND(lParam), CB_GETLBTEXT , nIdx, (LPARAM) string); // get the info corresponding to the new selected item SelectSavedParams(string); UpdateDlgFromValue(parentWnd); } break;*//* case IDC_BUTTON_CONFIG_SAVE: { // save the data in the current config char string[MAX_PATH]; ::GetWindowText(::GetDlgItem( parentWnd, IDC_COMBO_SETTINGS), string, MAX_PATH); UpdateValueFromDlg(parentWnd); SaveValuesToStringKey(string); SelectSavedParams(string); UpdateConfigs(parentWnd); UpdateDlgFromValue(parentWnd); } break; case IDC_BUTTON_CONFIG_RENAME: { char string[MAX_PATH]; ::GetWindowText(::GetDlgItem( parentWnd, IDC_COMBO_SETTINGS), string, MAX_PATH); if (RenameCurrentTo(string)) { // Update the names displayed UpdateConfigs(parentWnd); } } break; case IDC_BUTTON_CONFIG_DELETE: { char string[MAX_PATH]; ::GetWindowText(::GetDlgItem( parentWnd, IDC_COMBO_SETTINGS), string, MAX_PATH); if (DeleteConfig(string)) { // Update the names displayed UpdateConfigs(parentWnd); UpdateDlgFromValue(parentWnd); } } break;*/ } return FALSE;}bool AEncodeProperties::RenameCurrentTo(const std::string & new_config_name){ bool bResult = false; // display all the names of the saved configs // get the values from the saved file if possible if (my_stored_data.LoadFile(my_store_location)) { TiXmlNode* node; node = my_stored_data.FirstChild("lame_acm"); TiXmlElement* CurrentNode = node->FirstChildElement("encodings"); if (CurrentNode->Attribute("default") != NULL) { std::string CurrentConfigName = *CurrentNode->Attribute("default"); // no rename possible for Current if (CurrentConfigName == "") { bResult = true; } else if (CurrentConfigName != "Current") { // find the config that correspond to CurrentConfig TiXmlElement* iterateElmt = CurrentNode->FirstChildElement("config");// int Idx = 0; while (iterateElmt != NULL) { const std::string * tmpname = iterateElmt->Attribute("name"); /** \todo support language names */ if (tmpname != NULL) { if (tmpname->compare(CurrentConfigName) == 0) { iterateElmt->SetAttribute("name",new_config_name); bResult = true; break; } }// Idx++; iterateElmt = iterateElmt->NextSiblingElement("config"); } } if (bResult) { CurrentNode->SetAttribute("default",new_config_name); my_stored_data.SaveFile(my_store_location); } } } return bResult;}bool AEncodeProperties::DeleteConfig(const std::string & config_name){ bool bResult = false; if (config_name != "Current") { // display all the names of the saved configs // get the values from the saved file if possible if (my_stored_data.LoadFile(my_store_location)) { TiXmlNode* node; node = my_stored_data.FirstChild("lame_acm"); TiXmlElement* CurrentNode = node->FirstChildElement("encodings"); TiXmlElement* iterateElmt = CurrentNode->FirstChildElement("config");// int Idx = 0; while (iterateElmt != NULL) { const std::string * tmpname = iterateElmt->Attribute("name"); /** \todo support language names */ if (tmpname != NULL) { if (tmpname->compare(config_name) == 0) { CurrentNode->RemoveChild(iterateElmt); bResult = true; break; } }// Idx++; iterateElmt = iterateElmt->NextSiblingElement("config"); } } if (bResult) { my_stored_data.SaveFile(my_store_location); // select a new default config : "Current" SelectSavedParams("Current"); } } return bResult;}void AEncodeProperties::UpdateConfigs(const HWND HwndDlg){ // Add User configs// SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SETTINGS), CB_RESETCONTENT , NULL, NULL); // display all the names of the saved configs // get the values from the saved file if possible if (my_stored_data.LoadFile(my_store_location)) { TiXmlNode* node; node = my_stored_data.FirstChild("lame_acm"); TiXmlElement* CurrentNode = node->FirstChildElement("encodings"); std::string CurrentConfig = ""; if (CurrentNode->Attribute("default") != NULL) { CurrentConfig = *CurrentNode->Attribute("default"); } TiXmlElement* iterateElmt;my_debug.OutPut("are we here ?"); // find the config that correspond to CurrentConfig iterateElmt = CurrentNode->FirstChildElement("config"); int Idx = 0; while (iterateElmt != NULL) { const std::string * tmpname = iterateElmt->Attribute("name"); /** \todo support language names */ if (tmpname != NULL) {// SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SETTINGS), CB_ADDSTRING, NULL, (LPARAM) tmpname->c_str()); if (tmpname->compare(CurrentConfig) == 0) {// SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SETTINGS), CB_SETCURSEL, Idx, NULL); SelectSavedParams(*tmpname); UpdateDlgFromValue(HwndDlg); } }my_debug.OutPut("Idx = %d",Idx); Idx++; // only Current config supported now// iterateElmt = iterateElmt->NextSiblingElement("config"); iterateElmt = NULL;my_debug.OutPut("iterateElmt = 0x%08X",iterateElmt); } }}/*void AEncodeProperties::UpdateAbrSteps(unsigned int min, unsigned int max, unsigned int step) const{}*/void AEncodeProperties::UpdateDlgFromSlides(HWND hwndDlg) const{ UINT value_min, value_max, value_step, value; char tmp[4]; value_min = SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_MIN), TBM_GETPOS, NULL, NULL); value_max = SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_MAX), TBM_GETPOS, NULL, NULL); if (value_min>value_max) { SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_MIN), TBM_SETPOS, TRUE, value_max); UpdateDlgFromSlides(hwndDlg); return; } if (value_max<value_min) { SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_MAX), TBM_SETPOS, TRUE, value_min); UpdateDlgFromSlides(hwndDlg); return; } wsprintf(tmp,"%3d",value_min); ::SetWindowText(GetDlgItem( hwndDlg, IDC_STATIC_AVERAGE_MIN_VALUE), tmp); SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_SETRANGEMIN, TRUE, value_min); wsprintf(tmp,"%3d",value_max); ::SetWindowText(GetDlgItem( hwndDlg, IDC_STATIC_AVERAGE_MAX_VALUE), tmp); SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_SETRANGEMAX, TRUE, value_max); value_step = SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_STEP), TBM_GETPOS, NULL, NULL); wsprintf(tmp,"%3d",value_step); ::SetWindowText(GetDlgItem( hwndDlg, IDC_STATIC_AVERAGE_STEP_VALUE), tmp); SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_CLEARTICS, TRUE, 0); for(UINT i=value_max; i>=value_min;i-=value_step) { SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_SETTIC, 0, i); } SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_SETLINESIZE, 0, value_step); SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_SETPAGESIZE, 0, value_step); value = SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_GETPOS, NULL, NULL); wsprintf(tmp,"%3d",value); ::SetWindowText(GetDlgItem( hwndDlg, IDC_STATIC_AVERAGE_SAMPLE_VALUE), tmp);}void AEncodeProperties::EnableAbrOptions(HWND hDialog, bool enable){ ::EnableWindow(::GetDlgItem( hDialog, IDC_SLIDER_AVERAGE_MIN), enable); ::EnableWindow(::GetDlgItem( hDialog, IDC_SLIDER_AVERAGE_MAX), enable); ::EnableWindow(::GetDlgItem( hDialog, IDC_SLIDER_AVERAGE_STEP), enable); ::EnableWindow(::GetDlgItem( hDialog, IDC_SLIDER_AVERAGE_SAMPLE), enable); ::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_MIN), enable); ::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_MAX), enable); ::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_STEP), enable); ::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_SAMPLE), enable); ::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_MIN_VALUE), enable); ::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_MAX_VALUE), enable); ::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_STEP_VALUE), enable); ::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_SAMPLE_VALUE), enable);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -