Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for file drag and drop #224

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Examples/WhisperDesktop/TranscribeDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,25 @@ enum struct TranscribeDlg::eVisualState : uint8_t
Stopping = 2
};

LRESULT TranscribeDlg::OnDropFiles(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
HDROP hDrop = (HDROP)wParam;

UINT fileCount = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);

if (fileCount > 0)
{
TCHAR filePath[MAX_PATH];
if (DragQueryFile(hDrop, 0, filePath, MAX_PATH) > 0)
{
sourceMediaPath.SetWindowText(filePath);
}
}

DragFinish(hDrop);

return 0;
}
// CBN_SELCHANGE notification for IDC_OUTPUT_FORMAT combobox
LRESULT TranscribeDlg::onOutFormatChange( UINT, INT, HWND, BOOL& bHandled )
{
Expand Down
7 changes: 5 additions & 2 deletions Examples/WhisperDesktop/TranscribeDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TranscribeDlg :
// Show this dialog modally, without parent.
HRESULT show();

BEGIN_MSG_MAP( LoadModelDlg )
BEGIN_MSG_MAP(TranscribeDlg)
MESSAGE_HANDLER( WM_INITDIALOG, OnInitDialog )
ON_BUTTON_CLICK( IDC_CONSOLE, cbConsole.click )
ON_BUTTON_CLICK( IDCANCEL, onClose )
Expand All @@ -36,10 +36,12 @@ class TranscribeDlg :
COMMAND_HANDLER( IDC_OUTPUT_FORMAT, CBN_SELCHANGE, onOutFormatChange )
COMMAND_HANDLER( IDC_PATH_MEDIA, EN_CHANGE, onInputChange )
MESSAGE_HANDLER( WM_CALLBACK_STATUS, onCallbackStatus )
MESSAGE_HANDLER(WM_DROPFILES, OnDropFiles)

MSG_WM_CLOSE( onWmClose )
END_MSG_MAP()

BEGIN_DDX_MAP( LoadModelDlg )
BEGIN_DDX_MAP(TranscribeDlg)
DDX_CONTROL_HANDLE( IDC_MODEL_DESC, modelDesc )
DDX_CONTROL_HANDLE( IDC_PATH_MEDIA, sourceMediaPath )
DDX_CONTROL_HANDLE( IDC_OUTPUT_FORMAT, transcribeOutFormat )
Expand Down Expand Up @@ -117,6 +119,7 @@ class TranscribeDlg :
void __stdcall poolCallback() noexcept override final;

LRESULT onCallbackStatus( UINT, WPARAM wParam, LPARAM, BOOL& bHandled );
LRESULT OnDropFiles(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);

HRESULT transcribe();
void getThreadError();
Expand Down
Binary file modified Examples/WhisperDesktop/WhisperDesktop.rc
Binary file not shown.