Old 17th August 2017, 10:52   #1
Kuppy
Junior Member
 
Join Date: Sep 2016
Posts: 34
Drag & Drop File

I have a question NSIS can use the drag and drop files {NSD_CreateText}?

PHP Code:
!define APPNAME "Drag & Drop"

NAME "${APPNAME}"
OutFile "${APPNAME}.exe"
InstallDir $temp

ShowInstDetails show
RequestExecutionLevel user

CompletedText 
"Drop files on me..."
DirText "You can drop a folder on the text field!"
SpaceTexts none

!include "MUI.nsh"
!include "WinCore.nsh"
!include "nsDialogs.nsh"
!include "LogicLib.nsh"
!include "WinMessages.nsh"

Page Custom "PageShow"
Page InstFiles

!insertmacro MUI_LANGUAGE 'English' 

var LabelText

Function "PageShow"
  
FindWindow $"#32770" "" $HWNDPARENT
  GetDlgItem 
$$1 0x3E9
  EnableWindow 
$0 0
  GetDlgItem 
$$1 0x3FB
  HandleFileDragDrop
::MakeDropWindow $""

  
nsDialogs::Create 1044
  Pop 
$0
  
${If} $== error
    Abort
  
${EndIf}

  ${
NSD_CreateText0010095"$\r$\n$\r$\n$\r$\n$\r$\nDrag & Drop$\r$\n$\r$\n$\r$\n$\r$\nYour file here"
  
Pop $LabelText
  
${NSD_Onchange$LabelText "InstPageDrop"

  
GetFunctionAddress $"InstPageDrop"
  
HandleFileDragDrop::MakeDropWindow $HWNDPARENT $0

  nsDialogs
::Show
FunctionEnd

Function "InstPageDrop"
  
DetailPrint Drop:$0
   SendMessage $LabelText 
${WM_SETTEXT'STR:$0'
  
StrCpy $""
FunctionEnd

Section

SectionEnd

Function .OnGuiEnd
  HandleFileDragDrop
::NOP
FunctionEnd 
Kuppy is offline   Reply With Quote
Old 22nd November 2018, 09:17   #2
T.Slappy
Major Dude
 
T.Slappy's Avatar
 
Join Date: Jan 2006
Location: Slovakia
Posts: 526
Send a message via ICQ to T.Slappy
I would like to try this plugin, but Unicode version.

@Anders: are sources available? Can you upload them to wiki?

Cool looking installer with custom design: www.graphical-installer.com
I offer NSIS scripting, C/C++/C#/Delphi programming: www.unsigned.sk
Develop NSIS projects in Visual Studio 2005-2019: www.visual-installer.com
or RAD Studio 2009, 2010, XE-10.3 Rio: www.rad-installer.com
T.Slappy is offline   Reply With Quote
Old 22nd November 2018, 10:37   #3
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,079
I might have it on a old machine but this is a very simple plug-in, it would be easy to write from scratch.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 23rd November 2018, 18:23   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,079
I uploaded a new version on the Wiki with slightly changed syntax

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 24th November 2018, 13:12   #5
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,079
...and to answer the original question; yes, you can detect drops on any control. The first parameter you pass to the plug-in in the handle of the window/control.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 24th November 2018, 23:47   #6
nickdollahz
Junior Member
 
Join Date: Apr 2018
Posts: 11
Is it possible for the values to be returned in Natural Order(Windows Sort Order)?
Not sure how trivial that would be. If not maybe a nsis function or plugin that can?
nickdollahz is offline   Reply With Quote
Old 25th November 2018, 00:46   #7
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,079
Why? And what is their natural order? The current sort mode in Explorer?

I believe they are returned in the order you select them, with the anchor first IIRC. Regardless, the plug-in just returns them in the order they are in the HDROP object.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 25th November 2018, 05:49   #8
nickdollahz
Junior Member
 
Join Date: Apr 2018
Posts: 11
The way Explorer sorts items by name:
1.txt
2.txt
10.txt

instead of
1.txt
10.txt
2.txt

Looks like it is returning in the order selected(which is natural order in my case). It just depends on the anchor you use as it will start with the anchor and return items from that point till the end then start from the beginning until that point. Which is actually how it works with most applications so I wont worry about it.

So if you have:
1.txt
2.txt
3.txt
4.txt
5.txt

and you highlight them all and then drag from 3.txt into the window. It will return:

3.txt
4.txt
5.txt
1.txt
2.txt


Thanks for your hard work. Unicode version has been clutch for the project I'm working on.
nickdollahz is offline   Reply With Quote
Old 25th November 2018, 12:13   #9
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,079
If you are putting them in a ListBox or ListView then it is probably possible to sort them like Explorer with the system plug-in. At least the ListView has a sort callback message, not sure about the ListBox...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump