Old 10th May 2006, 16:46   #1
shaunb
Member
 
Join Date: May 2006
Location: Devon, UK
Posts: 65
Changing DirRequest control properties

Hi, noob alert.

I am using NSIS to create an installer for our product, I must say first a big thanks to anyone involved in the development of NSIS, or people who help out here.

Basically my query is relating to a custom page I have created, which in all essence looks near identical to the MUI_PAGE_DIRECTORY macro, although I have built a custom dialog using the DirRequest control, asking the user 'where a directory is' (not a normal install directory), anyway, its near enough finished but this question is merely about cosmetics really,

is it possible to change the "..." Caption on the button in the DirRequest control to "B&rowse" or any text you like? I just want it to look near identical to the MUI_PAGE_DIRECTORY page, and this is the only thing stopping me so far.

Many thanks in advance for anyone who replies.
shaunb is offline   Reply With Quote
Old 10th May 2006, 16:57   #2
shaunb
Member
 
Join Date: May 2006
Location: Devon, UK
Posts: 65
I just read something about this being possible in later versions of installoptions2, does this mean that functionality is included in the NSIS 2.16 release?
shaunb is offline   Reply With Quote
Old 10th May 2006, 17:21   #3
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Not that I am aware of.
You can try using InstallOptionsEx.

If all else fails, you'd need to change it with the System plugin by calling user32::SetWindowText and then resize the button control with user32::SetWindowPos.

May I ask why you need to create a custom dialog which is almost identical to the NSIS Directory page?

-Stu
Afrow UK is offline   Reply With Quote
Old 10th May 2006, 17:29   #4
shaunb
Member
 
Join Date: May 2006
Location: Devon, UK
Posts: 65
I want to ask the 'user' for the location of their ColdFusionMX install.

I did have it working using just another MUI_PAGE_DIRECTORY, but i honestly found it easier building my own dialog rather than removing the 'space required/space available' and the title and subtitle, also I found it added the directory in question to the end, probably as I didnt set a seperate variable for it to go out of.

apologies for my noobiness I've only been on the case since this week. NSIS is very powerful though and a great tool.

Hmm, seems a little tricky, it doesnt look so bad as "..." but it'd be nice if it matched the dialog following it.

I'll keep looking around, I take it InstallOptionsEX is a seperate external plugin to InstallOptions2, and doesnt come with NSIS?

Thanks for your help.
shaunb is offline   Reply With Quote
Old 10th May 2006, 17:47   #5
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
If I remember correctly, putting a \ on the end of the install dir path for the Directory pages stops the end dir name being appended to the end every time (or vise versa).

InstallOptionsEx is on the Wiki.

-Stu
Afrow UK is offline   Reply With Quote
Old 10th May 2006, 18:42   #6
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
It's your lucky day

I decided to have a 'break' from doing maths revision.
This example changes the browse button text to "Browse..." and resizes the button accordingly.

-Stu
Attached Files
File Type: zip dirbrowsetext.zip (1.4 KB, 610 views)
Afrow UK is offline   Reply With Quote
Old 10th May 2006, 19:16   #7
shaunb
Member
 
Join Date: May 2006
Location: Devon, UK
Posts: 65
I'll try it at work tomorrow, very kind of you.

thanks
shaunb is offline   Reply With Quote
Old 11th May 2006, 01:26   #8
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
Nice trick, Afrow!
Another option is to setup a custom page with a text box and a button. (Make the button say whatever you want.)

Then, using the DialogsEX plugin, make a folder browser appear when clicking on the button.

Sounds complicated, but it's really fairly simple. The page's exit function would look something like this:
code:

Function MyLeaveFunction
; This assumes that the text field is Field 5 and the browse button is Field 6
ReadIniStr '$PLUGINSDIR\mypage.ini' $0 'Settings' 'State'
StrCmp $0 6 DirBrowseButton Continue

DirBrowseButton:
; browse button was pressed:
; make sure you also write the value to the ini file in case you return to the page later during the install
${ModernFolderBox} "Browse for Key Disk" "Choose a location contianing a keydisk" "C:\" ${Var_1}
!insertmacro XPUI_INSTALLOPTIONS_WRITE "Page_InputcusNumber.ini" "Field 5" "State" "$1"
SendMessage $2 ${WM_SETTEXT} 0 "STR:$1"
abort

continue:
; [ the rest of your code goes here ]
FunctionEnd

Comperio is offline   Reply With Quote
Old 11th May 2006, 09:23   #9
shaunb
Member
 
Join Date: May 2006
Location: Devon, UK
Posts: 65
Seems to work fine! thanks a lot

I noticed the defines at the top of the code arent used so I cut it down a bit, I am just fiddling with the button width size multiplication so I can get it the same width, maybe eventually position, and maybe height as the browse button on the next page.

I just know people will look at it and moan although it looks fine to me, I will try using the example to change the other properties of the control. thanks!
shaunb is offline   Reply With Quote
Old 11th May 2006, 09:37   #10
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Yeh I put those defines in there and forgot to put them into the actual code

$R3 stores the height, but I'm sure you worked that out

-Stu
Afrow UK is offline   Reply With Quote
Old 11th May 2006, 09:53   #11
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Btw, if you're displaying a NSIS Directory page before your custom page, you could get the dimensions of the browse button from there instead.

-Stu
Afrow UK is offline   Reply With Quote
Old 11th May 2006, 10:42   #12
shaunb
Member
 
Join Date: May 2006
Location: Devon, UK
Posts: 65
Hmm, maybe its more sense to ask for the product install dir using a normal nsis directory page, then ask for the CF install location after. I can now change the height and size of the button but not its location hehe.

Anyway, I'm starting to try and fill in some logic for checking the users' input CF dir is valid, using the Locate plugin, but I'm not entirely sure how to block on the current page (obviously disable next button) and keep asking for a valid path, with a messagebox to prompt illegal paths.

I seem to have it producing a messagebox but not reverting to the same window, it just carries on to the next NSIS page.

I'll poke around and probably swap the page order as it looks better asking for the product dir before the CF dir.

Obviously the "product install" path doesnt need to exist, as the installer will create it, but the 'where is CF installed' box doesnt need to create directories etc, it just needs to unzip files to the correct locations in the CF dir. I'm just having a few issues blocking on a page, waiting for a 'decent' CF path from the dirrequest, and messagebox'ing the user if its not a decent path.

plus if I could change the button on my custom page like you said, to have the same dimensions as the Dirrequest button on the previous page, it would be great.

obviously I'm not asking anyone to hand me this on a plate, and most of this bumf is probably me clearing it in my own head, but at least you'll maybe understand what I'm getting at, hehe

Thanks again

Then I'll think about the dir checking again. ack!
shaunb is offline   Reply With Quote
Old 11th May 2006, 10:48   #13
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
I would consider using two Directory pages again. In normal InstallOptions the NOTIFY flag doesn't work well with DirRequest fields. You won't be able to validate the new path on key up, for example. You'd have to check the path in the pages' Leave function and then call Abort to go back to the page.

The NSIS Directory page already validates the entered directory path for you. It also removes any unwanted characters if you're dealing with the $INSTDIR variable when Pushing it to the stack.

-Stu
Afrow UK is offline   Reply With Quote
Old 11th May 2006, 10:56   #14
shaunb
Member
 
Join Date: May 2006
Location: Devon, UK
Posts: 65
ah, hmm. whimper

I did have it checking in the leave function before, I'm not against using another normal directory page again, but I've maybe just wasted a day creating this custom dialog, when I could have been removing parts from the default directory page.

hm, what you've said does point to using another directory page as the best method, if I can remove all the unimportant items from the said page. I'll take a look
shaunb is offline   Reply With Quote
Old 11th May 2006, 11:00   #15
shaunb
Member
 
Join Date: May 2006
Location: Devon, UK
Posts: 65
It seems the :

locate CFdir
if fail
messagebox "choose correct cf dir etc yeah"
abort
else
continue:


: actually looks alright, I thought it would produce a blank page with the messagebox on, then go back to the previous page, but this method actually looks 'ok', now if I could get the button to move away from the textbox a bit in the dirrequest control, and get it to move up a little so the bottom of the texbox and the bottom of the button are the same level, but not at the top, that would basically mean my custom page is finished and I wouldnt have to resort to using a normal NSIS directory page and removing the irrellevant details.

I'm good at rambling, thanks though
shaunb is offline   Reply With Quote
Old 11th May 2006, 12:04   #16
shaunb
Member
 
Join Date: May 2006
Location: Devon, UK
Posts: 65
Well thats the logic added

Only moving and resizing the button on the dirrequest control is an issue, but thats not really that important if it can't be moved it can't.

thanks anyone who helped, especially Afrow UK

(I'll probably make another topic regarding any other queries I have, after reading of course)
shaunb is offline   Reply With Quote
Old 11th May 2006, 14:11   #17
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
The button can be moved, but it would need quite a bit of extra code. GetClientRect returns 0 for the X and Y coordinates (bit pointless I know) because it works with the control itself rather than anything to do with the window that it sits in.

A better idea would be to make the DirRequest text box width smaller. This can be achieved with the same code, except you probably need to take about 10 units off, and the control ID will be one less than that of the button (e.g. 1201)

-Stu
Afrow UK 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