Einzelnen Beitrag anzeigen

xaromz

Registriert seit: 18. Mär 2005
1.682 Beiträge
 
Delphi 2006 Enterprise
 
#2

Re: DragOver vom Explorer erkennen

  Alt 28. Okt 2006, 10:51
Hallo,

vielleicht kannst Du Dir mit IDropTargetHelper was basteln.

Oder noch einfacher: MSDN-Library durchsuchenIDropTarget:
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Classes, Controls, Forms, ActiveX;

type
  TForm1 = class(TForm, IDropTarget)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    function DragEnter(const dataObj: IDataObject; grfKeyState: Longint;
      pt: TPoint; var dwEffect: Longint): HResult; stdcall;
    function DragOver(grfKeyState: Longint; pt: TPoint;
      var dwEffect: Longint): HResult; stdcall;
    function DragLeave: HResult; stdcall;
    function Drop(const dataObj: IDataObject; grfKeyState: Longint; pt: TPoint;
      var dwEffect: Longint): HResult; stdcall;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses
  Dialogs;

{ TForm1 }

function TForm1.DragEnter(const dataObj: IDataObject; grfKeyState: Integer;
  pt: TPoint; var dwEffect: Integer): HResult;
begin
  dwEffect := DROPEFFECT_COPY;
  Result := S_OK;
end;

function TForm1.DragLeave: HResult;
begin
  Result := S_OK;
end;

function TForm1.DragOver(grfKeyState: Integer; pt: TPoint;
  var dwEffect: Integer): HResult;
begin
  Color := RGB(Random(256), Random(256), Random(256));
  dwEffect := DROPEFFECT_COPY;
  Result := S_OK;
end;

function TForm1.Drop(const dataObj: IDataObject; grfKeyState: Integer;
  pt: TPoint; var dwEffect: Integer): HResult;
begin
  dwEffect := DROPEFFECT_COPY;
  Result := S_OK;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  R: Integer;
begin
  R := RegisterDragDrop(Handle, Self);
  if R <> S_OK then
    ShowMessage('Couldn''t initialize Drag''n''Drop!');
  Randomize;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  RevokeDragDrop(Handle);
end;

initialization
  OleInitialize(nil);
end.
Gruß
xaromz
I am a leaf on the wind - watch how I soar
  Mit Zitat antworten Zitat