RE: drag-n-drop
> -----Original Message-----
> From: Kat [mailto:gertie at PELL.NET]
> Ack, err, <cough> no, i haven't. What version of win32lib
> should i use for that? <duck>
> Tiggr is still on ..
> -- "Bleeding Edge" 0.42e
> -- (c) 1999 David Cuny
>
> but someone asked for an application to make his life easier
> (and his company more
> productive), and it entails dropping text files, html files,
> and various pic files onto an
> icon on the desktop, and the icon's program doing things to
> the file dropped onto it,
> and i haven't gotten into windoze programming except as
> *necessary*. This might be
> useful tho.
>
Here's some code that should work w/v42e (based on what's in 51.1--don't be
surprised if some typos exist below):
constant
xDragQueryFile = define_c_func(shell32, "DragQueryFileA",
{C_POINTER, C_INT, C_POINTER, C_INT}, C_INT),
WM_DROPFILES = #233
procedure main_onevent( atom hWnd, integer iMsg, atom wParam, atom lParam )
integer index, bufferSize, itemCount
atom buffer
sequence fileName
if iMsg = WM_DROPFILES then
-- set up data structures
index = -1 -- 'return the number of filenames'
bufferSize = 256
buffer = allocate( bufferSize )
-- get the count of files
itemCount = w32Func(xDragQueryFile,{wParam, index, buffer,
bufferSize})
-- DragQueryFileA uses zero based indexing
for i = 0 to itemCount - 1 do
-- get position of file name in the buffer
index = w32Func(xDragQueryFile,{wParam, i, buffer, bufferSize})
-- get the file name
fileName &= peek({buffer, index})
-- Insert whatever you want to do with the files here...
end for
-- Free the memory
free( buffer )
end if
end procedure
onEvent[Main] = routine_id("main_onevent")
Matt Lewis
|
Not Categorized, Please Help
|
|