SendDlgItemMessage(IDC_FLDCONFIRM_ICON, STM_SETICON, (WPARAM)icon, 0L);
if (!m_caption.empty())
- SetWindowText(m_caption.c_str());
+ SetTitleText(m_caption);
// setup handler for resizing this dialog
m_constraint.InitializeCurrentSize(this);
m_constraint.LoadPosition(_T("ResizeableDialogs"), _T("FolderCopyConfirmDlg"), false);
String strDontAskAgain = LoadResString(IDS_MESSAGEBOX_DONT_ASK_AGAIN);
- GetDlgItem(IDC_FLDCONFIRM_DONTASKAGAIN)->SetWindowText(strDontAskAgain.c_str());
+ SetDlgItemText(IDC_FLDCONFIRM_DONTASKAGAIN, strDontAskAgain);
}
return TRUE; // return TRUE unless you set the focus to a control
UpdateData(FALSE);
// Add patch styles to combobox
- m_comboStyle.AddString(_("Normal").c_str());
- m_comboStyle.AddString(_("Context").c_str());
- m_comboStyle.AddString(_("Unified").c_str());
- m_comboStyle.AddString(_("HTML").c_str());
+ SetDlgItemComboBoxList(IDC_DIFF_STYLE,
+ { _("Normal"), _("Context"), _("Unified"), _("HTML") });
m_outputStyle = OUTPUT_NORMAL;
m_comboStyle.SetCurSel(0);
// Add default context line counts to combobox if its empty
if (m_comboContext.GetCount() == 0)
{
- m_comboContext.AddString(_T("0"));
- m_comboContext.AddString(_T("1"));
- m_comboContext.AddString(_T("3"));
- m_comboContext.AddString(_T("5"));
- m_comboContext.AddString(_T("7"));
+ SetDlgItemComboBoxList(IDC_DIFF_CONTEXT,
+ { _T("0"), _T("1"), _T("3"), _T("5"), _T("7") });
}
LoadSettings();
m_comboContext.SelectString(-1, strutils::to_str(m_contextLines).c_str());
- if (m_outputStyle == OUTPUT_CONTEXT || m_outputStyle == OUTPUT_UNIFIED || m_outputStyle == OUTPUT_HTML)
- m_comboContext.EnableWindow(TRUE);
- else
- m_comboContext.EnableWindow(FALSE);
+ bool enabled = (m_outputStyle == OUTPUT_CONTEXT || m_outputStyle == OUTPUT_UNIFIED || m_outputStyle == OUTPUT_HTML);
+ m_comboContext.EnableWindow(enabled);
}
/**
// Enable/disable "Custom codepage" edit field
EnableDlgItem(IDC_CUSTOM_CP_NUMBER, IsDlgButtonChecked(IDC_CP_CUSTOM) == 1);
- m_comboAutodetectType.EnableWindow(
- IsDlgButtonChecked(IDC_DETECT_CODEPAGE2) == 1);
+ EnableDlgItem(IDC_DETECT_AUTODETECTTYPE, IsDlgButtonChecked(IDC_DETECT_CODEPAGE2) == 1);
- m_comboCustomCodepageValue.SetWindowText(strutils::to_str(m_nCustomCodepageValue).c_str());
+ SetDlgItemInt(IDC_CUSTOM_CP_NUMBER, m_nCustomCodepageValue);
IExconverter *pexconv = Exconverter::getInstance();
if (pexconv != nullptr)
void PropCodepage::OnDetectCodepage2()
{
- m_comboAutodetectType.EnableWindow(
- IsDlgButtonChecked(IDC_DETECT_CODEPAGE2) == 1);
+ EnableDlgItem(IDC_DETECT_AUTODETECTTYPE, IsDlgButtonChecked(IDC_DETECT_CODEPAGE2) == 1);
}
void PropCodepage::OnDetectAutodetecttype()
*/
BOOL PropCompare::OnInitDialog()
{
- CComboBox * combo = (CComboBox*) GetDlgItem(IDC_DIFF_ALGORITHM);
- for (const auto& item : { _("default"), _("minimal"), _("patience"), _("histogram"), _("none") })
- combo->AddString(item.c_str());
- combo->SetCurSel(m_nDiffAlgorithm);
+ SetDlgItemComboBoxList(IDC_DIFF_ALGORITHM,
+ { _("default"), _("minimal"), _("patience"), _("histogram"), _("none") });
OptionsPanel::OnInitDialog();
return TRUE; // return TRUE unless you set the focus to a control
*/
BOOL PropCompareFolder::OnInitDialog()
{
- OptionsPanel::OnInitDialog();
- CComboBox * combo = (CComboBox*) GetDlgItem(IDC_COMPAREMETHODCOMBO);
+ SetDlgItemComboBoxList(IDC_COMPAREMETHODCOMBO,
+ { _("Full Contents"), _("Quick Contents"), _("Binary Contents"), _("Modified Date"), _("Modified Date and Size"), _("Size") });
- for (const auto& item : { _("Full Contents"), _("Quick Contents"), _("Binary Contents"), _("Modified Date"), _("Modified Date and Size"), _("Size") })
- combo->AddString(item.c_str());
- combo->SetCurSel(m_compareMethod);
+ OptionsPanel::OnInitDialog();
+
UpdateControls();
return TRUE; // return TRUE unless you set the focus to a control
*/
BOOL PropCompareImage::OnInitDialog()
{
- CComboBox * combo = (CComboBox*) GetDlgItem(IDC_COMPAREIMAGE_OCR_RESULT_TYPE);
- for (const auto& item : { _("Text only"), _("Line-by-line position and text"), _("Word-by-word position and text") })
- combo->AddString(item.c_str());
- combo->SetCurSel(m_nOcrResultType);
+ SetDlgItemComboBoxList(IDC_COMPAREIMAGE_OCR_RESULT_TYPE,
+ { _("Text only"), _("Line-by-line position and text"), _("Word-by-word position and text") });
OptionsPanel::OnInitDialog();
return TRUE; // return TRUE unless you set the focus to a control
*/
BOOL PropCompareWebPage::OnInitDialog()
{
- CComboBox * combo = (CComboBox*) GetDlgItem(IDC_COMPAREWEBPAGE_USERDATAFOLDER_TYPE);
- for (const auto& item : { _("AppData folder"), _("Install folder") })
- combo->AddString(item.c_str());
- combo->SetCurSel(m_nUserDataFolderType);
+ SetDlgItemComboBoxList(IDC_COMPAREWEBPAGE_USERDATAFOLDER_TYPE,
+ { _("AppData folder"), _("Install folder") });
OptionsPanel::OnInitDialog();
return TRUE; // return TRUE unless you set the focus to a control
*/
void PropEditor::LoadComboBoxStrings()
{
- CComboBox * cbo = (CComboBox *)GetDlgItem(IDC_BREAK_TYPE);
- for (const auto& item : { _("Break at whitespace"), _("Break at whitespace or punctuation") })
- cbo->AddString(item.c_str());
- cbo = (CComboBox *)GetDlgItem(IDC_RENDERING_MODE);
- for (const auto& item : { _("GDI"), _("DirectWrite Default"), _("DirectWrite Aliased"), _("DirectWrite GDI Classic"), _("DirectWrite GDI Natural"), _("DirectWrite Natural"), _("DirectWrite Natural Symmetric") })
- cbo->AddString(item.c_str());
+ SetDlgItemComboBoxList(IDC_BREAK_TYPE,
+ { _("Break at whitespace"), _("Break at whitespace or punctuation") });
+ SetDlgItemComboBoxList(IDC_RENDERING_MODE,
+ { _("GDI"), _("DirectWrite Default"), _("DirectWrite Aliased"), _("DirectWrite GDI Classic"), _("DirectWrite GDI Natural"), _("DirectWrite Natural"), _("DirectWrite Natural Symmetric") });
}
/**
BOOL PropGeneral::OnInitDialog()
{
- OptionsPanel::OnInitDialog();
-
- CComboBox *pWnd = (CComboBox*)GetDlgItem(IDC_AUTO_COMPLETE_SOURCE);
- ASSERT(pWnd != nullptr);
-
- for (const auto& item : { _("Disabled"), _("From file system"), _("From Most Recently Used list") })
- pWnd->AddString(item.c_str());
-
- pWnd->SetCurSel(m_nAutoCompleteSource);
-
- pWnd = (CComboBox*)GetDlgItem(IDC_ESC_CLOSES_WINDOW);
- ASSERT(pWnd != nullptr);
-
- for (const auto& item : { _("Disabled"), _("MDI child window or main window"), _("MDI child window only"), _("Close main window if there is only one MDI child window") })
- pWnd->AddString(item.c_str());
-
- pWnd->SetCurSel(m_nCloseWindowWithEsc);
+ SetDlgItemComboBoxList(IDC_AUTO_COMPLETE_SOURCE,
+ { _("Disabled"), _("From file system"), _("From Most Recently Used list") });
+ SetDlgItemComboBoxList(IDC_ESC_CLOSES_WINDOW,
+ { _("Disabled"), _("MDI child window or main window"), _("MDI child window only"), _("Close main window if there is only one MDI child window") });
+ SetDlgItemComboBoxList(IDC_SINGLE_INSTANCE,
+ { _("Disabled"), _("Allow only one instance to run"), _("Allow only one instance to run and wait for the instance to terminate") });
+ SetDlgItemComboBoxList(IDC_AUTO_RELOAD_MODIFIED_FILES,
+ { _("Disabled"), _("Only on window activated"), _("Immediately") });
- pWnd = (CComboBox*)GetDlgItem(IDC_SINGLE_INSTANCE);
- ASSERT(pWnd != nullptr);
-
- for (const auto& item : { _("Disabled"), _("Allow only one instance to run"), _("Allow only one instance to run and wait for the instance to terminate") })
- pWnd->AddString(item.c_str());
-
- pWnd->SetCurSel(m_nSingleInstance);
-
- pWnd = (CComboBox*)GetDlgItem(IDC_AUTO_RELOAD_MODIFIED_FILES);
- ASSERT(pWnd != nullptr);
-
- for (const auto& item : { _("Disabled"), _("Only on window activated"), _("Immediately") })
- pWnd->AddString(item.c_str());
-
- pWnd->SetCurSel(m_nFileReloadMode);
+ OptionsPanel::OnInitDialog();
m_ctlLangList.SetDroppedWidth(600);
m_ctlLangList.EnableWindow(FALSE);
if (m_bArgumentsRequired)
{
- SetWindowText((_("Specify plugin arguments") + _T(" [") + pluginTypeStr + _T("]")).c_str());
+ SetTitleText(_("Specify plugin arguments") + _T(" [") + pluginTypeStr + _T("]"));
String args;
- CString pipeline;
+ String pipeline;
GetDlgItemText(IDC_PLUGIN_ARGUMENTS, args);
- m_ctlPluginPipeline.GetWindowText(pipeline);
- m_strPluginPipeline = pipeline + _T(" ") + args.c_str();
- m_ctlPluginPipeline.SetWindowText(m_strPluginPipeline.c_str());
- m_ctlPluginPipeline.SetFocus();
+ GetDlgItemText(IDC_PLUGIN_PIPELINE, pipeline);
+ m_strPluginPipeline = pipeline + _T(" ") + args;
+ SetDlgItemText(IDC_PLUGIN_PIPELINE, m_strPluginPipeline);
+ SetDlgItemFocus(IDC_PLUGIN_PIPELINE);
return FALSE;
}
- CString title;
- GetWindowText(title);
- SetWindowText(title + _T(" [") + pluginTypeStr.c_str() + _T("]"));
+ SetTitleText(GetTitleText() + _T(" [") + pluginTypeStr + _T("]"));
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
\r
void SetDlgItemText(unsigned id, const String& text)\r
{\r
- return dlg()->SetDlgItemTextW(id, text.c_str());\r
+ dlg()->SetDlgItemTextW(id, text.c_str());\r
+ }\r
+\r
+ void SetDlgItemComboBoxList(unsigned id, const std::initializer_list<String>& list)\r
+ {\r
+ CComboBox * cbo = (CComboBox *)dlg()->GetDlgItem(id);\r
+ if (!cbo)\r
+ return;\r
+ for (const auto& item : list)\r
+ cbo->AddString(item.c_str());\r
+ }\r
+\r
+ String GetTitleText()\r
+ {\r
+ CString title;\r
+ dlg()->GetWindowText(title);\r
+ return title.GetString();\r
+ }\r
+\r
+ void SetTitleText(const String& text)\r
+ {\r
+ dlg()->SetWindowText(text.c_str());\r
}\r
};\r
\r
bool fitToWindow = m_pWebDiffWindow->GetFitToWindow();
m_wndWebPageDiffBar.CheckDlgButton(IDC_FITTOWINDOW, fitToWindow);
m_wndWebPageDiffBar.CheckDlgButton(IDC_SHOWDIFFERENCES, m_pWebDiffWindow->GetShowDifferences());
- m_wndWebPageDiffBar.GetDlgItem(IDC_WIDTH)->EnableWindow(!fitToWindow);
- m_wndWebPageDiffBar.GetDlgItem(IDC_HEIGHT)->EnableWindow(!fitToWindow);
+ m_wndWebPageDiffBar.EnableDlgItem(IDC_WIDTH, !fitToWindow);
+ m_wndWebPageDiffBar.EnableDlgItem(IDC_HEIGHT, !fitToWindow);
SIZE size = m_pWebDiffWindow->GetSize();
m_wndWebPageDiffBar.SetDlgItemText(IDC_WIDTH, strutils::format(_T("%d"), size.cx));
m_wndWebPageDiffBar.SetDlgItemText(IDC_HEIGHT, strutils::format(_T("%d"), size.cy));