How to Use Drag and Drop

Hi I was wondering how to implement Drag and Drop.

Basically I have a bunch of graphics files that I need to change the background colors to transparent. I could do this in code but I'd have to type in each image address by hand and the graphics are in multiple files, I figure using drag and drop would be much quicker and I could use it in later programming too.

I'm using visual C++ 2010 (Free Version), I have SFML up and running. OS = windows7
Is there an SDK that I'd have to download to do this?
Last edited on
closed account (o3hC5Di1)
I'm sorry, I'm afraid I don't quite follow how you would like to use drag and drop here?

Might thisbe what you are looking for? : http://codebetter.com/petervanooijen/2007/07/07/basic-drag-and-drop-in-winforms/

All the best,
NwN
I want to be able to drag an image file from a folder or the desktop to my program and be able to get the address of that file into the program so the program can make a copy of the file after changing the background colors.
Just process WM_DROPFILES in your window procedure. There is example code already posted in these forums.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
case WM_DROPFILES:
		{
	
		TCHAR lpszFile[MAX_PATH] = {0};
		UINT uFile = 0;
		HDROP hDrop = (HDROP)wParam;

		uFile = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, NULL);
		if (uFile != 1){
			MessageBox (hDlg, _T("Dropping multiple files is not supported."), NULL, MB_ICONERROR);
			DragFinish(hDrop);
			break;
			}
		lpszFile[0] = '\0';
		if (DragQueryFile(hDrop, 0, lpszFile, MAX_PATH))
			{
				MessageBox (NULL, lpszFile, NULL, MB_ICONINFORMATION);
			}
			
		DragFinish(hDrop);
			break;
		}
Last edited on
OK, uh, I have no Idea what is going on in that code, is there a link to a tutorial, or to the original example code?

I don't know what it means to "process WM_DROPFILES in your window procedure" especially since I don't know about "window procedure" in the first place.

Thanks for the help, but I'm just not at that level yet. Any links you have would be very helpful.
closed account (o3hC5Di1)
Hi there,

Code seems to come from this thread:
http://www.cplusplus.com/forum/windows/59537/2/

Here's an article giving some more explanation, not sure if it will be enough to you though:
http://bcbjournal.org/articles/vol1/9709/What_a_drag!.htm?PHPSESSID=5bbb31e23a30aca64ebc297392a4286a

All the best,
NwN
Topic archived. No new replies allowed.