Archive: nsDialogs - (Probably) Newbie questions


nsDialogs - (Probably) Newbie questions
  Hello world,

I am trying my first steps with MUI2 custom pages using nsDialogs. I googled a lot and followed the introduction at http://nsis.sourceforge.net/Docs/nsDialogs/Readme.html, but I couln't find something about...

1.) How to make a radio button (or a checkbox) selected? I figured out that ${NSD_GetState} delivers 0/1 to query the selection, but there seems to be no ${NSD_SetState} to change it.

2.) How to change the text of a label? Like above, there is ${NSD_GetText}, but no ${NSD_SetText}.

3.) How do I group different sets of radio buttons on the same page? By default, all radio buttons I create belong to the same radio group.

4.) Just because I am curious: Is there a documentation of what the "magic number" 1018 means with nsDialogs::Create?

Jens


1. EnableWindow $CheckBox 1 ;or 0 to disable

2. SendMessage $Label ${WM_SETTEXT} 0 "STR:Label Text"

3. not sure, but i guess you have to control this by the OnClick function

4. not sure about the correct terminology, but 1018 is the part of the window, where to place the control (1028 would be the area of the brandingtext)

only a guess, but i take it there will be macros following the current syntax to replace EnableWindow and SendMessage in future versions


1. EnableWindow $CheckBox 1 ;or 0 to disable
Does not work. This ones makes a control enabled/disabled, but I try to make a radio button (or checkbox) selected/unselected. Or am I doing something wrong?
2. SendMessage $Label ${WM_SETTEXT} 0 "STR:Label Text"
Works great, thanks!

1) SendMessage $hControl ${BM_SETCHECK} ${BST_CHECKED} 0
3) The first button control of the next group of radio buttons must have the WS_GROUP style set.
4) 1018 is a hidden control on the parent dialog. I think its purpose is to provide a size and location for the child dialog that is created for the custom pages. 1044 is the full dialog.

I don't see any reason to get rid of EnableWindow or SendMessage, they are very useful and easy enough to understand.

Don


Originally posted by demiller9
I don't see any reason to get rid of EnableWindow or SendMessage, they are very useful and easy enough to understand.
only and best reason i can think of is continuity/consistency. i thought it's the reason why it's still undocumented.

Originally posted by demiller9
1) SendMessage $hControl ${BM_SETCHECK} ${BST_CHECKED} 0
Works. Thank you!
3) The first button control of the next group of radio buttons must have the WS_GROUP style set.
Another newbie question: How would I set this style? ${NSD_CreateRadioButton} does not seem to have a parameter for it.

I tried to create a working example of two radio button groups and it seems more difficult than my first reply makes it sound. The WS_GROUP style is not enough to separate the groups, and creating two groupboxes didn't work for me either.

I'll keep looking for this unless some other Windows experts chime in.

Don


Var Dialog

>Function c
nsDialogs::Create /NOUNLOAD 1018
Pop $Dialog
>${NSD_CreateRadioButton} 0 0 100% 12u "a"
>pop $0
System::Call 'user32::GetWindowLong(i r0,i -16)i.r1'
>IntOp $1 $1 | ${WS_GROUP}
>System::Call 'user32::SetWindowLong(i r0,i -16,i r1)'

>${NSD_CreateRadioButton} 0 20 100% 12u "b"
>pop $0


>${NSD_CreateRadioButton} 0 40 100% 12u "1"
>pop $0
System::Call 'user32::GetWindowLong(i r0,i -16)i.r1'
>IntOp $1 $1 | ${WS_GROUP}
>System::Call 'user32::SetWindowLong(i r0,i -16,i r1)'

>${NSD_CreateRadioButton} 0 60 100% 12u "2"
>pop $0

nsDialogs::Show
FunctionEnd

page custom c
>
edit:
even

System::Call 'user32::GetWindowLong(i r0,i -16)i.r1'

>System::Call 'user32::SetWindowLong(i r0,i -16,i $1|${WS_GROUP} )'
seems to work

Thank you Anders for your examples. You showed me what I didn't have in my own tests: the WS_GROUP bit must be set on all radio button groups' first buttons. (I had only put it on the first button of the second group).

Here's the way I would create two sets of radio buttons with the modification I made to nsDialogs.nsh:

Page custom Choices Choices.Leave

Function Choices
Var /GLOBAL Group1.Button1
Var /GLOBAL Group2.Button1

nsDialogs::Create /NOUNLOAD 1018
Pop $0

# Create controls and set defaults
${NSD_CreateGroupBox} 0u 0u 100% 45% "A set of options"
Pop $0

!define NSD_ADD_STYLE ${WS_GROUP}
${NSD_CreateRadioButton} 18u 16u 82u 11u "&Do it right"
Pop $Group1.Button1
SendMessage $Group1.Button1 ${BM_SETCHECK} ${BST_CHECKED} 0

${NSD_CreateRadioButton} 18u 32u 82u 11u "D&o it fast"
Pop $0

${NSD_CreateGroupBox} 0u 55% 100% 45% "Please choose"
Pop $0

!define NSD_ADD_STYLE ${WS_GROUP}
${NSD_CreateRadioButton} 18u 100u 82u 11u "&This or"
Pop $Group2.Button1

${NSD_CreateRadioButton} 18u 116u 82u 11u "T&hat"
Pop $0
SendMessage $0 ${BM_SETCHECK} ${BST_CHECKED} 0

# Show the page.
nsDialogs::Show
FunctionEnd

Function Choices.Leave
${NSD_GetState} $Group1.Button1 $Group1
${NSD_GetState} $Group2.Button1 $Group2
FunctionEnd

Don