Archive: An idea for a plugin...


An idea for a plugin...
  This would be a nice plugin...

dirpage::dirrequest "[start-in-folder]" "[dialog-name]"
Pop $0 ;selected dir
dirpage::filerequest "[start-in-folder]" "[dialog-name]" "[file-types]"
Pop $0 ;selected file

This would work just like the InstallOptions dirrequest/filerequest's.
The plugin could be used in sections and between pages...

I'm guessing the code could be taken from IO?

-Stu


Could somebody update system plugin at CVS, please (attached)? Small bug with structures fixed.

Open / Save file dialogs


     ; 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 "Text files (*.txt)", &t6 "*.TXT", &t16 "All files (*.*)", &t4 "*.*", &i1 0) i.r0'
; Prepare OpenFileName structure with other options
System::Call '*${stOPENFILENAME}(, $HWNDPARENT,, r0,,,,"",,"",, i 0, "Test open file dialog", 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
>
You can call GetSaveFileName instead of GetOpenFileName

openfilename structure:
; typedef struct tagOFN {
; DWORD lStructSize;
; HWND hwndOwner;
; HINSTANCE hInstance;
; LPCTSTR lpstrFilter;
; LPTSTR lpstrCustomFilter;
; DWORD nMaxCustFilter;
; DWORD nFilterIndex;
; LPTSTR lpstrFile;
; DWORD nMaxFile;
; LPTSTR lpstrFileTitle;
; DWORD nMaxFileTitle;
; LPCTSTR lpstrInitialDir;
; LPCTSTR lpstrTitle;
; DWORD Flags;
; WORD nFileOffset;
; WORD nFileExtension;
; LPCTSTR lpstrDefExt;
; LPARAM lCustData;
; LPOFNHOOKPROC lpfnHook;
; LPCTSTR lpTemplateName;
; } OPENFILENAME, *LPOPENFILENAME;

use your combinations of flags instead of 0xA01800:
; OFN_READONLY 0x00000001
; OFN_OVERWRITEPROMPT 0x00000002
; OFN_HIDEREADONLY 0x00000004
; OFN_NOCHANGEDIR 0x00000008
; OFN_SHOWHELP 0x00000010
; OFN_ENABLEHOOK 0x00000020
; OFN_ENABLETEMPLATE 0x00000040
; OFN_ENABLETEMPLATEHANDLE 0x00000080
; OFN_NOVALIDATE 0x00000100
; OFN_ALLOWMULTISELECT 0x00000200
; OFN_EXTENSIONDIFFERENT 0x00000400
; OFN_PATHMUSTEXIST 0x00000800
; OFN_FILEMUSTEXIST 0x00001000
; OFN_CREATEPROMPT 0x00002000
; OFN_SHAREAWARE 0x00004000
; OFN_NOREADONLYRETURN 0x00008000
; OFN_NOTESTFILECREATE 0x00010000
; OFN_NONETWORKBUTTON 0x00020000
; OFN_NOLONGNAMES 0x00040000 ; force no long names for 4.x modules
; OFN_EXPLORER 0x00080000 ; new look commdlg
; OFN_NODEREFERENCELINKS 0x00100000
; OFN_LONGNAMES 0x00200000 ; force long names for 3.x modules
; OFN_ENABLEINCLUDENOTIFY 0x00400000 ; send include message to callback
; OFN_ENABLESIZING 0x00800000
; OFN_DONTADDTORECENT 0x02000000
; OFN_FORCESHOWHIDDEN 0x10000000 ; Show All files including System and hidden files

Here the BrowseForFolder function:

BrowseForFolder

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

System::Store "p3 l"
>FunctionEnd
>
Example:

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

Thanks, would you be able to make them into proper function with exch, push and pop.
For example, you can exch the title of the dialog's, exch the different browse for items (into one string)

etc

I'd do it myself, but I'm not sure where the output comes from, what variables are used within the scripts, and where to start basically!

-Stu


brainsucker,

missing on your examples:

/NOUNLOAD on System::... plugin calls

or SetPluginUnload alwaysoff

cvs updates, thanks :up:

Ramon