thek
15th June 2007 12:51 UTC
disable MUI_PAGE_DIRECTORY Directory field
Hello Guys
Is it possible to set in the MUI_PAGE_DIRECTORY the destination folder field to readonly and disabling the browse button? All this during runtime.
The reason for this:
I have an installer which only works if you are an admin...
so far so good...
now I'd like to allow a non admin user to update the software meaning:
If the software is already installed
he is allowed to update/replace the executables + config files
but he is not allowd to change the installationpath and so on...
Afrow UK
15th June 2007 13:01 UTC
!include WinMessages.nsh
!define MUI_PAGE_CUSTOMFUNCTION_SHOW DirectoryPageShow
!insertmacro MUI_PAGE_DIRECTORY
Function DirectoryPageShow
StrCmp ... SkipDisable
FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $R1 $R0 1019
SendMessage $R1 ${EM_SETREADONLY} 1 0
GetDlgItem $R1 $R0 1001
EnableWindow $R1 0
SkipDisable:
FunctionEnd
Not tested but should work.
Stu
thek
18th June 2007 11:35 UTC
thanks for the help
exactly what needed
highlader
30th August 2007 19:42 UTC
Hey there I just started learning NSIS yesterday and I need to do exactly what the topics says, but I dunno where and how, Could u please gimme a more detailed explanation about this.
thek
31st August 2007 08:35 UTC
To make a field readonly you have to tell the edit box that it is "readonly" no
In "Windows you do this by sending a Message to the edit box (in Windows everything is a Windows, even a button and so on)
and this does the code above
FindWindow $R0 "#32770" "" $HWNDPARENT
gets the ID of the dialog which contains the edit box
GetDlgItem $R1 $R0 1019
gets the id of the edit box in this dialog
SendMessage $R1 ${EM_SETREADONLY} 1 0
sends the message "Readonly" to the editbox
after this the editbox is "readonly"
GetDlgItem $R1 $R0 1001
gets the id of the Browse Button in this dialog
EnableWindow $R1 0
A Button cannot be set "readonly" so you have to disable it completly (you can do this with the edit box to)
but this is some homework for you to find out whats the difference between setting readonly and disable an edit box ;-)
hope it helps
nobs
pozbremser
31st August 2007 09:05 UTC
where can I find the Id's of components (pages, buttons,editboxes a.s.o.)?
thek
31st August 2007 09:25 UTC
try and error :(
sorry but as far as I know there is no other way
it sound's more diffecult than it is
the numbers are all over 1000
often you can get it via the code... (e.g. UMUI.nsh)
or by trying around a little bit (there a not so many items on a dialog
Wizou
31st August 2007 12:53 UTC
open the appropriate UI stub (C:\Program Files\NSIS\Contrib\UIs) with a resource editor (Visual Studio, ResHacker, etc...)
and find the ID in the page (dialog) you're interested in
pozbremser
31st August 2007 14:54 UTC
ok, thanks!
I use directory page now.
if I detect some components installed, I disable the directory change.
But it is possible to change directory!
If You press any key on keybord for example.
sie Attachment please.
Can I disable this?
thanks.
Wizou
31st August 2007 15:24 UTC
try this
FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $R1 $R0 1019
SendMessage $R1 ${EM_SETREADONLY} 1 0
EnableWindow $R1 0
GetDlgItem $R1 $R0 1001
EnableWindow $R1 0
pozbremser
3rd September 2007 09:52 UTC
exact! thanks!