Commit 4ab7aa39 authored by Marian Durkovic's avatar Marian Durkovic
Browse files

Fix skins2 Drag&Drop to accept files with non-ANSI CP characters

parent cc53b715
...@@ -76,6 +76,14 @@ static inline string sFromLocale( const string &rLocale ) ...@@ -76,6 +76,14 @@ static inline string sFromLocale( const string &rLocale )
return res; return res;
} }
/// Wrapper around FromWide, to avoid the need to call free()
static inline string sFromWide( const wstring &rWide )
{
char *s = FromWide( rWide.c_str() );
string res = s;
free( s );
return res;
}
/// Wrapper around ToLocale, to avoid the need to call LocaleFree() /// Wrapper around ToLocale, to avoid the need to call LocaleFree()
static inline string sToLocale( const string &rUTF8 ) static inline string sToLocale( const string &rUTF8 )
......
...@@ -146,22 +146,43 @@ STDMETHODIMP Win32DragDrop::Drop( LPDATAOBJECT pDataObj, DWORD grfKeyState, ...@@ -146,22 +146,43 @@ STDMETHODIMP Win32DragDrop::Drop( LPDATAOBJECT pDataObj, DWORD grfKeyState,
void Win32DragDrop::HandleDrop( HDROP HDrop ) void Win32DragDrop::HandleDrop( HDROP HDrop )
{ {
// Get the number of dropped files if( GetVersion() < 0x80000000 )
int nbFiles = DragQueryFile( HDrop, 0xFFFFFFFF, NULL, 0 ); {
// Use Unicode for Windows NT and above
// Get the number of dropped files
int nbFiles = DragQueryFileW( HDrop, 0xFFFFFFFF, NULL, 0 );
// For each dropped file
for( int i = 0; i < nbFiles; i++ )
{
// Get the name of the file
int nameLength = DragQueryFileW( HDrop, i, NULL, 0 ) + 1;
wchar_t *psz_fileName = new WCHAR[nameLength];
DragQueryFileW( HDrop, i, psz_fileName, nameLength );
// Add the file
CmdAddItem cmd(getIntf(),sFromWide(psz_fileName),m_playOnDrop);
cmd.execute();
// For each dropped file delete[] psz_fileName;
for( int i = 0; i < nbFiles; i++ ) }
}
else
{ {
// Get the name of the file int nbFiles = DragQueryFile( HDrop, 0xFFFFFFFF, NULL, 0 );
int nameLength = DragQueryFile( HDrop, i, NULL, 0 ) + 1;
char *psz_fileName = new char[nameLength]; for( int i = 0; i < nbFiles; i++ )
DragQueryFile( HDrop, i, psz_fileName, nameLength ); {
int nameLength = DragQueryFile( HDrop, i, NULL, 0 ) + 1;
char *psz_fileName = new char[nameLength];
DragQueryFile( HDrop, i, psz_fileName, nameLength );
// Add the file CmdAddItem cmd(getIntf(),sFromLocale(psz_fileName),m_playOnDrop);
CmdAddItem cmd( getIntf(), sFromLocale( psz_fileName ), m_playOnDrop ); cmd.execute();
cmd.execute();
delete[] psz_fileName; delete[] psz_fileName;
}
} }
DragFinish( HDrop ); DragFinish( HDrop );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment