Skip to content

Commit

Permalink
drag and drop support
Browse files Browse the repository at this point in the history
  • Loading branch information
RetroNick2020 committed May 22, 2023
1 parent 33c29f4 commit c94821a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
6 changes: 4 additions & 2 deletions rtbinsrcfm.lfm
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
object Form1: TForm1
Left = 502
Left = 467
Height = 560
Top = 400
Top = 370
Width = 858
AllowDropFiles = True
BorderIcons = [biSystemMenu, biMinimize]
BorderStyle = bsDialog
Caption = 'Form1'
ClientHeight = 560
ClientWidth = 858
OnCreate = FormCreate
OnDropFiles = FormDropFiles
LCLVersion = '2.0.10.0'
object InFile: TButton
Left = 16
Expand Down
41 changes: 39 additions & 2 deletions rtbinsrcfm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ interface

uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
LazFileUtils, SpinEx,rtcodegen;
LazFileUtils, Types, SpinEx,rtcodegen;

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

type

Expand Down Expand Up @@ -42,8 +42,10 @@ TForm1 = class(TForm)
procedure CopyToClipboardClick(Sender: TObject);
procedure FormatRadioGroupClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDropFiles(Sender: TObject; const FileNames: array of String);
procedure ImportClick(Sender: TObject);
procedure InFileClick(Sender: TObject);
procedure InFileDragDrop(Sender, Source: TObject; X, Y: Integer);
procedure LanRadioGroupClick(Sender: TObject);
procedure NumTypeRadioGroupClick(Sender: TObject);
procedure SaveAsClick(Sender: TObject);
Expand Down Expand Up @@ -140,6 +142,34 @@ procedure TForm1.FormCreate(Sender: TObject);
CGSetMemoProc(@FMemoAppend);
end;

procedure TForm1.FormDropFiles(Sender: TObject; const FileNames: array of String
);
var
MousePoint: TPoint;
begin
if High(Filenames) > 0 then
begin
ShowMessage('Drag only one file!');
exit;
end;

if FileExists(FileNames[0]) then
begin
OpenDialog.FileName:=FileNames[0];
EditFileName.Caption:=FileNames[0];
EditArrayName.Text:=LowerCase(ExtractFileName(ExtractFileNameWithoutExt(FileNames[0])));
Import.Enabled:=True;
end
else
begin
ShowMessage('Invalid File/Directory!');
exit;
end;

MousePoint := ScreenToClient(Mouse.CursorPos);
if NOT (PtInRect(InFile.BoundsRect, MousePoint) or PtInRect(EditFilename.BoundsRect, MousePoint)) then ImportClick(Self);
end;

procedure TForm1.ImportClick(Sender: TObject);
var
error : word;
Expand Down Expand Up @@ -200,6 +230,13 @@ procedure TForm1.InFileClick(Sender: TObject);
end;
end;

procedure TForm1.InFileDragDrop(Sender, Source: TObject; X, Y: Integer);
begin

end;



procedure TForm1.LanRadioGroupClick(Sender: TObject);
begin
if Processing then exit;
Expand Down

0 comments on commit c94821a

Please sign in to comment.