//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ListBox1Click(TObject *Sender)
{
Memo1->Lines->LoadFromFile(ListBox1->Items->Strings[ListBox1->ItemIndex]);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
DragAcceptFiles(Memo1->Handle, True);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
DragAcceptFiles(Memo1->Handle, False);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ApplicationEvents1Message(tagMSG &Msg, bool &Handled)
{
if(Msg.message == WM_DROPFILES)
{
ListBox1->Items->Clear();
Memo1->Lines->Clear();
int fileCount = DragQueryFile((HANDLE)Msg.wParam, 0xFFFFFFFF, NULL, 0);
if(fileCount == 1)
{
wchar_t *wFileName;
int iFLength = DragQueryFile((HANDLE)Msg.wParam, 0, NULL, 0) + 1;
wFileName = new wchar_t[iFLength];
DragQueryFile((HANDLE)Msg.wParam, 0, wFileName, iFLength);
ListBox1->Items->Add(wFileName);
Memo1->Lines->LoadFromFile(wFileName);
delete wFileName;
}
else
{
for(int c = 0; c < fileCount; c++)
{
wchar_t * wFileName;
int iFLength = DragQueryFile((HANDLE)Msg.wParam, c, NULL, 0) + 1;
wFileName = new wchar_t[iFLength];
DragQueryFile((HANDLE)Msg.wParam, c, wFileName, iFLength);
ListBox1->Items->Add(wFileName);
delete wFileName;
}
}
}
}
//---------------------------------------------------------------------------