- Main Page
- Namespaces
- Classes
- Files
- Directories

- File List
- File Members

# ConvertResDlg.cpp

    00001 /*
    00002  *      Copyright (C) 2003-2005 Gabest
    00003  *      http://www.gabest.org
    00004  *
    00005  *  This Program is free software; you can redistribute it and/or modify
    00006  *  it under the terms of the GNU General Public License as published by
    00007  *  the Free Software Foundation; either version 2, or (at your option)
    00008  *  any later version.
    00009  *
    00010  *  This Program is distributed in the hope that it will be useful,
    00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    00013  *  GNU General Public License for more details.
    00014  *
    00015  *  You should have received a copy of the GNU General Public License
    00016  *  along with GNU Make; see the file COPYING.  If not, write to
    00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
    00018  *  http://www.gnu.org/copyleft/gpl.html
    00019  *
    00020  */
    00021
    00022 // ConvertResDlg.cpp : implementation file
    00023 //
    00024
    00025 #include "stdafx.h"
    00026 #include "mplayerc.h"
    00027 #include "ConvertResDlg.h"
    00028
    00029 // CConvertResDlg dialog
    00030
    00031 CConvertResDlg::CConvertResDlg(CWnd* pParent /*=NULL*/)
    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;  // return TRUE unless you set the focus to a control
    00101         // EXCEPTION: OCX Property Pages should return FALSE
    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 // CConvertResDlg message handlers
    00121
    00122 void CConvertResDlg::OnUpdateOK(CCmdUI* pCmdUI)
    00123 {
    00124         pCmdUI->Enable(GetDlgItem(IDC_EDIT3)->GetWindowTextLength() > 0 && GetDlgItem(IDC_COMBO1)->GetWindowTextLength() > 0);
    00125 }