https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6d47eab52663a152deec3fb5f70804736bd216dc
commit 6d47eab52663a152deec3fb5f70804736bd216dc Author: Katayama Hirofumi MZ <katayama.hirofumi...@gmail.com> AuthorDate: Wed Dec 19 21:08:25 2018 +0900 Commit: GitHub <nore...@github.com> CommitDate: Wed Dec 19 21:08:25 2018 +0900 [ROSAPPS][VGAFONTEDIT] Allow file drop (#1165) - Allow file drop on EXE file. - Allow file drop on the main window. --- .../devutils/vgafontedit/CMakeLists.txt | 2 +- .../applications/devutils/vgafontedit/mainwnd.c | 41 +++++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/modules/rosapps/applications/devutils/vgafontedit/CMakeLists.txt b/modules/rosapps/applications/devutils/vgafontedit/CMakeLists.txt index 43bab70abb..390146eb96 100644 --- a/modules/rosapps/applications/devutils/vgafontedit/CMakeLists.txt +++ b/modules/rosapps/applications/devutils/vgafontedit/CMakeLists.txt @@ -13,5 +13,5 @@ list(APPEND SOURCE add_executable(vgafontedit ${SOURCE} vgafontedit.rc) add_pch(vgafontedit precomp.h SOURCE) set_module_type(vgafontedit win32gui UNICODE) -add_importlibs(vgafontedit user32 gdi32 comdlg32 msvcrt kernel32) +add_importlibs(vgafontedit shell32 user32 gdi32 comdlg32 msvcrt kernel32) add_cd_file(TARGET vgafontedit DESTINATION reactos/system32 FOR all) diff --git a/modules/rosapps/applications/devutils/vgafontedit/mainwnd.c b/modules/rosapps/applications/devutils/vgafontedit/mainwnd.c index cde135a357..fd708491bf 100644 --- a/modules/rosapps/applications/devutils/vgafontedit/mainwnd.c +++ b/modules/rosapps/applications/devutils/vgafontedit/mainwnd.c @@ -3,6 +3,7 @@ * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) * PURPOSE: Implements the main window of the application * COPYRIGHT: Copyright 2008 Colin Finck (co...@reactos.org) + * Copyright 2018 Katayama Hirofui MZ (katayama.hirofumi...@gmail.com) */ #include "precomp.h" @@ -221,6 +222,34 @@ DoFileOpen(IN PMAIN_WND_INFO Info) } } +static VOID +MainWndOpenFile(IN PMAIN_WND_INFO Info, LPCWSTR File) +{ + PFONT_OPEN_INFO OpenInfo; + + OpenInfo = HeapAlloc(hProcessHeap, HEAP_ZERO_MEMORY, sizeof(FONT_OPEN_INFO)); + OpenInfo->pszFileName = HeapAlloc(hProcessHeap, 0, MAX_PATH); + lstrcpynW(OpenInfo->pszFileName, File, MAX_PATH); + + OpenInfo->bCreateNew = FALSE; + CreateFontWindow(Info, OpenInfo); +} + +static VOID +MainWndDropFiles(IN PMAIN_WND_INFO Info, HDROP hDrop) +{ + WCHAR Path[MAX_PATH]; + INT i, Count = DragQueryFileW(hDrop, 0xFFFFFFFF, NULL, 0); + + for (i = 0; i < Count; ++i) + { + DragQueryFileW(hDrop, i, Path, MAX_PATH); + MainWndOpenFile(Info, Path); + } + + DragFinish(hDrop); +} + VOID DoFileSave(IN PMAIN_WND_INFO Info, IN BOOL bSaveAs) { @@ -439,7 +468,7 @@ static LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { static HWND hNextClipboardViewer; - + INT i; PMAIN_WND_INFO Info; Info = (PMAIN_WND_INFO) GetWindowLongPtrW(hwnd, GWLP_USERDATA); @@ -497,6 +526,12 @@ MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) InitResources(Info); ShowWindow(hwnd, Info->nCmdShow); + + for (i = 1; i < __argc; ++i) + { + MainWndOpenFile(Info, __wargv[i]); + } + DragAcceptFiles(hwnd, TRUE); return 0; case WM_DESTROY: @@ -521,6 +556,10 @@ MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_SIZE: MainWndSize( Info, LOWORD(lParam), HIWORD(lParam) ); return 0; + + case WM_DROPFILES: + MainWndDropFiles(Info, (HDROP)wParam); + return 0; } }