X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2b813b73cd79cfb4d275e9628811f379e8c5ee39..6d41981d894198a4de266d399f0f5cd141f97df6:/src/msw/mimetype.cpp diff --git a/src/msw/mimetype.cpp b/src/msw/mimetype.cpp index a73c5150e0..6f488946c5 100644 --- a/src/msw/mimetype.cpp +++ b/src/msw/mimetype.cpp @@ -6,7 +6,7 @@ // Created: 23.09.98 // RCS-ID: $Id$ // Copyright: (c) 1998 Vadim Zeitlin -// Licence: wxWindows license (part of wxExtra library) +// Licence: wxWindows licence (part of wxExtra library) ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -20,7 +20,9 @@ #pragma hdrstop #endif -// this is Win32 only code +#if wxUSE_MIMETYPE + +// Doesn't compile in WIN16 mode #ifndef __WIN16__ #ifndef WX_PRECOMP @@ -39,7 +41,7 @@ #ifdef __WXMSW__ #include "wx/msw/registry.h" - #include "windows.h" + #include "wx/msw/private.h" #endif // OS #include "wx/msw/mimetype.h" @@ -86,7 +88,7 @@ void wxFileTypeImpl::Init(const wxString& strFileType, const wxString& ext) m_strFileType = strFileType; if ( !strFileType ) { - m_strFileType = m_ext.AfterFirst('.') + "_auto_file"; + m_strFileType = m_ext.AfterFirst('.') + _T("_auto_file"); } } @@ -235,6 +237,9 @@ wxString wxFileTypeImpl::GetCommand(const wxChar *verb) const wxRegKey(wxRegKey::HKCR, strKey + _T("\\Topic")). QueryValue(_T(""), ddeTopic); + if (ddeTopic.IsEmpty()) + ddeTopic = wxT("System"); + // HACK: we use a special feature of wxExecute which exists // just because we need it here: it will establish DDE // conversation with the program it just launched @@ -331,7 +336,8 @@ bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const bool wxFileTypeImpl::GetIcon(wxIcon *icon, wxString *iconFile, - int *iconIndex) const + int *iconIndex, + int iconSize) const { #if wxUSE_GUI wxString strIconKey; @@ -362,7 +368,12 @@ bool wxFileTypeImpl::GetIcon(wxIcon *icon, // here we need C based counting! int nIndex = wxAtoi(strIndex); - HICON hIcon = ExtractIcon(GetModuleHandle(NULL), strExpPath, nIndex); + HICON hIcon, hIconLarge, hIconSmall; + ExtractIconEx(strExpPath, nIndex, &hIconLarge, &hIconSmall, 1); + + hIcon = (iconSize == wxICON_LARGE) ? hIconLarge : hIconSmall; + + switch ( (int)hIcon ) { case 0: // means no icons were found case 1: // means no such file or it wasn't a DLL/EXE/OCX/ICO/... @@ -372,6 +383,8 @@ bool wxFileTypeImpl::GetIcon(wxIcon *icon, default: icon->SetHICON((WXHICON)hIcon); + wxSize size = wxGetHiconSize(hIcon); + icon->SetSize(size); if ( iconIndex ) *iconIndex = nIndex; if ( iconFile ) @@ -594,7 +607,7 @@ wxFileType *wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo) // now make other extensions have the same filetype - + for (iExtCount=1; iExtCount < ftInfo.GetExtensionsCount(); iExtCount++ ) { ext = ftInfo.GetExtensions()[iExtCount]; @@ -636,8 +649,8 @@ wxFileType *wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo) // SetCommand(), SetDefaultIcon() &c will use it later) wxRegKey keyFT(wxRegKey::HKCR, filetype); ok = keyFT.Create(); - - wxFileType *ft = NULL; + + wxFileType *ft = NULL; ft = CreateFileType(filetype, extWithDot); if (ft) @@ -654,7 +667,7 @@ wxFileType *wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo) bool wxFileTypeImpl::SetCommand(const wxString& cmd, const wxString& verb, - bool overwriteprompt) + bool WXUNUSED(overwriteprompt)) { wxCHECK_MSG( !m_ext.IsEmpty() && !verb.IsEmpty(), FALSE, _T("SetCommand() needs an extension and a verb") ); @@ -827,3 +840,5 @@ bool wxFileTypeImpl::RemoveDescription() #endif // __WIN16__ + +#endif // wxUSE_MIMETYPE