D
D
Dmitry Shalimov2017-01-26 16:15:47
User interface
Dmitry Shalimov, 2017-01-26 16:15:47

How to open a file when dragged into a window?

Для упрощения рабочего процесса написал транслятор. Работает просто:
Окно для ввода разметки
4 кнопки на 4 вида обработки
Окно вывода кода.
Когда нужно обработать один файл - все просто, но когда приходится обрабатывать по 7-8 с постоянными правками от заказчика, тратится достаточно много времени.
Собственно вопрос.
Как научить приложение получать содержимое файла при перетаскивание его в окно приложения?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sumor, 2017-01-26
@Akui_Aru

Easy way: Allow AllowDrop for the form and catch the DragDrop event. In its parameters there will be a description of what they throw at you.
Complicated way: for seed, read this https://habrahabr.ru/post/179131/ .
The implementation in Delphi is described there, but the sequence of actions is the same.
It is necessary to describe all the functions that are used through DllImport. Call DragAcceptFiles.
Redefine Wndproc for the form protected override void WndProc(ref Message m), and process the WM_DROPFILES event there and get the transferred list via DragQueryFile.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question