|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
#include <fmx.h>
|
|
|
|
|
#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)
|
|
|
|
|
#pragma resource "*.fmx"
|
|
|
|
|
|
|
|
|
|
#if _WIN64
|
|
|
|
|
#define Parm GWLP_WNDPROC
|
|
|
|
|
#elif _WIN32
|
|
|
|
|
#define Parm GWL_WNDPROC
|
|
|
|
|
#elif __APPLE__
|
|
|
|
|
// macOS
|
|
|
|
|
#else
|
|
|
|
|
#error Not a supported platform
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
std::vector <AnsiString>filenames;
|
|
|
|
|
|
|
|
|
|
TForm1 *Form1;
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
void __fastcall TForm1::msg_hnd(TWMDropFiles Msg)
|
|
|
|
|
{
|
|
|
|
|
int count;
|
|
|
|
|
int i;
|
|
|
|
|
char fname[256];
|
|
|
|
|
|
|
|
|
|
count=DragQueryFile((HDROP)Msg.Drop, 0xFFFFFFFF, NULL, 255);
|
|
|
|
|
DragQueryFile((HDROP)Msg.Drop, 0, fname, 255);
|
|
|
|
|
///<EFBFBD>t<EFBFBD>@<EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(fname);
|
|
|
|
|
Memo1->Lines->Add(fname);
|
|
|
|
|
if (count>1) {
|
|
|
|
|
for(i=1;i<count;i++) {
|
|
|
|
|
DragQueryFile((HDROP)Msg.Drop, i, fname, 255);
|
|
|
|
|
//<EFBFBD>t<EFBFBD>@<EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2(fname)
|
|
|
|
|
Memo1->Lines->Add(fname);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
DragFinish((HDROP)Msg.Drop); // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>J<EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
HWND m_Hwnd;
|
|
|
|
|
|
|
|
|
|
WNDPROC m_WndOldProc;
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
int count;
|
|
|
|
|
int i;
|
|
|
|
|
char fname[256];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(Msg == WM_DROPFILES){
|
|
|
|
|
|
|
|
|
|
//ShowMessage("drop files fired and catched");
|
|
|
|
|
|
|
|
|
|
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]);
|
|
|
|
|
|
|
|
|
|
//<EFBFBD>h<EFBFBD><EFBFBD><EFBFBD>b<EFBFBD>v<EFBFBD><EFBFBD><EFBFBD>ꂽ<EFBFBD>t<EFBFBD>@<EFBFBD>C<EFBFBD><EFBFBD><EFBFBD>̖<EFBFBD><EFBFBD>O<EFBFBD><EFBFBD><EFBFBD>擾<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
DragQueryFile((HDROP)wParam, i, filename.get(), length + 1);
|
|
|
|
|
AnsiString temp;
|
|
|
|
|
temp = filename.get();
|
|
|
|
|
//Form1->Memo1->Lines->Add(temp);
|
|
|
|
|
filenames.push_back(temp);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return CallWindowProc(m_WndOldProc,hWnd,Msg,wParam,lParam);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
__fastcall TForm1::TForm1(TComponent* Owner)
|
|
|
|
|
: TForm(Owner)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_Hwnd = Fmx::Platform::Win::FormToHWND(Form1);
|
|
|
|
|
DragAcceptFiles(m_Hwnd,true);
|
|
|
|
|
|
|
|
|
|
m_OldWndProc = GetWindowLongPtr(m_Hwnd, Parm);
|
|
|
|
|
m_WndOldProc = (WNDPROC)SetWindowLongPtr(m_Hwnd, Parm,(LONG)WndProc);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|