Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Dropfiles und der Cursor (https://www.delphipraxis.net/69015-dropfiles-und-der-cursor.html)

turboPASCAL 9. Mai 2006 09:32


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:

turboPASCAL 10. Mai 2006 10:01

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

MSDN Referenz


Leider ist das nur für Listboxen.
Das muss man doch auch auf ein Fenster beziehen können. :gruebel:

chaosben 10. Mai 2006 10:43

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:
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;
Initialisiert wird das via:
Delphi-Quellcode:
OleInitialize(nil);
  {Allow window to accept drop events}
  OleCheck(RegisterDragDrop(Handle, Self));
Und das Gegenteil ist:
Delphi-Quellcode:
{Finished accepting drops}
  RevokeDragDrop(Handle);
  OleUninitialize;
Ach so, das Formular braucht noch die IDropTarget-Unterstützung ... also:
Delphi-Quellcode:
MyNiceFormWithDropDeny = class(TForm, IDropTarget)

turboPASCAL 10. Mai 2006 12:49

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 15:25 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz