You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
2.1 KiB
104 lines
2.1 KiB
//--------------------------------------------------------------------------- |
|
|
|
#include <fmx.h> |
|
#pragma hdrstop |
|
#include <FMX.Platform.Win.hpp> |
|
#include <ShellAPI.h> |
|
#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 |
|
|
|
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); |
|
///ファイル処理(fname); |
|
Memo1->Lines->Add(fname); |
|
if (count>1) { |
|
for(i=1;i<count;i++) { |
|
DragQueryFile((HDROP)Msg.Drop, i, fname, 255); |
|
//ファイル処理2(fname) |
|
Memo1->Lines->Add(fname); |
|
} |
|
} |
|
DragFinish((HDROP)Msg.Drop); // メモリ開放 |
|
} |
|
*/ |
|
|
|
HWND m_Hwnd; |
|
|
|
WNDPROC m_WndOldProc; |
|
|
|
long m_OldWndProc; |
|
|
|
|
|
|
|
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"); |
|
|
|
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); |
|
|
|
} |
|
|
|
|
|
|
|
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); |
|
} |
|
|
|
|