mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[ui] add drag and drop support
* This feature is only available for Vista or later * Closes #316 * Closes #668
This commit is contained in:
parent
b4128c5ac3
commit
96f421f7d2
3 changed files with 50 additions and 7 deletions
45
src/rufus.c
45
src/rufus.c
|
@ -72,6 +72,13 @@
|
||||||
#define ERROR_FILE_TOO_LARGE 223
|
#define ERROR_FILE_TOO_LARGE 223
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MSGFLT_ADD
|
||||||
|
#define MSGFLT_ADD 1
|
||||||
|
#endif
|
||||||
|
#ifndef WM_COPYGLOBALDATA
|
||||||
|
#define WM_COPYGLOBALDATA 0x49
|
||||||
|
#endif
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
HIMAGELIST himl;
|
HIMAGELIST himl;
|
||||||
RECT margin;
|
RECT margin;
|
||||||
|
@ -2091,12 +2098,14 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
static LPITEMIDLIST pidlDesktop = NULL;
|
static LPITEMIDLIST pidlDesktop = NULL;
|
||||||
static MY_SHChangeNotifyEntry NotifyEntry;
|
static MY_SHChangeNotifyEntry NotifyEntry;
|
||||||
DRAWITEMSTRUCT* pDI;
|
DRAWITEMSTRUCT* pDI;
|
||||||
|
HDROP droppedFileInfo;
|
||||||
POINT Point;
|
POINT Point;
|
||||||
RECT DialogRect, DesktopRect, LangToolbarRect;
|
RECT DialogRect, DesktopRect, LangToolbarRect;
|
||||||
LONG progress_style;
|
LONG progress_style;
|
||||||
HDC hDC;
|
HDC hDC;
|
||||||
int nDeviceIndex, fs, tt, i, nWidth, nHeight, nb_devices, selected_language, offset;
|
int nDeviceIndex, fs, tt, i, nWidth, nHeight, nb_devices, selected_language, offset;
|
||||||
char tmp[128];
|
char tmp[128];
|
||||||
|
wchar_t* wbuffer = NULL;
|
||||||
loc_cmd* lcmd = NULL;
|
loc_cmd* lcmd = NULL;
|
||||||
EXT_DECL(img_ext, NULL, __VA_GROUP__("*.img;*.vhd;*.gz;*.bzip2;*.xz;*.lzma;*.Z;*.zip"), __VA_GROUP__(lmprintf(MSG_095)));
|
EXT_DECL(img_ext, NULL, __VA_GROUP__("*.img;*.vhd;*.gz;*.bzip2;*.xz;*.lzma;*.Z;*.zip"), __VA_GROUP__(lmprintf(MSG_095)));
|
||||||
EXT_DECL(iso_ext, NULL, __VA_GROUP__("*.iso"), __VA_GROUP__(lmprintf(MSG_036)));
|
EXT_DECL(iso_ext, NULL, __VA_GROUP__("*.iso"), __VA_GROUP__(lmprintf(MSG_036)));
|
||||||
|
@ -2426,7 +2435,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
return (INT_PTR)TRUE;
|
return (INT_PTR)TRUE;
|
||||||
case IDC_SELECT_ISO:
|
case IDC_SELECT_ISO:
|
||||||
if (iso_provided) {
|
if (iso_provided) {
|
||||||
uprintf("Image provided: '%s'\n", image_path);
|
uprintf("\r\nImage provided: '%s'", image_path);
|
||||||
iso_provided = FALSE; // One off thing...
|
iso_provided = FALSE; // One off thing...
|
||||||
} else {
|
} else {
|
||||||
safe_free(image_path);
|
safe_free(image_path);
|
||||||
|
@ -2613,6 +2622,25 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WM_DROPFILES:
|
||||||
|
droppedFileInfo = (HDROP)wParam;
|
||||||
|
wbuffer = calloc(MAX_PATH, sizeof(wchar_t));
|
||||||
|
if (wbuffer == NULL) {
|
||||||
|
uprintf("Failed to alloc buffer for drag-n-drop");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DragQueryFileW(droppedFileInfo, 0, wbuffer, MAX_PATH);
|
||||||
|
safe_free(image_path);
|
||||||
|
image_path = wchar_to_utf8(wbuffer);
|
||||||
|
safe_free(wbuffer);
|
||||||
|
|
||||||
|
if (image_path != NULL) {
|
||||||
|
iso_provided = TRUE;
|
||||||
|
// Simulate ISO selection click
|
||||||
|
SendMessage(hDlg, WM_COMMAND, IDC_SELECT_ISO, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
case WM_ENDSESSION:
|
case WM_ENDSESSION:
|
||||||
if (format_thid != NULL) {
|
if (format_thid != NULL) {
|
||||||
|
@ -2782,6 +2810,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||||
char *tmp, *locale_name = NULL, **argv = NULL;
|
char *tmp, *locale_name = NULL, **argv = NULL;
|
||||||
wchar_t **wenv, **wargv;
|
wchar_t **wenv, **wargv;
|
||||||
PF_TYPE_DECL(CDECL, int, __wgetmainargs, (int*, wchar_t***, wchar_t***, int, int*));
|
PF_TYPE_DECL(CDECL, int, __wgetmainargs, (int*, wchar_t***, wchar_t***, int, int*));
|
||||||
|
PF_TYPE_DECL(WINAPI, BOOL, ChangeWindowMessageFilter, (UINT message, DWORD dwFlag));
|
||||||
HANDLE mutex = NULL, hogmutex = NULL, hFile = NULL;
|
HANDLE mutex = NULL, hogmutex = NULL, hFile = NULL;
|
||||||
HWND hDlg = NULL;
|
HWND hDlg = NULL;
|
||||||
HDC hDC;
|
HDC hDC;
|
||||||
|
@ -3037,6 +3066,20 @@ relaunch:
|
||||||
}
|
}
|
||||||
if ((relaunch_rc.left > -65536) && (relaunch_rc.top > -65536))
|
if ((relaunch_rc.left > -65536) && (relaunch_rc.top > -65536))
|
||||||
SetWindowPos(hDlg, HWND_TOP, relaunch_rc.left, relaunch_rc.top, 0, 0, SWP_NOSIZE);
|
SetWindowPos(hDlg, HWND_TOP, relaunch_rc.left, relaunch_rc.top, 0, 0, SWP_NOSIZE);
|
||||||
|
|
||||||
|
// Enable drag-n-drop through the message filter (for Vista or later)
|
||||||
|
if (nWindowsVersion >= WINDOWS_VISTA) {
|
||||||
|
PF_INIT(ChangeWindowMessageFilter, user32);
|
||||||
|
if (pfChangeWindowMessageFilter != NULL) {
|
||||||
|
// NB: We use ChangeWindowMessageFilter() here because
|
||||||
|
// ChangeWindowMessageFilterEx() is not available on Vista
|
||||||
|
pfChangeWindowMessageFilter(WM_DROPFILES, MSGFLT_ADD);
|
||||||
|
pfChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ADD);
|
||||||
|
// CopyGlobalData is needed sine we are running elevated
|
||||||
|
pfChangeWindowMessageFilter(WM_COPYGLOBALDATA, MSGFLT_ADD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ShowWindow(hDlg, SW_SHOWNORMAL);
|
ShowWindow(hDlg, SW_SHOWNORMAL);
|
||||||
UpdateWindow(hDlg);
|
UpdateWindow(hDlg);
|
||||||
|
|
||||||
|
|
11
src/rufus.rc
11
src/rufus.rc
|
@ -32,7 +32,8 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||||
|
|
||||||
IDD_DIALOG DIALOGEX 12, 12, 242, 376
|
IDD_DIALOG DIALOGEX 12, 12, 242, 376
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
CAPTION "Rufus 2.7.833"
|
EXSTYLE WS_EX_ACCEPTFILES
|
||||||
|
CAPTION "Rufus 2.7.834"
|
||||||
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
|
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
|
||||||
BEGIN
|
BEGIN
|
||||||
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
|
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
|
||||||
|
@ -319,8 +320,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 2,7,833,0
|
FILEVERSION 2,7,834,0
|
||||||
PRODUCTVERSION 2,7,833,0
|
PRODUCTVERSION 2,7,834,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -337,13 +338,13 @@ BEGIN
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
|
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
|
||||||
VALUE "FileDescription", "Rufus"
|
VALUE "FileDescription", "Rufus"
|
||||||
VALUE "FileVersion", "2.7.833"
|
VALUE "FileVersion", "2.7.834"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)"
|
||||||
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
||||||
VALUE "OriginalFilename", "rufus.exe"
|
VALUE "OriginalFilename", "rufus.exe"
|
||||||
VALUE "ProductName", "Rufus"
|
VALUE "ProductName", "Rufus"
|
||||||
VALUE "ProductVersion", "2.7.833"
|
VALUE "ProductVersion", "2.7.834"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
|
@ -283,7 +283,6 @@ const char* StrError(DWORD error_code, BOOL use_default_locale)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL WriteFileWithRetry(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
|
BOOL WriteFileWithRetry(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
|
||||||
LPDWORD lpNumberOfBytesWritten, DWORD nNumRetries)
|
LPDWORD lpNumberOfBytesWritten, DWORD nNumRetries)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue