Archive: disable MUI_PAGE_DIRECTORY Directory field


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...


!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

thanks for the help

exactly what needed


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.


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

where can I find the Id's of components (pages, buttons,editboxes a.s.o.)?


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


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


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.


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

exact! thanks!