[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
i spotted this in the CHANGES for 4.1.12
Angelo Mottola let application bundles accept files dragged onto the
application icon under MacOS X.
i have presented an idea for win32 drag and drop before, maybe with hackish
code.
this time i'd like to present it again; much cleaner code, and ask that it
be included in the win32 port.
// user provides a callback func
void *drag_and_drop_callback(LONG x, LONG y, const char* sz);
// some code for /src/win/wwnd.c
void win32_process_drag_and_drop(WPARAM w)
{
HANDLE hDrop;
POINT point; // simple struct { LONG x, LONG y }
UINT file_count;
UINT i;
char sz[512];
hDrop = (void*)(w); // the handle to the query is passed in via wParam
if ( 0 == DragQueryPoint(hDrop, &point)) // win32 call, query the mouse
drop point
return;
file_count = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0 ); // win32 call,
query the number of files to be processed
if ( file_count > 0 )
{
for ( i=0 ; i < file_count ; i++ )
{
DragQueryFile(hDrop, i, sz, 512 ); // win32 call, obtain the filename
drag_and_drop_callback(point.x, point.y, sz);
}
}
DragFinish(hDrop);
}
// add this to the msgs
case WM_DROPFILES :
win32_process_drag_and_drop( wParam );
break;
1st argument of CreateWindowEx() in /src/win/wwnd.c
add this WS_EX_ACCEPTFILES
that it!
anyone see any reason why this could not be added ?
aj.