Drag files to listbox

i have a listbox that i would like to be able to drop files in
 
LISTBOX         SETTINGS_DIALOG_LIST, 12, 97, 174, 55, WS_HSCROLL, WS_EX_ACCEPTFILES


in main WndProc
1
2
3
4
	case WM_INITDIALOG:
		HWND_SETTINGS_DIALOG_DLL_LIST			= GetDlgItem(hWnd, SETTINGS_DIALOG_LIST);
		WNDPROC_ORIGINAL_SETTINGS_DIALOG_LIST = (WNDPROC) SetWindowLong(HWND_SETTINGS_DIALOG_LIST, GWL_WNDPROC, (LONG) WNDPROC_SETTINGS_DIALOG_LIST);
		break;


then my subclass listbox
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
LRESULT APIENTRY WNDPROC_SETTINGS_DIALOG_LIST(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch(uMsg)
	{
	case WM_DROPFILES:
		{
			char	szDroppedFile[MAX_PATH];
			HDROP	hDrop ;

			hDrop = (HDROP)wParam;

			int c = DragQueryFile ( hDrop, 0xFFFFFFFF, ( LPTSTR ) szDroppedFile, sizeof ( szDroppedFile ) ) ;

			for ( int i = 0 ; i < c ; i++ )
			{
				int c = DragQueryFile ( hDrop, i, ( LPTSTR ) szDroppedFile, sizeof ( szDroppedFile ) ) ;

				//Do My Stuff here
			}
		}
		break;
	}
	return CallWindowProc(WNDPROC_ORIGINAL_SETTINGS_DIALOG_LIST, hwnd, uMsg, wParam, lParam);
}


problem is that the mouse pointer dont even change when your draging a file over the list box
you must first call DragAcceptFiles() in order to have a drop target.
You always need a registered drop target for drag&drop action.

See:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb776406%28v=vs.85%29.aspx
i can get drag & drop working in the full window with

EXSTYLE WS_EX_ACCEPTFILES

in my resource file but the problem is that i only want the drag an drop to work in my list box.
an only want the mouse to change while trying to drop into the list box
thats why i sub classed the listbox

DragAcceptFiles(hWnd, true);
works the same as EXSTYLE WS_EX_ACCEPTFILES but not how i want

DragAcceptFiles(HWND_SETTINGS_DIALOG_DLL_LIST, true);
dont work
Last edited on
while it is not documented it seems indeed that WM_DROPFILES works only for the main window.
Topic archived. No new replies allowed.