1 ///////////////////////////////////////////////////////////////////////////
4 // Updated: 17-Oct-1999
6 // Copyright: Ferdinand Prantl
7 // E-mail: prantl@ff.cuni.cz
9 // Character encoding dialog
11 // You are free to use or modify this code to the following restrictions:
12 // - Acknowledge me somewhere in your about box, simple "Parts of code by.."
13 // will be enough. If you can't (or don't want to), contact me personally.
14 // - LEAVE THIS HEADER INTACT
15 ////////////////////////////////////////////////////////////////////////////
19 #include "ccrystaltextview.h"
22 #include "DDXHelper.h"
28 EDITPADC_CLASS LPCTSTR pszCodeNames[] =
30 _T ("ASCII (without accents)"),
31 _T ("MS-Windows CP 1250"),
32 _T ("MS-Windows CP 1252"),
33 _T ("PC Latin I (CP 850)"),
34 _T ("PC Latin II (CP 852)"),
35 _T ("IBM Latin II (IBM 852)"),
38 _T ("Brothers Kamenicky"),
40 _T ("Apple Macintosh"),
41 _T ("Apple Macintosh for Central Europe"),
46 EDITPADC_CLASS int nCodeNames = sizeof (pszCodeNames) / sizeof (pszCodeNames[0]) - 1;
48 EDITPADC_CLASS void FillComboBox (CComboBox &Control, LPCTSTR *pszItems)
50 Control.ResetContent();
51 ASSERT (pszItems != nullptr);
53 Control.AddString(*pszItems++);
56 /////////////////////////////////////////////////////////////////////////////
57 // CCharConvDlg dialog
59 CCharConvDlg::CCharConvDlg () : CDialog (CCharConvDlg::IDD, nullptr)
65 //{{AFX_DATA_INIT(CCharConvDlg)
70 DoDataExchange (CDataExchange * pDX)
72 CDialog::DoDataExchange (pDX);
73 //{{AFX_DATA_MAP(CCharConvDlg)
74 DDX_Control(pDX, IDC_SRC, m_ctlSource);
75 DDX_Control(pDX, IDC_DEST, m_ctlDest);
76 DDX_CBIndex(pDX, IDC_SRC, m_nSource);
77 DDX_CBIndex(pDX, IDC_DEST, m_nDest);
78 DDX_Check(pDX, IDC_ALPHA_ONLY, m_bAlpha);
79 DDX_Text(pDX, IDC_PREVIEW, m_sPreview);
83 BEGIN_MESSAGE_MAP (CCharConvDlg, CDialog)
84 //{{AFX_MSG_MAP(CCharConvDlg)
85 ON_BN_CLICKED(IDPREVIEW, OnPreview)
89 /////////////////////////////////////////////////////////////////////////////
90 // CCharConvDlg message handlers
92 static int nSource = 1;
98 CDialog::OnInitDialog ();
99 FillComboBox (m_ctlSource, pszCodeNames);
100 FillComboBox (m_ctlDest, pszCodeNames);
103 m_sPreview = m_sOriginal;
108 void CCharConvDlg::OnOK ()
115 void CCharConvDlg::OnPreview()
118 LPTSTR pszNew = nullptr;
119 if (!iconvert_new (m_sOriginal, &pszNew, m_nSource, m_nDest, m_bAlpha))
124 if (pszNew != nullptr)