|
4 | 4 | #include <stdbool.h> |
5 | 5 | #include <shlobj.h> |
6 | 6 |
|
| 7 | +#include "treeview_extension.h" |
7 | 8 | #include "utility.h" |
8 | 9 | #include "bnk-extract/defs.h" |
9 | 10 |
|
@@ -99,17 +100,7 @@ static HRESULT STDMETHODCALLTYPE DragOver(IDropTarget* This, DWORD grfKeyState, |
99 | 100 |
|
100 | 101 | // early return in case DragEnter determined that this data is not drag-drop supported |
101 | 102 | if (!idropTarget->dragValid) return S_OK; |
102 | | - printf("x: %ld, y: %ld\n", pt.x, pt.y); |
103 | | - // The POINT structure is identical to the POINTL structure. |
104 | | - POINT point = { |
105 | | - .x = pt.x, |
106 | | - .y = pt.y |
107 | | - }; |
108 | | - printf("screentoclient return: %d\n", ScreenToClient(treeview, &point)); |
109 | | - printf("x: %ld, y: %ld\n", point.x, point.y); |
110 | | - TVHITTESTINFO hitTestInfo = {.pt = point}; |
111 | | - HTREEITEM hoveredItem = TreeView_HitTest(treeview, &hitTestInfo); |
112 | | - printf("hovered Item: %p\n", hoveredItem); |
| 103 | + HTREEITEM hoveredItem = TreeView_PerformHitTest(pt.x, pt.y, NULL); |
113 | 104 | if (hoveredItem) *pdwEffect = DROPEFFECT_COPY; |
114 | 105 |
|
115 | 106 | return S_OK; |
@@ -167,13 +158,14 @@ static HRESULT STDMETHODCALLTYPE Drop(IDropTarget* This, IDataObject* pDataObj, |
167 | 158 | UINT fileNameSize = DragQueryFile(hDropInfo, index, NULL, 0); |
168 | 159 | char fileNameBuffer[fileNameSize + 1]; |
169 | 160 | DragQueryFile(hDropInfo, index, fileNameBuffer, fileNameSize + 1); |
170 | | - uint32_t current_file_id = strtol(rstrstr(fileNameBuffer, "\\") + 1, NULL, 0); |
| 161 | + uint32_t current_file_id = strtol(strrchr(fileNameBuffer, '\\') + 1, NULL, 0); |
171 | 162 | AudioData* wemData = NULL; |
172 | 163 | printf("wemDataList: %p\n", wemDataList); |
173 | 164 | printf("length of list: %llu\n", wemDataList->length); |
174 | 165 | for (uint32_t i = 0; i < wemDataList->length; i++) { |
175 | 166 | printf("objects[%d]: %u\n", i, wemDataList->objects[i].id); |
176 | 167 | } |
| 168 | + // relies on the fact this list is inherently sorted, which it always is in practice. |
177 | 169 | find_object_s(wemDataList, wemData, id, current_file_id); |
178 | 170 | printf("wemData: %p\n", wemData); |
179 | 171 | if (wemData) { |
|
0 commit comments