[ROSAPPS][VGAFONTEDIT] Allow file drop (#1165)

- Allow file drop on EXE file.
- Allow file drop on the main window.
This commit is contained in:
Katayama Hirofumi MZ 2018-12-19 21:08:25 +09:00 committed by GitHub
parent bba8262bc1
commit 6d47eab526
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 2 deletions

View file

@ -13,5 +13,5 @@ list(APPEND SOURCE
add_executable(vgafontedit ${SOURCE} vgafontedit.rc) add_executable(vgafontedit ${SOURCE} vgafontedit.rc)
add_pch(vgafontedit precomp.h SOURCE) add_pch(vgafontedit precomp.h SOURCE)
set_module_type(vgafontedit win32gui UNICODE) 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) add_cd_file(TARGET vgafontedit DESTINATION reactos/system32 FOR all)

View file

@ -3,6 +3,7 @@
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Implements the main window of the application * PURPOSE: Implements the main window of the application
* COPYRIGHT: Copyright 2008 Colin Finck (colin@reactos.org) * COPYRIGHT: Copyright 2008 Colin Finck (colin@reactos.org)
* Copyright 2018 Katayama Hirofui MZ (katayama.hirofumi.mz@gmail.com)
*/ */
#include "precomp.h" #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 VOID
DoFileSave(IN PMAIN_WND_INFO Info, IN BOOL bSaveAs) 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) MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
static HWND hNextClipboardViewer; static HWND hNextClipboardViewer;
INT i;
PMAIN_WND_INFO Info; PMAIN_WND_INFO Info;
Info = (PMAIN_WND_INFO) GetWindowLongPtrW(hwnd, GWLP_USERDATA); Info = (PMAIN_WND_INFO) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
@ -497,6 +526,12 @@ MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
InitResources(Info); InitResources(Info);
ShowWindow(hwnd, Info->nCmdShow); ShowWindow(hwnd, Info->nCmdShow);
for (i = 1; i < __argc; ++i)
{
MainWndOpenFile(Info, __wargv[i]);
}
DragAcceptFiles(hwnd, TRUE);
return 0; return 0;
case WM_DESTROY: case WM_DESTROY:
@ -521,6 +556,10 @@ MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_SIZE: case WM_SIZE:
MainWndSize( Info, LOWORD(lParam), HIWORD(lParam) ); MainWndSize( Info, LOWORD(lParam), HIWORD(lParam) );
return 0; return 0;
case WM_DROPFILES:
MainWndDropFiles(Info, (HDROP)wParam);
return 0;
} }
} }