can someone please get me started on drag and drop in a listview?
I have started a ListView tutorial that will include this, for now I will post the example code once I get home from work later today.
just to make sure you know what i mean... I want to be able to drag a file from the computer and drop it on the listview which then will use the filename. I know how to get the listview to allow files but i cant figure out what notification or message to look for.
I understand exactly what you mean, I just got home a few minutes ago and will slap something together shortly.
ok cool.. thanks.
Here's a quick example I threw together, no commenting but here it goes..
- Just used a very basic listview test bed I had kicking around
- This example is in GoAsm syntax, I am too tired to translate to other assemblers right now
- The listview has the WS_EX_ACCEPTFILES style set.
- The listview needs to be subclassed in order to process the WM_DROPFILES message
- DragQueryFile is called with -1 in order to obtain the number of files dropped
- It is then called in a loop, displaying a message box with the name of each file.
- Once the last file has been reached, DragFinish is called to close the drag handle.
Enjoy,
Donkey
[attachment deleted by admin]
thx for the example.. ill see if i can it workin like i want..
ok for those that want the masm format i am posting the code that i used to do the subclass and the code that creates my listview from the WM_CREATE message.
ListViewSubClass PROTO :HWND, :DWORD, :DWORD, :DWORD
.DATA
ListViewClassName db "SysListView32",0
.DATA?
hList dd ?
pListviewProc dd ?
.CONST
MAXSIZE equ 260
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
cmp uMsg, WM_DESTROY
jne @F
Invoke PostQuitMessage,NULL
jmp Return
@@:
cmp uMsg, WM_CREATE
jne @F
Invoke CreateWindowEx, WS_EX_CLIENTEDGE or WS_EX_ACCEPTFILES, addr ListViewClassName, NULL, LVS_REPORT or WS_CHILD or WS_VISIBLE, 0,0,493,318,hWnd, NULL, hInstance, NULL
mov hList, eax
mov eax, LVS_EX_FULLROWSELECT or LVS_EX_HEADERDRAGDROP or LVS_EX_GRIDLINES
Invoke SendMessage, hList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, eax
Invoke InsertColumn
Invoke SetWindowLong, hList, GWL_WNDPROC, offset ListViewSubClass
mov pListviewProc,eax
jmp Return
@@:
Invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
Return:
xor eax,eax
ret
WndProc endp
ListViewSubClass proc hWnd:HWND, uMsg:DWORD, wParam:WPARAM, lParam:LPARAM
LOCAL szDropFile[MAXSIZE]:DWORD
cmp uMsg,WM_DROPFILES
jne DEFPROC
Invoke DragQueryFile,wParam,-1,ADDR szDropFile,MAXSIZE
mov ebx,eax
@@:
sub ebx, 1
js @F
Invoke DragQueryFile,wParam,ebx,ADDR szDropFile,MAXSIZE
Invoke MessageBox,NULL,ADDR szDropFile,ADDR AppName,MB_OK
jmp @B
@@:
Invoke DragFinish,wParam
xor eax,eax
ret
DEFPROC:
Invoke CallWindowProc,pListviewProc,hWnd,uMsg,wParam,lParam
ret
ListViewSubClass endp
Again thx donkey for the help :)
Donky,
Do you happen to know how to
make it so you can drag to Windows
Explorer? or the desktop? I have tried
this I can drag to and from my listviews
and it works, but I can't find a window
in windows explorer that has the acceptfiles style
so it don't work.
I get the handle to the drop window where
the mouse was released then if that window is not a
exceptfile style one I get the parent of that window
to test it. I do this untill I find no more parents.
Zcoder....
to make it work with windows explorer you will need to use COM.
There exist some source samples for masm, but I cannot remember the names.
Well this is kinda rud to me.
Example when I drag a file or files from windows Explorer
windows explorer sends me a WM_DROPFILES message
my app then uses DragQueryFile to first get the cound of files.
then uses DragQueryFile over and over to get each file name
all this comes from a DROPFILE structure.
This means that windows Explorer build a DROPFILE structre
with the list of files in it and then posted my app a WM_DROPFILES
message.
so I do the same to send files to explorer but it don't work
this would make you think I am sending the DROPFILE structure wrong
or building it wrong, but I can drop files to and from my apps that have
this ability to accept files using WM_DROPFILES and DragQueryFile API
method, so why is windows explorer sending it to my app this way
put expects me to send it using some other method??? like COM
or what ever???
this has me confued, as I can drag and drop files to other programs from my apps
using this method.
as I have done it without no problems.
Can someone explain this problem and how an app is to know what method to use
to send a list of files to another app? example how does the drag source app know
what the drop destination program will use to accept draged files?
Here is a program that drages and drops files it drags and drops to each window
and from windows explorer but not to explorer.
Zcoder....
[attachment deleted by admin]
Hi ZCoder,
I did not know that, though it has some interesting applications. I am currently working on a listview tutorial (begginer to advanced) and will look into it. I have also use the IDropTarget interface in some applications that is a bit more flexible for drag and drop, I may end up posting some examples one day.
I guess since explorer is able to list not only files and directories, it has to use a more general approach for drag & drop than just the file oriented DragQueryFile functions.
I did find the url of the COM example in the meantime:
www.japheth.de/Download/dragdrop.zip
(http://www.japheth.de/Download/dragdrop.zip)
Gustav,
thanks for the example, it sure does do what I wanted.
Thing is, the example is done in a different programming style then my project is
example: you have to assemble it all into different obj's and then link them together
with your main app's obj, thats fine, but I do about the same exept I cheat.
While assembling into obj's I place them all in a lib, then assemle with my main
app. Well I took out everything that had to do with his examples main app
assembled them all into objs and then put them into a LIB when I use the
lib to use the functions I get dupclicate symbol error's and undefined proc
error's or other items missing.
So I worked on it for God nows how long to track down what was wrong
and I failed. So this example will most likely be hard for anyone to port to
another project style, I will do it, but it will take time as I have to study
this untill I know it inside and out, so I know what is needed and what
is not and to get these all into a lib for other to use.
Other then that it is what I was looking for.
Thanks alot for pointing me to the example.
Zcoder....
zcoder,
Read Japheth's site carefully. He uses a very different windows.inc and you need to provide for that. PM me if you need more help. I converted another of his projects (Joe) to enable it to be built using Masm32 and it was not too hard. Japheth does not use Masm32.
Paul
I was able to assemble and link it without errors, using the MASM32 V7 windows.inc from the very same site.
Isn't there some sort of licensing issue with using that version? Your results are sure interesting, though.
Paul
> Isn't there some sort of licensing issue with using that version?
I don't know. AFAICS it is allowed to distribute the masm32 windows.inc with non-commercial products.
I'm not sure about the v7 License but the v9 license clearly states that:
Quote from: masm32 License
What you CANNOT do with the MASM32 Project.
1. The MASM32 Project is not an item of trade or commerce. It cannot be either purchased or sold.
2. The MASM32 Project cannot be re-licenced or made subordinate to any other form of licence.
3. None of its components or source code are redistributable.
4. You cannot use the MASM32 Project to write software for Non-Microsoft Operating Systems.
5. You cannot use the MASM32 Project to write any form of illegal software.
that sounds bad, especially no 3.
In windows.inc of v8 there is a notice:
------------------------------------------------------------------------
WINDOWS.INC is copyright software licenced to the user by the
MASM32 project. It is available completely free of any charges
for any person to use for purposes including commercial software
but the file must not be sold or included in any commercial
programming package.
------------------------------------------------------------------------
So it seems the licence is getting a bit more restrictive from version to version.
The MASM32 license is for the MASM32 project, the equates in Windows.inc can not subject to it's license, they were released by Microsoft as part of it's header files and are a derivitive work of that project. Neither Hutch nor the MASM32 project can legally copyright the Windows equates, copyright requires an original work, and does not apply to derivitive works, and those equates belong to Microsoft, arranging them in a single file is derivitive in nature and so no copyright can be assumed.
The individual functions in the MASM32 library are subject to the copyright restrictions placed on them by their original author unless the copyright was transferred to the project.
Any code you compile using MASM is your own, the MASM32 project makes no claim to ownership of MASM and never has, but usage of MASM is limited by the Microsoft EULA distributed with whatever MASM package you might be using.
However, any original software or tools that are distributed as part of MASM32 and whose author has ceded the copyright of to the MASM32 project, is subject to the provisions of the license.
To avoid confusion, my last posting is because he said he used V7 of ml.exe to build the project. That is not allowed. That is what I was hinting at. I think Mark is the only one to understand the point.
Paul
The only reason why the windows.inc file is subject to copyright is to prevent the many attempts to commercially eploit it. To protect everyone who has contributed to the project over time all of the software is subject to the projects copyright as well as any that the owner has applied to it. I have made special provision for true no bullshit freeware to be able to use the include files but i will not allow them to be bundled with any commercial software of be relicenced in any form as they are first and formost for assembler programmers to use completely free of any charges or any licencing restrictions.
I cannot help anyone who uses Japheths include files and I don't intend to make any effort to support them as I have never had anything useful contributed from Japheth. If anyone does have problems with them, they should contact Japheth for support.
> I cannot help anyone who uses Japheths include files and I don't intend to make any effort to support them as I
> have never had anything useful contributed from Japheth. If anyone does have problems with them, they should
> contact Japheth for support.
nice, but we were not talking about japeth's include files, but of the masm32 v7 windows.inc he supplies on his page and which Paul Brennick has doubted to have a valid licence, as far as I had understood. Shouldn't it be possible to read the thread at least briefly before posting?
All things are possible and I have no problems reading at all but what I addressed was how I licence the windows.inc file, not what Paul may have thought about an old version that is on another site. The copyright issue was raised by Donkey so I clarified how the windows.inc file is licenced and while the equate specification belong to Microsoft, the actual file is part of the masm32 project and is subject to its licence.
I have no problems with Japheth having an out of date version of Windows.inc from the masm32 project on his site but I will make the point again that I will not support out of date versions of the file or anyone elses include file sets. Anyone is free to use anything they like but if they want support for Japheth's include files, they will need to get it from him.
Quote from: hutch-- on March 10, 2006, 07:21:53 AM
the actual file is part of the masm32 project and is subject to its licence.
Yup, I should have been more clear about that, the file itself is copyright and is subject to it's license, the equates however as I had mentioned are not. That is if you find an equate value in the file you can use it in your program without concern of any license.
I think should clear it up for everyone. If you wish to post your projects on your website that is something that everyone encorages. But when it comes to tools and such, you should point your visitors to the proper website where authentic downloads are to be had. It seems this topic is all over the place but the point Hutch made is a very important one and I understood his point right away.
[ ] <-- This area is reserved for a point that I decided not to make.
Paul