I have
procedure TMainForm.FormCreate(Sender: TObject);
begin
DragAcceptFiles (Handle, True ) ;
end ;
but the form does not accept dragged files - no drop cursor, no firing of WM_DROPFILES message.
I had the following construct in my FormShow event (for a different reason - there was code I wanted to execute only once after the form was created, and FormShow was firing more than once during initialisation) :
procedure TMainForm.FormShow(Sender: TObject);
begin
if (not FRunOnce) then // as FormShow can be called twice - if Form.Position assigned to
begin
DragAcceptFiles (Handle, True ) ;
FRunOnce := True ;
end ;
end ;
DragAcceptFiles (Handle, True ) in the position shown still doesn't work. If I move it to the top of the routine (so it executes twice), it does work:
procedure TMainForm.FormShow(Sender: TObject);
begin
DragAcceptFiles (Handle, True ) ;
if (not FRunOnce) then // as FormShow can be called twice - if Form.Position assigned to
begin
FRunOnce := True ;
end ;
end ;
All the example code I have found seems to call DragAccept during OnCreate. My experiments suggest this is too early, as is the first fire of OnShow. I'm sure something is wrong with my code elsewhere but what might be causing this?