1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
void __fastcall TForm1::ApplicationEvents1Message(tagMSG &Msg, bool &Handled)
{
wchar_t Filename(512);
if (Msg.message == WM_DROPFILES)
{
// Trouver nbr de fichiers
int NbrFichier = DragQueryFile((HDROP)Msg.wParam, 0xFFFFFFFFF, NULL, 0);
if (NbrFichier != 1)
{
ShowMessage ("Trop de fichier");
return;
}
DragFinish((HDROP)Msg.wParam);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DrawGrid1DragDrop(TObject *Sender, TObject *Source, int X,
int Y, TDragState State, bool &Accept)
{
if (Source->InheritsFrom(__classid(TWinControl)))
{
TWinControl *SourceControl = dynamic_cast<TWinControl*>(Source);
if (SourceControl)
{
if (dynamic_cast<TDrawGrid*>(SourceControl))
{
UnicodeString FileName = L""; // Chemin du fichier déposé
LoadExcelData(FileName);
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DrawGrid1DragOver(TObject *Sender, TObject *Source, int X,
int Y, TDragState State, bool &Accept)
{
Accept = Source->InheritsFrom(__classid(TWinControl)); // Autorise le drop si la source est un contrôle
} |
Partager