Skip to content

Commit c94821a

Browse files
committed
drag and drop support
1 parent 33c29f4 commit c94821a

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

rtbinsrcfm.lfm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
object Form1: TForm1
2-
Left = 502
2+
Left = 467
33
Height = 560
4-
Top = 400
4+
Top = 370
55
Width = 858
6+
AllowDropFiles = True
67
BorderIcons = [biSystemMenu, biMinimize]
78
BorderStyle = bsDialog
89
Caption = 'Form1'
910
ClientHeight = 560
1011
ClientWidth = 858
1112
OnCreate = FormCreate
13+
OnDropFiles = FormDropFiles
1214
LCLVersion = '2.0.10.0'
1315
object InFile: TButton
1416
Left = 16

rtbinsrcfm.pas

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ interface
66

77
uses
88
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
9-
LazFileUtils, SpinEx,rtcodegen;
9+
LazFileUtils, Types, SpinEx,rtcodegen;
1010

1111
Const
12-
ProgramName = 'RtBinSrc v1.2 By RetroNick - Released May 19 - 2023';
12+
ProgramName = 'RtBinSrc v1.3 By RetroNick - Released May 22 - 2023';
1313

1414
type
1515

@@ -42,8 +42,10 @@ TForm1 = class(TForm)
4242
procedure CopyToClipboardClick(Sender: TObject);
4343
procedure FormatRadioGroupClick(Sender: TObject);
4444
procedure FormCreate(Sender: TObject);
45+
procedure FormDropFiles(Sender: TObject; const FileNames: array of String);
4546
procedure ImportClick(Sender: TObject);
4647
procedure InFileClick(Sender: TObject);
48+
procedure InFileDragDrop(Sender, Source: TObject; X, Y: Integer);
4749
procedure LanRadioGroupClick(Sender: TObject);
4850
procedure NumTypeRadioGroupClick(Sender: TObject);
4951
procedure SaveAsClick(Sender: TObject);
@@ -140,6 +142,34 @@ procedure TForm1.FormCreate(Sender: TObject);
140142
CGSetMemoProc(@FMemoAppend);
141143
end;
142144

145+
procedure TForm1.FormDropFiles(Sender: TObject; const FileNames: array of String
146+
);
147+
var
148+
MousePoint: TPoint;
149+
begin
150+
if High(Filenames) > 0 then
151+
begin
152+
ShowMessage('Drag only one file!');
153+
exit;
154+
end;
155+
156+
if FileExists(FileNames[0]) then
157+
begin
158+
OpenDialog.FileName:=FileNames[0];
159+
EditFileName.Caption:=FileNames[0];
160+
EditArrayName.Text:=LowerCase(ExtractFileName(ExtractFileNameWithoutExt(FileNames[0])));
161+
Import.Enabled:=True;
162+
end
163+
else
164+
begin
165+
ShowMessage('Invalid File/Directory!');
166+
exit;
167+
end;
168+
169+
MousePoint := ScreenToClient(Mouse.CursorPos);
170+
if NOT (PtInRect(InFile.BoundsRect, MousePoint) or PtInRect(EditFilename.BoundsRect, MousePoint)) then ImportClick(Self);
171+
end;
172+
143173
procedure TForm1.ImportClick(Sender: TObject);
144174
var
145175
error : word;
@@ -200,6 +230,13 @@ procedure TForm1.InFileClick(Sender: TObject);
200230
end;
201231
end;
202232

233+
procedure TForm1.InFileDragDrop(Sender, Source: TObject; X, Y: Integer);
234+
begin
235+
236+
end;
237+
238+
239+
203240
procedure TForm1.LanRadioGroupClick(Sender: TObject);
204241
begin
205242
if Processing then exit;

0 commit comments

Comments
 (0)