![]() |
Dropfiles und der Cursor
Hi,
ist es möglich bei (WM)DropFiles, also dem Drag and Drop von Dateien auf ein Programm, den Cursor passend zu wechseln ? Beispiel, mit WMDropFiles holt man eine Datei in sein Programm, nun ist das Dateiformat aber von diesem Programm nicht untertützt und nun soll an Stelle des crDrag-Cursors der crNoDrag-Cursor angezeigt werden (schon beim ziehen über das Programm). Apropo wie mach WinXP das mit den Icons mit text beim Drag and Droppen ? :gruebel: |
Re: Dropfiles und der Cursor
Irgend wie muss das funktionieren, Windows kann es ja. Nqach einer suche im Netz und Luckies Tut. fand ich die Messages:
DL_MESSAGE laut MSDN -> There are no search results to display :gruebel: DL_BEGINDRAG, received when an item is selected DL_DRAGGING, received while dragging DL_CANCELDRAG, user cancel dragging by pressing ESCAPE DL_DROPPED, user finished dragging and dropped the item DL_STOPCURSOR, DL_COPYCURSOR, or DL_MOVECURSOR ![]() Leider ist das nur für Listboxen. Das muss man doch auch auf ein Fenster beziehen können. :gruebel: |
Re: Dropfiles und der Cursor
Ich glaube vom SwissDelphiCenter stammt der folgende Code, der jweils eine Zuweisung des Effektes (also auch Verbot) zulässt.
Delphi-Quellcode:
Initialisiert wird das via:
function TForm1.DragEnter(const dataObj: IDataObject; grfKeyState: Integer;
pt: TPoint; var dwEffect: Integer): HResult; var Form : tagFORMATETC; begin dwEffect := DROPEFFECT_COPY; //Hier iss was with Form do begin cfFormat := CF_TEXT; ptd := nil; dwAspect := DVASPECT_CONTENT; lindex := -1; tymed := TYMED_HGLOBAL; end; Result := dataObj.QueryGetData(Form); end; function TForm1.DragLeave: HResult; begin Result := S_OK; end; function TForm1.DragOver(grfKeyState: Integer; pt: TPoint; var dwEffect: Integer): HResult; begin dwEffect := DROPEFFECT_COPY; //Guckst du hier Result := S_OK; end; function TForm1.Drop(const dataObj: IDataObject; grfKeyState: Integer; pt: TPoint; var dwEffect: Integer): HResult; var aFmtEtc: TFORMATETC; aStgMed: TSTGMEDIUM; pData: PChar; begin {Make certain the data rendering is available} if (dataObj = nil) then raise Exception.Create('IDataObject-Pointer is not valid!'); with aFmtEtc do begin cfFormat := CF_TEXT; ptd := nil; dwAspect := DVASPECT_CONTENT; lindex := -1; tymed := TYMED_HGLOBAL; end; {Get the data} OleCheck(dataObj.GetData(aFmtEtc, aStgMed)); try {Lock the global memory handle to get a pointer to the data} pData := GlobalLock(aStgMed.hGlobal); ScanTextForUrls(String(pData)); finally {Finished with the pointer} GlobalUnlock(aStgMed.hGlobal); {Free the memory} ReleaseStgMedium(aStgMed); end; Result := S_OK; end;
Delphi-Quellcode:
Und das Gegenteil ist:
OleInitialize(nil);
{Allow window to accept drop events} OleCheck(RegisterDragDrop(Handle, Self));
Delphi-Quellcode:
Ach so, das Formular braucht noch die IDropTarget-Unterstützung ... also:
{Finished accepting drops}
RevokeDragDrop(Handle); OleUninitialize;
Delphi-Quellcode:
MyNiceFormWithDropDeny = class(TForm, IDropTarget)
|
Re: Dropfiles und der Cursor
Ja, das ist mal ein Anhaltspunkt! Mal schauen ob man daraus was machen kann. ;)
:thumb: |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:20 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz