Вопрос Функция drag'n'drop в inno setup - (Решено)

Хамик

Старожил
Как реализовать drag'n'drop в inno setup? В частности интересует как при перетаскивании на объект TEdit получить путь к файлу.
 
Последнее редактирование:

DiCaPrIo

Новичок
code_language.pascal:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "My Program"
#define MyAppVersion "1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "MyProg.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{7EB8829F-28CE-4F66-A82D-A37267A0D495}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes

[code] 
procedure DragAcceptFiles(Wnd: HWND; fAccept: BOOL);external 'DragAcceptFiles@shell32.dll stdcall';
function DragQueryFile(hDrop: THandle; iFile: UINT; lpszFile: String; cch: UINT): UINT; external 'DragQueryFileW@shell32.dll stdcall';
function ChangeWindowMessageFilter(msg: UINT; dwFlag: DWORD): BOOL; external 'ChangeWindowMessageFilter@user32.dll stdcall';
procedure DragFinish(hDrop: THandle);external 'DragFinish@shell32.dll stdcall';

procedure DirEdtProc(var Msg: TMsg; var Handled: Boolean);
var
Len:Integer;
S:String;
begin
if Msg.hwnd=WizardForm.DirEdit.Handle then
if msg.message =  $0233 then  begin
Len := DragQueryFile(Msg.wParam, 0, '', 0);
SetLength(S,Len)
DragQueryFile(Msg.wParam, 0, S, Len);
S:=Trim(S);
WizardForm.DirEdit.Text:=ExtractFileDir(S);
DragFinish(Msg.wParam)
end;
end;

procedure InitializeWizard(); var buffer: array [0 .. 255] of Char;
begin
{Register DragDrop}
ChangeWindowMessageFilter($0233,1)
ChangeWindowMessageFilter($0049, 1);
DragAcceptFiles(WizardForm.DirEdit.Handle,True);
{==============}
Application.OnMessage:=  @DirEdtProc;
end;
 
Сверху