From a597d2e4ec1083ae1ccf8c11d4bf634e243b7eca Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 11 Jan 2023 21:42:40 +0300 Subject: =?UTF-8?q?fixes=20#3298=20(=D0=A1=D0=BE=D1=80=D1=82=D0=B8=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=BA=D0=B0=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=B2=D0=B8=D1=81=D0=B8=D1=82=20=D0=BE=D1=82=20?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B3=D0=BF=D0=B0=D0=BA=D0=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/JabberG/src/jabber_vcard.cpp | 50 +++++++++++++++------------------- 1 file changed, 22 insertions(+), 28 deletions(-) (limited to 'protocols/JabberG/src') diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp index aad0f8d9be..ff7f3e9212 100644 --- a/protocols/JabberG/src/jabber_vcard.cpp +++ b/protocols/JabberG/src/jabber_vcard.cpp @@ -165,22 +165,22 @@ struct JabberVcardPersonalDlg : public JabberVcardBaseDlg ///////////////////////////////////////////////////////////////////////////////////////// // Home vcard dialog -struct JabberVcardHomeDlg : public JabberVcardBaseDlg +class JabberVcardHomeDlg : public JabberVcardBaseDlg { + CCtrlCombo countries; + +public: JabberVcardHomeDlg(CJabberProto *_ppro) : - JabberVcardBaseDlg(_ppro, IDD_VCARD_HOME, 1) + JabberVcardBaseDlg(_ppro, IDD_VCARD_HOME, 1), + countries(this, IDC_COUNTRY) { } bool OnInitDialog() override { - for (int i = 0; i < g_cbCountries; i++) { - if (g_countries[i].id != 0xFFFF && g_countries[i].id != 0) { - wchar_t *country = mir_a2u(g_countries[i].szName); - SendDlgItemMessage(m_hwnd, IDC_COUNTRY, CB_ADDSTRING, 0, (LPARAM)TranslateW(country)); - mir_free(country); - } - } + for (int i = 0; i < g_cbCountries; i++) + if (g_countries[i].id != 0xFFFF && g_countries[i].id != 0) + countries.AddString(TranslateW(_A2T(g_countries[i].szName)), i); return JabberVcardBaseDlg::OnInitDialog(); } @@ -194,7 +194,7 @@ struct JabberVcardHomeDlg : public JabberVcardBaseDlg SetDialogField(IDC_ZIP, "ZIP"); CMStringW buf(ppro->getMStringW("Country")); - SendDlgItemMessage(m_hwnd, IDC_COUNTRY, CB_SELECTSTRING, -1, LPARAM(TranslateW(buf.c_str()))); + countries.SelectString(TranslateW(buf.c_str())); return false; } @@ -206,10 +206,7 @@ struct JabberVcardHomeDlg : public JabberVcardBaseDlg SaveDialogField(IDC_STATE, "State"); SaveDialogField(IDC_ZIP, "ZIP"); - int i = SendDlgItemMessage(m_hwnd, IDC_COUNTRY, CB_GETCURSEL, 0, 0); - wchar_t *country = mir_a2u((i) ? g_countries[i + 2].szName : g_countries[1].szName); - ppro->setWString("Country", country); - mir_free(country); + ppro->setWString("Country", _A2T(g_countries[countries.GetCurData()].szName)); return JabberVcardBaseDlg::OnApply(); } @@ -218,22 +215,22 @@ struct JabberVcardHomeDlg : public JabberVcardBaseDlg ///////////////////////////////////////////////////////////////////////////////////////// // Work vcard dialog -struct JabberVcardWorkDlg : public JabberVcardBaseDlg +class JabberVcardWorkDlg : public JabberVcardBaseDlg { + CCtrlCombo countries; + +public: JabberVcardWorkDlg(CJabberProto *_ppro) : - JabberVcardBaseDlg(_ppro, IDD_VCARD_WORK, 2) + JabberVcardBaseDlg(_ppro, IDD_VCARD_WORK, 2), + countries(this, IDC_COUNTRY) { } bool OnInitDialog() override { - for (int i = 0; i < g_cbCountries; i++) { - if (g_countries[i].id != 0xFFFF && g_countries[i].id != 0) { - wchar_t *country = mir_a2u(g_countries[i].szName); - SendDlgItemMessage(m_hwnd, IDC_COUNTRY, CB_ADDSTRING, 0, (LPARAM)TranslateW(country)); - mir_free(country); - } - } + for (int i = 0; i < g_cbCountries; i++) + if (g_countries[i].id != 0xFFFF && g_countries[i].id != 0) + countries.AddString(TranslateW(_A2T(g_countries[i].szName)), i); return JabberVcardBaseDlg::OnInitDialog(); } @@ -250,7 +247,7 @@ struct JabberVcardWorkDlg : public JabberVcardBaseDlg SetDialogField(IDC_ZIP, "CompanyZIP"); CMStringW buf(ppro->getMStringW("CompanyCountry")); - SendDlgItemMessage(m_hwnd, IDC_COUNTRY, CB_SELECTSTRING, -1, LPARAM(TranslateW(buf.c_str()))); + countries.SelectString(TranslateW(buf.c_str())); return false; } @@ -265,10 +262,7 @@ struct JabberVcardWorkDlg : public JabberVcardBaseDlg SaveDialogField(IDC_STATE, "CompanyState"); SaveDialogField(IDC_ZIP, "CompanyZIP"); - int i = SendDlgItemMessage(m_hwnd, IDC_COUNTRY, CB_GETCURSEL, 0, 0); - wchar_t *country = mir_a2u((i) ? g_countries[i + 2].szName : g_countries[1].szName); - ppro->setWString("CompanyCountry", country); - mir_free(country); + ppro->setWString("CompanyCountry", _A2T(g_countries[countries.GetCurData()].szName)); return JabberVcardBaseDlg::OnApply(); } -- cgit v1.2.3