|
|
|
@ -4,6 +4,11 @@ |
|
|
|
|
#pragma hdrstop |
|
|
|
|
#include <FMX.Platform.Win.hpp> |
|
|
|
|
#include <ShellAPI.h> |
|
|
|
|
#include <cstdlib> |
|
|
|
|
#include <memory> |
|
|
|
|
#include <vector> |
|
|
|
|
#include <iostream> |
|
|
|
|
|
|
|
|
|
#include "Unit1.h" |
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
#pragma package(smart_init) |
|
|
|
@ -19,6 +24,8 @@ |
|
|
|
|
#error Not a supported platform |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
std::vector <AnsiString>filenames; |
|
|
|
|
|
|
|
|
|
TForm1 *Form1; |
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
@ -50,7 +57,12 @@ void __fastcall TForm1::msg_hnd(TWMDropFiles Msg) |
|
|
|
|
|
|
|
|
|
long m_OldWndProc; |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
const unsigned int count = DragQueryFile((HDROP)Message.Drop, -1, NULL, 0); |
|
|
|
|
for (unsigned int i = 0; i < count; ++i) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
LRESULT CALLBACK WndProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam) |
|
|
|
|
{ |
|
|
|
@ -63,18 +75,20 @@ LRESULT CALLBACK WndProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam) |
|
|
|
|
|
|
|
|
|
//ShowMessage("drop files fired and catched");
|
|
|
|
|
|
|
|
|
|
count=DragQueryFile((HDROP)wParam, 0xFFFFFFFF, NULL, 255); |
|
|
|
|
DragQueryFile((HDROP)wParam, 0, fname, 255); |
|
|
|
|
///ファイル処理(fname);
|
|
|
|
|
Form1->Memo1->Lines->Add(fname); |
|
|
|
|
if (count>1) { |
|
|
|
|
for(i=1;i<count;i++) { |
|
|
|
|
DragQueryFile((HDROP)wParam, i, fname, 255); |
|
|
|
|
//ファイル処理2(fname)
|
|
|
|
|
Form1->Memo1->Lines->Add(fname); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
DragFinish((HDROP)wParam); |
|
|
|
|
const unsigned int count = DragQueryFile((HDROP)wParam,-1,NULL,0); |
|
|
|
|
for( unsigned int i = 0 ; i < count ; ++i ){ |
|
|
|
|
const unsigned int length = DragQueryFile((HDROP)wParam, i, NULL, 0); |
|
|
|
|
std::unique_ptr<wchar_t[]> filename(new wchar_t[length + 1]); |
|
|
|
|
|
|
|
|
|
//ドロップされたファイルの名前を取得する
|
|
|
|
|
DragQueryFile((HDROP)wParam, i, filename.get(), length + 1); |
|
|
|
|
AnsiString temp; |
|
|
|
|
temp = filename.get(); |
|
|
|
|
//Form1->Memo1->Lines->Add(temp);
|
|
|
|
|
filenames.push_back(temp); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -102,3 +116,14 @@ void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action) |
|
|
|
|
SetWindowLongPtr(m_Hwnd,Parm,m_OldWndProc); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void __fastcall TForm1::Button1Click(TObject *Sender) |
|
|
|
|
{ |
|
|
|
|
// dump file names to Memo1
|
|
|
|
|
//using iterator
|
|
|
|
|
|
|
|
|
|
for( auto index = filenames.begin() ; index != filenames.end() ; index++ ) |
|
|
|
|
Memo1->Lines->Add(*index); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|