WIN32: get Unicode filename of Dropped files

This commit is contained in:
Thomas Bernard 2018-12-18 17:52:28 +01:00
parent 322d95add8
commit b706566f57
5 changed files with 55 additions and 38 deletions

View File

@ -697,41 +697,52 @@ void Main_handler(void)
char* flimit;
byte old_cursor_shape;
Upload_infos_page(&Main);
flimit = Find_last_separator(Drop_file_name);
*(flimit++) = '\0';
Hide_cursor();
old_cursor_shape=Cursor_shape;
Cursor_shape=CURSOR_SHAPE_HOURGLASS;
Display_cursor();
Init_context_layered_image(&context, flimit, Drop_file_name);
Load_image(&context);
if (File_error!=1)
if (flimit != NULL)
{
Compute_limits();
Compute_paintbrush_coordinates();
Redraw_layered_image();
End_of_modification();
Main.image_is_modified=0;
}
Destroy_context(&context);
Compute_optimal_menu_colors(Main.palette);
Check_menu_mode();
Display_menu();
if (Config.Display_image_limits)
Display_image_limits();
*(flimit++) = '\0';
Upload_infos_page(&Main);
Hide_cursor();
Cursor_shape=old_cursor_shape;
Display_all_screen();
Display_cursor();
Hide_cursor();
old_cursor_shape=Cursor_shape;
Cursor_shape=CURSOR_SHAPE_HOURGLASS;
Display_cursor();
Init_context_layered_image(&context, flimit, Drop_file_name);
if (Drop_file_name_unicode != NULL)
{
context.File_name_unicode = Find_last_separator_unicode(Drop_file_name_unicode);
if (context.File_name_unicode != NULL)
context.File_name_unicode++;
}
Load_image(&context);
if (File_error!=1)
{
Compute_limits();
Compute_paintbrush_coordinates();
Redraw_layered_image();
End_of_modification();
Main.image_is_modified=0;
}
Destroy_context(&context);
Compute_optimal_menu_colors(Main.palette);
Check_menu_mode();
Display_menu();
if (Config.Display_image_limits)
Display_image_limits();
Hide_cursor();
Cursor_shape=old_cursor_shape;
Display_all_screen();
Display_cursor();
}
}
free(Drop_file_name);
Drop_file_name=NULL;
free(Drop_file_name_unicode);
Drop_file_name_unicode=NULL;
}
if(Get_input(0))

View File

@ -82,6 +82,7 @@ int Snap_axis_origin_X;
int Snap_axis_origin_Y;
char * Drop_file_name = NULL;
word * Drop_file_name_unicode = NULL;
#if defined(USE_X11) || (defined(SDL_VIDEO_DRIVER_X11) && !defined(NO_X11))
char * X11_clipboard = NULL;

View File

@ -75,6 +75,7 @@ extern int Snap_axis_origin_Y;
/// This malloced string is set when a drag-and-drop event
/// brings a file to Grafx2's window.
extern char * Drop_file_name;
extern word * Drop_file_name_unicode;
#if defined __HAIKU__
#define SHORTCUT_COPY (KEY_c|MOD_ALT)

View File

@ -1435,7 +1435,7 @@ int main(int argc,char * argv[])
}
#ifdef _MSC_VER
GFX2_Log(GFX2_DEBUG, "built with _MSC_VER=%d\n", _MSC_VER);
GFX2_Log(GFX2_DEBUG, "built with _MSC_VER=%d Windows ANSI Code Page=%u\n", _MSC_VER, GetACP());
#endif
Main_handler();

View File

@ -31,6 +31,7 @@
#include "windows.h"
#include "input.h"
#include "keyboard.h"
#include "unicode.h"
extern int user_feedback_required;
extern word Input_new_mouse_X;
@ -259,17 +260,20 @@ static LRESULT CALLBACK Win32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP
{
TCHAR LongDropFileName[MAX_PATH];
TCHAR ShortDropFileName[MAX_PATH];
if (DragQueryFile(hDrop, 0 , LongDropFileName ,(UINT) MAX_PATH)
&& GetShortPathName(LongDropFileName, ShortDropFileName, MAX_PATH))
if (DragQueryFile(hDrop, 0 , LongDropFileName ,(UINT) MAX_PATH))
{
Drop_file_name = (char *)malloc(lstrlen(ShortDropFileName) + 1);
if (Drop_file_name != NULL)
Drop_file_name_unicode = Unicode_strdup((word *)LongDropFileName);
if (GetShortPathName(LongDropFileName, ShortDropFileName, MAX_PATH))
{
int i;
Drop_file_name = (char *)malloc(lstrlen(ShortDropFileName) + 1);
if (Drop_file_name != NULL)
{
int i;
for (i = 0; ShortDropFileName[i] != 0; i++)
Drop_file_name[i] = (char)ShortDropFileName[i];
Drop_file_name[i] = 0;
for (i = 0; ShortDropFileName[i] != 0; i++)
Drop_file_name[i] = (char)ShortDropFileName[i];
Drop_file_name[i] = 0;
}
}
}
}