Re:OnDragOver event not working!
Quote
Alexei Novikov wrote:
> On 31 Mar 1997, Yoav Ben-Yosef wrote:
> > Hi Folks,
> > Have a bit of a problem with OnDragOver - it doesn't respond when draging
> > something from the outside world (like a file name from explorer).
> > Everything is OK when I try to drag a control which is ON the forms, but
> > not for the things from the outside.
> > What am I missing here?
> Nothing. It doesn't work. Delphi's support for drag&drop is
> proprietary. Which is pretty stupid if you ask me. To communicate with
> the outside world, you need to use IDropTarget and IDropSource (?)
> DCOM objects (I think they are defined in OLE2 unit) or WM_DROPFILES
> window message if only need to accept dropped files.
> Alex.
If you only want to accept dropped files the following code snipped
from an app of mine works. (I got most of it from an article on the web
someplace, I've forgot where.)
procedure TfrmMain.FormCreate(Sender: TObject);
begin
DragAcceptFiles(frmMain.Handle, true);
Application.OnMessage := AppMessage;
DragAcceptFiles(Application.Handle, true);
end;
procedure TfrmMain.AppMessage(var Msg: Tmsg; var Handled: Boolean);
const
BufferLength : word = 1023;
var
DroppedFilename : string;
pDroppedFilename : array [0..1023] of Char;
begin
if Msg.Message = WM_DROPFILES then
begin
DragQueryFile(Msg.WParam, 0, pDroppedFilename, BufferLength);
DroppedFilename := StrPas(pDroppedFilename);
OpenFile(DroppedFileName);
DragFinish(Msg.WParam);
Handled := true;
end;
end;
Note that I am only interested in the first file dropped. Search the web
for the original code that handled multiple files.
FWIW,
_/_/_/_/_/_/_/_/_/
_/ _/_/ _/
_/_/_/_/_/ _/
_/ _/ _/
_/ _/_/_/_/_/_/