2 * Copyright (C) 2003-2006 Gabest
3 * http://www.gabest.org
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Make; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 // ConvertResDlg.cpp : implementation file
27 #include "ConvertResDlg.h"
29 // CConvertResDlg dialog
31 CConvertResDlg::CConvertResDlg(CWnd
* pParent
/*=NULL*/)
32 : CResizableDialog(CConvertResDlg::IDD
, pParent
)
38 CConvertResDlg::~CConvertResDlg()
42 void CConvertResDlg::DoDataExchange(CDataExchange
* pDX
)
44 __super::DoDataExchange(pDX
);
45 DDX_Text(pDX
, IDC_EDIT3
, m_name
);
46 DDX_Text(pDX
, IDC_COMBO1
, m_mime
);
47 DDX_Control(pDX
, IDC_COMBO1
, m_mimectrl
);
48 DDX_Text(pDX
, IDC_EDIT2
, m_desc
);
51 BOOL
CConvertResDlg::OnInitDialog()
53 __super::OnInitDialog();
55 AddAnchor(IDC_EDIT3
, TOP_LEFT
, TOP_RIGHT
);
56 AddAnchor(IDC_COMBO1
, TOP_LEFT
, TOP_RIGHT
);
57 AddAnchor(IDC_EDIT2
, TOP_LEFT
, BOTTOM_RIGHT
);
58 AddAnchor(IDOK
, BOTTOM_CENTER
);
59 AddAnchor(IDCANCEL
, BOTTOM_CENTER
);
62 CString
str(_T("MIME\\Database\\Content Type"));
63 if(ERROR_SUCCESS
== key
.Open(HKEY_CLASSES_ROOT
, str
, KEY_READ
))
65 CAtlStringMap
<bool> mimes
;
68 DWORD len
= countof(buff
);
69 for(int i
= 0; ERROR_SUCCESS
== key
.EnumKey(i
, buff
, &len
); i
++, len
= countof(buff
))
73 ULONG len
= countof(ext
);
74 if(ERROR_SUCCESS
== mime
.Open(HKEY_CLASSES_ROOT
, str
+ _T("\\") + buff
, KEY_READ
)
75 && ERROR_SUCCESS
== mime
.QueryStringValue(_T("Extension"), ext
, &len
))
77 CString mime
= CString(buff
).MakeLower();
79 m_mimectrl
.AddString(mime
);
83 static TCHAR
* moremimes
[] =
85 _T("application/octet-stream"),
86 _T("application/zip"),
87 _T("application/rar"),
88 _T("application/x-truetype-font"),
91 for(int i
= 0; i
< countof(moremimes
); i
++)
92 if(!mimes
.Lookup(moremimes
[i
]))
93 m_mimectrl
.AddString(moremimes
[i
]);
96 m_desc
.Replace(_T("\n"), _T("\r\n"));
100 return TRUE
; // return TRUE unless you set the focus to a control
101 // EXCEPTION: OCX Property Pages should return FALSE
104 void CConvertResDlg::OnOK()
110 m_desc
.Replace(_T("\r\n"), _T("\r"));
116 BEGIN_MESSAGE_MAP(CConvertResDlg
, CResizableDialog
)
117 ON_UPDATE_COMMAND_UI(IDOK
, OnUpdateOK
)
120 // CConvertResDlg message handlers
122 void CConvertResDlg::OnUpdateOK(CCmdUI
* pCmdUI
)
124 pCmdUI
->Enable(GetDlgItem(IDC_EDIT3
)->GetWindowTextLength() > 0 && GetDlgItem(IDC_COMBO1
)->GetWindowTextLength() > 0);