Old 26th July 2003, 11:16   #1
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Script not working...

code:

; OpenFileName defenition
!define stOPENFILENAME '(&l4, i, i 0, i, i 0, i 0, i 0, t, i \
${NSIS_MAX_STRLEN}, t, i ${NSIS_MAX_STRLEN}, t, t, i, \
&i2, &i2, t, i 0, i 0, i 0) i'

; Prepare filter sting
System::Call '*(&t19 "Zip files", &t6 "*.zip", &t16 \
"Zip files", &t4 "*.zip", &i1 0) i.r0'
; Prepare OpenFileName structure with other options
System::Call '*${stOPENFILENAME}(, $HWNDPARENT,, r0,,,,"",,"",, \
i 0, "Select zip file to install", 0xA01800,,,,,,) .r1'

; OpenFileName Dialog
System::Call 'comdlg32::GetOpenFileNameA(i r1) i .r2'
; You could check r2 for zero value - this will indicate
; the user pressed the cancel button

; Retrieve selected file path
System::Call '*$1${stOPENFILENAME}(,,,,,,,.r3)'
; just a demo
MessageBox MB_OK 'Result $2, Filename "$3"'

; Free used memory
System::Free $1
System::Free $0



This is a script that brainsucker made for me, but it isn't working quite right.
The "*.zip" bit that is meant to show only zip files is not working - *.* show instead.

Can anyone fix this for me?

Thanks

-Stu
Afrow UK is offline   Reply With Quote
Old 27th July 2003, 15:21   #2
pengyou
Major Dude
 
Join Date: Mar 2003
Posts: 571
Have you considered using InstallOptions2 with a FileRequest control using a filter to restrict the FileOpen window to only showing Zip files ("Filter=ZIP Files|*.zip") ?
pengyou is offline   Reply With Quote
Old 27th July 2003, 16:25   #3
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
The whole perpose of this script is to open the dialog in a Section.

-Stu
Afrow UK is offline   Reply With Quote
Old 27th July 2003, 16:41   #4
pengyou
Major Dude
 
Join Date: Mar 2003
Posts: 571
Sorry my answer was of no use to you: your original message did not mention how the script fragment was being used.
pengyou is offline   Reply With Quote
Old 2nd August 2003, 09:33   #5
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Try replacing:

System::Call '*(&t19 "Zip files", &t6 "*.zip", &t16 "Zip files", &t4 "*.zip", &i1 0) i.r0'


with:

System::Call '*(&t10 "Zip files", &t6 "*.zip", &t10 "Zip files", &t6 "*.zip", &i1 0) i.r0'

Notice that I have changed the number after every &t to match the number of the characters in the string + 1.

If that doesn't work try removing the second pair of "Zip files", "*.zip". Maybe Windows doesn't like it when you specify the same thing twice.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 2nd August 2003, 11:06   #6
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
I put it in twice because the first pair didn't do anything (original script).

I will check this new one out, thanks.

-Stu
Afrow UK is offline   Reply With Quote
Old 14th August 2003, 10:19   #7
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
I have made a function out of this, which can be found here:
http://nsis.sourceforge.net/archive/...ances=0,11,211

I have allowed users to Push different Flags for use, but I'm not sure what the different flags need to be seperated with.

Anyone know?

Thanks

-Stu
Afrow UK is offline   Reply With Quote
Old 14th August 2003, 10:36   #8
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Now, here is the DirRequest function by brainsucker:
code:

Function DirRequest
System::Store "s r8r9"

; Get callback
System::Get '(i.s, i.s, i.s, i.s) i ss'
pop $0

; BrowseInfo structure
System::Call '*(i $HWNDPARENT, i 0, t "", t r9, i 0x45, k r0, i, i) i.r1'
System::Call 'shell32::SHBrowseForFolderA(i r1) i.s'
ShBrowse:
Pop $2
StrCmp $2 "callback1" 0 ExitBrowse

System::Store "s r3r4r5r6"
; BFMM_INITIALIZED ?
IntCmp $4 1 0 exit exit
; yes, set the starting dir
System::Call 'user32::SendMessageA(i $3, i 1126, i 1, t r8) i'
System::Store "r2r3r4r5r6"
System::Call "$0" 0
exit:
; Restore
System::Store "l"
System::Call "$0" 0
Goto ShBrowse

ExitBrowse:
; free used resources
System::Free $0
System::Free $1

; now we should determine folder name from given PIDL
System::Call 'shell32::SHGetPathFromIDListA(i $2, t "" r3)'

; IMalloc->Free work
; Get the pointer to interface
System::Call 'shell32::SHGetMalloc(*i . r4)'
; Get the pointer to interface VTABLE
System::Call '*$4(i.r7)'
; Get the pointer to IMalloc->Free
System::Call '*$7(&t20, i.r5)'
; Call Free method
System::Call '::$5(i r2)'

System::Store "p3 l"
FunctionEnd



The line...
System::Call 'shell32::SHBrowseForFolderA(i r1) i.s'
...crashes the installer everytime.

-Stu
Afrow UK is offline   Reply With Quote
Old 3rd September 2003, 12:20   #9
brainsucker
Senior Member
 
brainsucker's Avatar
 
Join Date: Sep 2002
Location: Minsk, Belarus
Posts: 190
Send a message via ICQ to brainsucker
Afrow UK: have you solved you problem with dirrequest?
updated versions included. BrowseForFolderNew - no startup folder.
Source - attached. You'll probably need updated exehead to use them.
Use:

push "Select folder Demo"
push "d:\Program files" ; startup folder
call BrowseForFolder
pop $0
MessageBox MB_OK "Selected folder '$0'"

push "Select folder Demo small"
call BrowseForFolderNew
pop $0
MessageBox MB_OK "Selected folder '$0'"
Attached Files
File Type: txt browseforfolder.txt (2.0 KB, 221 views)
brainsucker is offline   Reply With Quote
Old 3rd September 2003, 15:26   #10
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
The new script also crashes; after clicking OK after selecting the folder.
This happens on my Windows XP system, not sure about Windows 98 (not able to test).

-Stu
Afrow UK is offline   Reply With Quote
Old 3rd September 2003, 15:28   #11
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Ok, I'll need latest CVS first...

Thanks

-Stu
Afrow UK is offline   Reply With Quote
Old 3rd September 2003, 23:00   #12
brainsucker
Senior Member
 
brainsucker's Avatar
 
Join Date: Sep 2002
Location: Minsk, Belarus
Posts: 190
Send a message via ICQ to brainsucker
Sorry Afrow. I don't think the latest CVS will help. No one of NSIS developers updated NSIS exehead code yet (as I know). If it will became critical for you I can send you updated makensis compiled from latest CVS and my changes.
brainsucker is offline   Reply With Quote
Old 24th November 2006, 21:19   #13
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
One heck of an old thread - perhaps FileRequest doesn't work under XP? Not sure.

Basically I was hoping to make use of this function to pop up a file browsing dialog that would show hidden files/folders. (DialogsEx doesn't support it - d'oh) But even the sample code in the WiKi seems to do zilch and returns a null value.

I get the following values for the usual variables just before the function starts popping the originals:
code:

$0 = <null>
$1 = 1430240
$2 = error
$3 = <null>
$4 = (&l4, i, i 0, i, i 0, i 0, i 0, t, i 1024, t, i 1024, t, t, i, &i2, &i2, t, i 0, i 0, i 0) i
$5 = Zip Files (*.zip)
$6 = *.zip
$7 = All Files (*.*)
$8 = *.*
$9 = Select Zip file to install

$R0 = 18
$R1 = 6
$R2 = 16
$R3 = 4
$R4 = open
$R5 = 0xA01800
$R6 = <null>
$R7 = <null>
$R8 = <null>
$R9 = <null>



Any clues or "oops - silly us, change 'this' to 'that'" would be appreciated.
Animaether is offline   Reply With Quote
Old 24th November 2006, 21:31   #14
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
nevermind - the first thing I tried was getting rid of the $R4 in the call to comdlg32 and, out of habit more than anything, spelled it "GetOpenFileName". Immediately, things worked.

Then I thought "well why wouldn't that $R4 insert?" before I realized that it did. Except it inserted "open" and thus the call was "GetopenFileName".

Oops? :P

I'll adjust the wiki in a moment.
Animaether is offline   Reply With Quote
Old 24th November 2006, 21:37   #15
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
Only to hit the next problem - it's not showing me the hidden files/folders.

I tried passing...
code:

Push "0xA01800,0x10000000"


and
code:

Push "0x10000000"



Neither worked. Am I missing something else?

Edit:

I also tried the flag "0x00000200" for multi-select, and it fails to work if passed as:
code:

Push "0xA01800,0x00000200"



but works when using:

code:

Push "0x00000200"



So double-checked with the hidden files one - but still no luck.
Animaether is offline   Reply With Quote
Old 25th November 2006, 13:27   #16
demiller9
Senior Member
 
Join Date: Mar 2006
Location: Dallas
Posts: 462
I believe that the flags should be OR'ed together, not listed with commas between them: 0x10A01800. (And for multiselect, 0xA01A00). My commdlg.h file (From Visual C++, 6.0) doesn't show a flag for hidden files, are you sure the 0x10000000 is correct?

When I open a dialog for files with my editor (Crimson Editor) or with Firefox, it automatically includes hidden files. I can see 'thumbs.db' which has 'HSA' attributes. Did you try changing the dialog view type to 'detail' and adding the attribute column to the view? (right click on the detail view column header and select the columns you want).

Don
demiller9 is offline   Reply With Quote
Old 26th November 2006, 02:55   #17
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
Quote:
Originally posted by demiller9
I believe that the flags should be OR'ed together, not listed with commas between them: 0x10A01800.
I had tried that as well, to no avail.

Quote:
Originally posted by demiller9 My commdlg.h file (From Visual C++, 6.0) doesn't show a flag for hidden files, are you sure the 0x10000000 is correct?[/B]
As sure as I can be.. The flags are listed in the WiKi page on this. A quick Google search I had done at the time just in case that hex code was incorrect seemed to confirm it should be fine (MSDN lists it at... http://msdn2.microsoft.com/en-us/library/ms646839.aspx )

Quote:
Originally posted by demiller9
When I open a dialog for files with my editor (Crimson Editor) or with Firefox, it automatically includes hidden files.
Are you sure that is not because you have explorer set to show hidden folders/files by default?
FireFox 1.5 isn't showing me the hidden file either. Perhaps its location is important..
c:\documents and settings\myUsername\My Documents\somefile.jpg

somefile.jpg as the attributes: archive, hidden

Quote:
Originally posted by demiller9
Did you try changing the dialog view type to 'detail' and adding the attribute column to the view?
Yeah, that does nothing either. That just changes how things are displayed, not what files are displayed, I'm afraid.
Animaether 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