以下参考代码可以解决问题。关键是要在 FormCreate方法中调用 ChangeMessageProi();
class TForm1: public TForm
{
...
private: // User declarations
void virtual __fastcall WMDropFiles(TWMDropFiles &Message);
public: // User declarations
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_DROPFILES,TWMDropFiles,WMDropFiles);
END_MESSAGE_MAP (TForm);
}
void __fastcall TForm1::WMDropFiles(TWMDropFiles &Message) {
UINT FileCount = DragQueryFile((HDROP) Message.Drop, 0xFFFFFFFF, NULL, 0);
String FileName;
String FileExtension;
int FileLength;
for(UINT ii=0; ii < FileCount; ii++) {
FileName.SetLength(MAX_PATH);
FileLength = DragQueryFile((HDROP)Message.Drop, ii, FileName.c_str(), FileName.Length());
FileName.SetLength(FileLength);
Memo1->Lines->Add(FileName);
}
DragFinish((HDROP) Message.Drop);
}
//---------------------------------------------------------------------------
#defi