Drag + Drop
-
hallo,
ich habe einen Dialog in dem ich ein Groupbox definiert hab die Drag&Drop Fähig ist (WS_EX_ACCEPTFILES).
Nun hab ich in meiner Callbackfunktion des Dialoges die WM_DROPFILES: eingebaut, allerdings passiert nichts wenn ich im debugger einen breakpoint in diesen caseblock setze. Scheint also etwas zu fehlen, da die WM nicht ausgelöst wird.
der Dialog selbst kommt aus einer ressource und hab ich in VC Editor zusammen geklickt. Die Groupbox füge ich zur laufzeit hinzu.
Die Große Preisfrage ist jetzt was fehlt, ich hab leider nicht wirklich viel glück beim googeln gehabt das wir die frage beantwortet hätte.
// DirectInputDialog.cpp : Definiert den Einstiegspunkt für die Anwendung. // #include "stdafx.h" #include "main.h" #include "shellapi.h" INT_PTR CALLBACK DialogCallback(HWND, UINT, WPARAM, LPARAM); HWND g_hDlg = NULL; int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { DialogBox(hInstance, MAKEINTRESOURCE(IDD_INPUT), NULL, DialogCallback); return 0; } // Meldungshandler für Infofeld. INT_PTR CALLBACK DialogCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND hGroupbox; HDROP hDropFile; INT_PTR nSize, nCount, nForIndex; g_hDlg = hDlg; UNREFERENCED_PARAMETER(lParam); switch (message) { case WM_INITDIALOG: { hGroupbox = CreateWindowEx( WS_EX_ACCEPTFILES, L"button",L"Video zum splitten" , BS_GROUPBOX | WS_VISIBLE | WS_CHILD , 15, 40, 200, 100, hDlg, (HMENU) 1000, NULL , NULL); return (INT_PTR)TRUE; } case WM_COMMAND: { if(LOWORD(wParam) == IDOK) EndDialog(hDlg,(INT_PTR)TRUE); break; } case WM_DROPFILES: { hDropFile = (HDROP) wParam; nCount = DragQueryFile(hDropFile, -1, NULL, 0); for (nForIndex = 0; nForIndex < nCount; ++nForIndex) { if( 0 == (nSize = DragQueryFile(hDropFile, -1, NULL, 0))) continue; } DragFinish(hDropFile); } case WM_CLOSE: { EndDialog(hDlg,(INT_PTR)TRUE); break; } } return (INT_PTR)FALSE; }
-
Groubboxen verhalten sich im allgemeinen Transparent gegebnüber Maus Aktionen. Sie eignet sich also nicht für Drag-Accept. Du könntest das lösen in dem Du die Groupbox subclasses und bei WM_NCHITTEST HTCLIENT returnierst. Muss es eine Groupbox sein?
-
Martin Richter schrieb:
Groubboxen verhalten sich im allgemeinen Transparent gegebnüber Maus Aktionen. Sie eignet sich also nicht für Drag-Accept. Du könntest das lösen in dem Du die Groupbox subclasses und bei WM_NCHITTEST HTCLIENT returnierst. Muss es eine Groupbox sein?
Muss nicht, aber ich find es optisch ganz nett wenn man die datei einfach in den groubbox bereich reinfallen lassen könnte.
subclasses müsste ich mir mal anschauen, höre ich das erstemal.....danke soweit.
-
da bin ich wieda, klemmt wieder. ich hab dieses beispiel gefunden für Drag+Drop: http://www.winapi.net/index.php?inhalt=s41
Das hab ich dann bei mir so umgesetzt:
Leider gelingt es mir aber nicht den dateinamen der datei abzufragen, ich krieg immer nur ein 'C' als Dateinamen geliefert, woran könnte das liegen?
// DirectInputDialog.cpp : Definiert den Einstiegspunkt für die Anwendung. // #include "stdafx.h" #include "main.h" #include "shellapi.h" INT_PTR CALLBACK DialogCallback(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK GroupBoxProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); HWND g_hDlg = NULL; static LONG_PTR PrevWndProcEdit; int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { DialogBox(hInstance, MAKEINTRESOURCE(IDD_INPUT), NULL, DialogCallback); return 0; } // Meldungshandler für Infofeld. INT_PTR CALLBACK DialogCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND hGroupbox; g_hDlg = hDlg; HDROP hDropFile; INT_PTR nSize, nCount, nForIndex; wchar_t* pszFileName; UNREFERENCED_PARAMETER(lParam); switch (message) { case WM_INITDIALOG: { hGroupbox = CreateWindowEx( WS_EX_ACCEPTFILES, L"button",L"Video zum splitten" , BS_GROUPBOX | WS_VISIBLE | WS_CHILD , 15, 40, 200, 100, hDlg, (HMENU) 1000, NULL , NULL); PrevWndProcEdit = SetWindowLongPtr(hGroupbox, GWLP_WNDPROC, (LONG_PTR) GroupBoxProc); return (INT_PTR)TRUE; } case WM_COMMAND: { if(LOWORD(wParam) == IDOK) EndDialog(hDlg,(INT_PTR)TRUE); break; } case WM_DROPFILES: { hDropFile = (HDROP) wParam; nCount = DragQueryFile(hDropFile, (UINT) -1, NULL, 0); for (nForIndex = 0; nForIndex < nCount; ++nForIndex) { if( 0 == (nSize = DragQueryFile(hDropFile, (UINT) -1, NULL, 0))) continue; pszFileName = new wchar_t[++nSize]; if(DragQueryFile(hDropFile, static_cast<UINT>(nForIndex), pszFileName, static_cast<UINT>(nSize))) // Dateinamen ermitteln { MessageBox(hDlg, pszFileName, L"Tara", MB_OK | MB_ICONEXCLAMATION); } delete []pszFileName; pszFileName = NULL; } DragFinish(hDropFile); break; } case WM_CLOSE: { EndDialog(hDlg,(INT_PTR)TRUE); break; } } return (INT_PTR)FALSE; } LRESULT CALLBACK GroupBoxProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_DROPFILES: { return (SendMessage(GetParent(hwnd), message, wParam, lParam)); } default: break; } return CallWindowProc ((WNDPROC) PrevWndProcEdit, hwnd, message, wParam, lParam); }
-
hat sich erledigt......sobald man um hilfe ruft sieht man es wie den hellen punkt in der nacht.....danke.