WM_DROPFILES mit SendMessage() senden
-
Hallo!
Ich möchte sozusagen eine WM_DROPFILES Message simulieren, d.h. ich möchte diese Nachricht per SendMessage() an ein Steuerelement senden. Das Problem ist nur, dass WM_DROPFILES als WPARAM ein HDROP Handle benötigt und ich habe keine Ahnung, wie ich ein solches erstellen kann. Kann mir da jemand weiterhelfen?
Gruß veryxRV
-
Hallo,
hast du dafür schon eine Lösung gefunden? Ich habe exakt das
gleiche Problem. Mein Control muss ebenfalls auf diesem Weg
Text übermittelt bekommen.
-
Warum eigentlich simulieren? Implementiert doch einen echten DragDrop.
-
Nein, habe leider noch keine Lösung.
Ich verwende ja auch einen echten Drag&Drop, möchte das Hinzufügen der Liste von Dateien aber auch über einen OpenFileDialog ermöglichen. Damit ich den Code unter der WM_DROPFILES case Marke nicht in eine Funktion packen muss, würde ich die in dem OpenFileDialog selektierte Datei gerne an WM_DROPFILES weitergeben.
-
Such mal in der MSDN nach DROPFILES:
typedef struct _DROPFILES { DWORD pFiles; POINT pt; BOOL fNC; BOOL fWide; } DROPFILES, FAR * LPDROPFILES;Defines the CF_HDROP and CF_PRINTERS clipboard formats. In the CF_HDROP case, the data that follows is a double null-terminated list of file names. For CF_PRINTERS, the data that follows are the printer friendly names.
pFiles
Offset of the file list from the beginning of this structure, in bytes.
pt
Drop point. The coordinates depend on fNC.
fNC
Nonclient area flag. If this member is TRUE, pt specifies the screen coordinates of a point in a window's nonclient area. If it is FALSE, pt specifies the client coordinates of a point in the client area.
fWide
Value that indicates if the file contains wide characters. This value is nonzero if it does contain wide characters, or zero otherwise.Der WPARAM Parameter ist ein Zeiger auf die DROPFILES Structur.
Hinter der Struktur kommt eine Liste mit den Dateien:typedef struct { DROPFILES sDrop; char sFiles[1]; }DropData; DropData *ptr; char *files; ptr = (DropData*)malloc(sizeof(DropData)+FileListSize); ... files = ptr->sFiles; for(i=0;i<...;i++) { strcpy(files,Filename[i]); files+=strlen(files)+1; } *files=0; SendMessage(hwnd,WM_DROPFILES,(WPARAM)ptr,0);