__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
    OldEditWndProc = Edit1->WindowProc;
    Edit1->WindowProc = NewEditWndProc;
    DragAcceptFiles(Edit1->Handle, TRUE);
}
void __fastcall TForm1::NewEditWndProc(TMessage& message)
{
    if (message.Msg == WM_DROPFILES)
    {
        char buffer[MAX_PATH];
        DragQueryFile((HDROP)message.WParam, 0, buffer, MAX_PATH);
        DragFinish((HDROP)message.WParam);
        Edit1->Text = buffer;
    }

    if (message.Msg == CM_RECREATEWND)
        DragAcceptFiles(Edit1->Handle, FALSE);

    OldEditWndProc(message);

    if (message.Msg == CM_RECREATEWND)
        DragAcceptFiles(Edit1->Handle, TRUE);
}