00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "stdafx.h"
00026 #include "mplayerc.h"
00027 #include "ConvertResDlg.h"
00028
00029
00030
00031 CConvertResDlg::CConvertResDlg(CWnd* pParent )
00032 : CResizableDialog(CConvertResDlg::IDD, pParent)
00033 , m_name(_T(""))
00034 , m_desc(_T(""))
00035 {
00036 }
00037
00038 CConvertResDlg::~CConvertResDlg()
00039 {
00040 }
00041
00042 void CConvertResDlg::DoDataExchange(CDataExchange* pDX)
00043 {
00044 __super::DoDataExchange(pDX);
00045 DDX_Text(pDX, IDC_EDIT3, m_name);
00046 DDX_Text(pDX, IDC_COMBO1, m_mime);
00047 DDX_Control(pDX, IDC_COMBO1, m_mimectrl);
00048 DDX_Text(pDX, IDC_EDIT2, m_desc);
00049 }
00050
00051 BOOL CConvertResDlg::OnInitDialog()
00052 {
00053 __super::OnInitDialog();
00054
00055 AddAnchor(IDC_EDIT3, TOP_LEFT, TOP_RIGHT);
00056 AddAnchor(IDC_COMBO1, TOP_LEFT, TOP_RIGHT);
00057 AddAnchor(IDC_EDIT2, TOP_LEFT, BOTTOM_RIGHT);
00058 AddAnchor(IDOK, BOTTOM_CENTER);
00059 AddAnchor(IDCANCEL, BOTTOM_CENTER);
00060
00061 CRegKey key;
00062 CString str(_T("MIME\\Database\\Content Type"));
00063 if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, str, KEY_READ))
00064 {
00065 CAtlMap<CString, bool, CStringElementTraits<CString> > mimes;
00066
00067 TCHAR buff[256];
00068 DWORD len = countof(buff);
00069 for(int i = 0; ERROR_SUCCESS == key.EnumKey(i, buff, &len); i++, len = countof(buff))
00070 {
00071 CRegKey mime;
00072 TCHAR ext[64];
00073 ULONG len = countof(ext);
00074 if(ERROR_SUCCESS == mime.Open(HKEY_CLASSES_ROOT, str + _T("\\") + buff, KEY_READ)
00075 && ERROR_SUCCESS == mime.QueryStringValue(_T("Extension"), ext, &len))
00076 {
00077 CString mime = CString(buff).MakeLower();
00078 mimes[mime] = true;
00079 m_mimectrl.AddString(mime);
00080 }
00081 }
00082
00083 static TCHAR* moremimes[] =
00084 {
00085 _T("application/octet-stream"),
00086 _T("application/zip"),
00087 _T("application/rar"),
00088 _T("application/x-truetype-font"),
00089 };
00090
00091 for(int i = 0; i < countof(moremimes); i++)
00092 if(!mimes.Lookup(moremimes[i]))
00093 m_mimectrl.AddString(moremimes[i]);
00094 }
00095
00096 m_desc.Replace(_T("\n"), _T("\r\n"));
00097
00098 UpdateData(FALSE);
00099
00100 return TRUE;
00101
00102 }
00103
00104 void CConvertResDlg::OnOK()
00105 {
00106 UpdateData();
00107
00108 m_name.Trim();
00109 m_mime.Trim();
00110 m_desc.Replace(_T("\r\n"), _T("\r"));
00111 m_desc.Trim();
00112
00113 __super::OnOK();
00114 }
00115
00116 BEGIN_MESSAGE_MAP(CConvertResDlg, CResizableDialog)
00117 ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOK)
00118 END_MESSAGE_MAP()
00119
00120
00121
00122 void CConvertResDlg::OnUpdateOK(CCmdUI* pCmdUI)
00123 {
00124 pCmdUI->Enable(GetDlgItem(IDC_EDIT3)->GetWindowTextLength() > 0 && GetDlgItem(IDC_COMBO1)->GetWindowTextLength() > 0);
00125 }