Open lyd405121 opened 3 months ago
case WM_DROPFILES: { HDROP hDrop = reinterpret_cast<HDROP>(wParam); char filename[MAX_PATH]; UINT count = DragQueryFileA(hDrop, -1, NULL, 0); for (UINT i = 0; i < count; ++i) { if (DragQueryFileA(hDrop, i, filename, MAX_PATH)) { printf("%s\n", filename); } } DragFinish(hDrop); return 0; }
Please note that there are a few things that could be improved here:
DragQueryFileW
instead of DragQueryFileA
, because this window is created with the W
version of CreateWindowEx
MAX_PATH
, but query DragQueryFileW
for the required lengthI am not 100% sure there is value is handling this on our side. It may be done on user/app side just as well: your WM_DROPFILES
event handler can be in app code without modifying the backend.
If we add some support then we need to do it and maintain it for all backends. I suppose it would be good to add it as a helper, but it doesn't seem like a very important thing, and I worry it could grow into a more complex thing if we try to design a generic version of it: It's quite unusual API design for us to use a callback for this, ideally we would expose it as a sort of getter then user is free to handle the event when they like in the frame. Also some people would like to connect this to BeginDragDropSource() with ImGuiDragDropFlags_SourceExtern, some people may want to query it differently. It's not something we can do without careful design.
Also see #2602
Version/Branch of Dear ImGui:
Version 1.91
Back-ends:
imgui_impl_iWin32.cpp
Compiler, OS:
Window10
Full config/build information:
No response
Details:
Background
https://github.com/user-attachments/assets/e99f6c75-f23f-4a0e-b865-9c021b140d97
How to do this
https://github.com/user-attachments/assets/2be1d57c-cbf0-4ed8-8059-f4f89cddb9b0
Can it be a feature
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
No response