Archive: How disable directory field on MUI_PAGE_DIRECTORY?


How disable directory field on MUI_PAGE_DIRECTORY?
  I'm using MUI

How disable directory field on MUI_PAGE_DIRECTORY?

Thank you


if i understand you correctly, this makes no sense at all. either leave the directory page or use it as is.


This has been asked before. Use EnableWindow in the show function.


What item_id of directory field?

Next code not work:

!define MUI_PAGE_CUSTOMFUNCTION_SHOW MyFuncDir
!insertmacro MUI_PAGE_DIRECTORY

Function MyFuncDir
FindWindow $hwnd "#32770" "" $HWNDPARENT
GetDlgItem ${TEMP} $hwnd 1202
EnableWindow ${TEMP} 0
FunctionEnd

Thank you


1019


Thank you very much !!!

Where I can find all item_id?

Thank you


See resource.h or use a resource hacker to view the dialogs in the Contrib\UIs folder.


Thank you Joost Verburg

All works perfectly


hello, I'm trying to do it to...

I do not completely understand what to do, and this code does not work...

can you mr anonym please give the complete code working ?


!define MUI_PAGE_CUSTOMFUNCTION_SHOW MyFuncDir
!insertmacro MUI_PAGE_DIRECTORY

Function MyFuncDir
FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $R1 $R0 1019
EnableWindow $R1 0
FunctionEnd
-Stu

thx very much...

this deactivates the field, but, not the "browse" button --> I still can change the $INSTDIR

have you got the value of the "browse" button --> though I can really disable the choice ?
(I think with just this value I could now do it :p )




why doing this and not skipping this page ?
--> because of the "proceed" button... (uninstall or reinstall or install)
this page is juste before the instfiles page, so I have to show that you're going to install or uninstall (and not only display a next page)


---> because of the reinstallation :
you reinstall and I show where is your software, (I don't want them ta change the INSTDIR if they reinstall)


where can I find this value ?

what is resource.h ?


up :D

i'me certainly annoying, but this is the last thing missing to me to finish my installer...

the question is :




how to disable the "browse" button in the MUI directory page ???


try this and then drag the finder over the browse button and look for the 'Control ID' once the window details have been found.

-daz


well I'vbe done what you aksed me to do...

I have a control ID :
000003E9

and now ? :p
because the control ID of the install dir text is
000003FB
and this is not the value I entered to disable it...


year 3FB in hex = 1019 in decimal !

super...

3E9 = 1001

I'm gonna try 1001 !


this is the perfect code to disable directory page :


!define MUI_PAGE_CUSTOMFUNCTION_SHOW MyFuncDir
!insertmacro MUI_PAGE_DIRECTORY
...

Function MyFuncDir
FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $R1 $R0 1019
EnableWindow $R1 0
FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $R1 $R0 1001
EnableWindow $R1 0
FunctionEnd



thx to everybody !

heh, forgot to say it's all in hexadecimal. glad it's working now :)

-daz


Ok, I know this is a bit off topic, but I just have to ask:

A MUI DIRECTORY page basiclaly just has 2 options: a text field for a description and a place to enter a path. There are no other options a user can click on, etc. that will make the select direcotry part become usable. Which leads to ask why even bother displaying the page in the first place?

I'm sure you have your reasons; I'm just being curious...


1) if you have already installed
if you lanch the installer (and the uninstaller too for me)
they can propose you to reinstall, and if you want to reinstall
you choose your components (add, remove)
you go now to the directory page


and with a disabled directory page you can announce where the software will be reinstalled-modified


for a difficulty reason, and too because it's not logical, I don't want them to change the install dir
---> disabling directory page


2) the directory page button is the install button...
So if you skip it, no more "install button"... just next buttons...
and it's more "clear" to disable the fields of the directory page than to change the buttons of another page



these are my reasons ;)


ps : I'll come back and give all my script file when the software will be released... 10th february 2005



Function MyFuncDir
FindWindow $hwnd "#32770" "" $HWNDPARENT
nice truck with winspy.

but how do you find de window(here 32770) or 8002hex ?

#32770 is a standard classname for all dialog windows created by windows. if you do the same over a messagebox you should see the classname is the same. but basically it's just how the OS is designed

-daz


i tried the code given by superwan

i still cant disable the browse button and the install location field.
pls help me out


FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $R1 $R0 1019
EnableWindow $R1 0


Hello there, I recently posted This Thread and now I see, the page can be disabled, but how can I disable it dinamically? I mean, if installRegKey returns that there is a previous installation, then disable the controls, but if it's a fresh installation let the user choose.

Thanks!

Cërf.


Why not simply skip the directory page if it's not needed? If you really want to disable it, add an if block around the above code:

!include LogicLib.nsh
#...
${If} $INSTDIR != ""
# disable
${EndIf}

If you're using the $hwnd var, you need to declare it first:

Var hwnd
That could be the source of your problems.

-dandaman32

Thanks Hichik!
You're right, now my problem is that I can't seem to find out (and this is embarrasing) how to assign $INSTDIR a default value, when it's a fresh installation.

Thanks again, Cërf.


!include LogicLib.nsh

>#...
>${If} $INSTDIR != ""
# disable controls here
StrCpy $INSTDIR "c:\some\default\folder"
>${EndIf}
--

additional note: you don't have to convert from hex to dec. If WinSpy gives you e.g. the value 403, simply use 0x403 in your NSIS script instead of 1027.

Thanks Animaether!


wish I knew how to get backslashes into a PHP quote ;)


You can't, that's why most people use [ code ][ /code ]
Like this:


|\_/|


Cërf.

The only thing is that there is no syntax coloring : (


hence why I'm using the PHP tag ;)

Must be some way - 'll have to dig around the help a bit :)

Edit: okay, no there isn't :D
silly stripslashes() to remove color-coding-induced backslashes that eats regular backslashes :x


I use this useful code :
!define InstallDirRegKey '"HKLM" "Software\${PRODUCT_PUBLISHER}\${CLIENT_NAME}\${PRODUCT_NAME}" "InstallPath"'
InstallDirRegKey ${InstallDirRegKey}

!define MUI_PAGE_CUSTOMFUNCTION_PRE DirectoryPre
!define MUI_PAGE_CUSTOMFUNCTION_SHOW DirectoryPre
!insertmacro MUI_PAGE_DIRECTORY

Function DirectoryPre
ReadRegStr $R0 ${InstallDirRegKey}
StrCmp $R0 "" FullDirectoryPage PartialDirectoryPage

PartialDirectoryPage:
FindWindow $R1 "#32770" "" $HWNDPARENT
GetDlgItem $R2 $R1 1019
EnableWindow $R2 0
GetDlgItem $R2 $R1 1001
EnableWindow $R2 0

FullDirectoryPage:
FunctionEnd
-----------------------------------------------------------
First install must write in registry 'InstallPath'.
If this 'InstallPath' exist, directory field and 'Browse' button are disabled on MUI_PAGE_DIRECTORY

Regards
From Paris,
Yves


Hi,

I ve been searching and reading forum for hours without any clue why i can't get it works.

I'd like to change the Text button of the Components Page "Next >" by "Install >"

I tried so many different things i m now a little bit messed up.

#...


# Variables
>Var hwnd
>#...

>!define MUI_PAGE_CUSTOMFUNCTION_SHOW ComponentsShow
>!insertmacro MUI_PAGE_COMPONENTS
>#!define MUI_PAGE_CUSTOMFUNCTION_SHOW ComponentsShow
# Before or after !insertmacro changes nothing
#...

>Function ComponentsShow
# CHECK IF SERVER INSTALLED YET TO INSTALL SERVICE/FILES
#MessageBox MB_OK "$(^Name) : $isInstalled$\nText : $(TEXT_INSTALL)"
StrCmp $isInstalled "1" 0 +7
FindWindow $hwnd"#32770" "" $HWNDPARENT
Push $R0
GetDlgItem $R0 $hwnd 1
#MessageBox MB_OK "$(^Name) : $R0$\nHWND : $hwnd"
SendMessage $R0 ${WM_SETTEXT} 0 "STR:$(TEXT_INSTALL)"
Pop $R0

FunctionEnd

>#...

>LangString TEXT_INSTALL ${LANG_FRENCH} "&Installer >"
>LangString TEXT_INSTALL ${LANG_ENGLISH} "&Install >"
On the Components page, the next button still displays "Suivant >"
C:\NSIS\makensis.exe /VERSION
2.17

Thanks in advance.

The button is not a child of the sub-dialog, it is located on the main dialog. You can get the handle with

GetDlgItem $R0 $HWNDPARENT 1

But NSIS will change the button text according to whether there are other pages before the INSTFILES page. You would only need to change the text if the page(s) before INSTFILES are going to be hidden with abort.

Don

Thx Don,

sorry but i don't understand the explanation (i m not english native speaker).
I tried first 'GetDlgItem $R0 $HWNDPARENT 1' without FindWindow but with same result (maybe i should retry because i ve done some other changes after).

i think i forget to say in previous post that i had a mui_page_directory i could also skip. I m gonna try to put the code in the pre function of diretory page (i lack time for the moment and a build is about 15 mn)


# Installer pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE cluf.rtf
!insertmacro MUI_PAGE_COMPONENTS
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ComponentsShow
!define MUI_PAGE_CUSTOMFUNCTION_PRE DirectoryPre
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

...

Function ComponentsShow
# CHECK IF SERVER INSTALLED YET TO INSTALL SERVICE/FILES
;MessageBox MB_OK "$(^Name) : $isInstalled$\nText : $(TEXT_INSTALL)"
StrCmp $isInstalled "1" 0 +7
FindWindow $hwnd "#32770" "" $HWNDPARENT
Push $R0
GetDlgItem $R0 $hwnd 1
;MessageBox MB_OK "$(^Name) : $R0$\nHWND : $hwnd"
SendMessage $R0 ${WM_SETTEXT} 0 "STR:$(TEXT_INSTALL)"
Pop $R0

FunctionEnd

Function DirectoryPre
# CHECK IF SERVER INSTALLED YET TO INSTALL SERVICE/FILES
StrCmp $isInstalled "1" 0 +1
Abort # Skip page
FunctionEnd


If application is already installed i show the commonents page but next i don't want to show de directory page (that seems to work as expected).

Thx Anyway...