Archive: How to check if components list is visible?


How to check if components list is visible?
Hi everybody,

I'm using the statement

InstType /COMPONENTSONLYONCUSTOM
in a setup script and I need to perform an action only if the components list is visible in the components page. Is there a way to test this with a function?

Thanks.
DD

You could check if the combo box contains the item with CB_FINDSTRINGEXACT:
http://msdn2.microsoft.com/en-us/library/ms673148.aspx

Stu


Thank you for your reply, but I still need some help to understand it (sorry): could you show me an example in which I can get a flag in a variable indicating whether components list is visible or not?
Thanks again.
DD


Using the available instructions that would be possible only when there is user's action by checking/uncheching components in custom installation, otherwise you'd need to go as Stu suggested.
Hence, this example partially working:

!include logiclib.nsh

outfile 'test.exe'

InstType Typical
InstType /COMPONENTSONLYONCUSTOM

page components
page instfiles

section 'section one' sec01
sectionin 1
sectionend

section 'section two' sec02
sectionin 1
sectionend

section 'section three' sec03
sectionin 1
sectionend

Function .onSelChange
GetCurInstType $R0
${If} $R0 == ${NSIS_MAX_INST_TYPES}
MessageBox MB_OK '$R0'
${EndIf}
FunctionEnd

Thank you very much. I tried this way first, but it's not a solution, because if the components list is displayed with the check boxes set in any standard section configuration I don't get the "32" value I need, but the section number instead. So unless the user alters some check box I can't know whether the components list is visible or not...
What I'd need is to query the list control through some message related to its visibility state, but I don't know such a message.
I'm sorry, I don't understand how to apply Stu's suggestion to my case. In which way checking for the presence of a string in the combo list can help me to determine whether components list is available?
Thanks again for any help.
DD


Following the million examples and according to that page :),

!include WinMessages.nsh
FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $R0 $R0 1017
SendMessage $R0 ${CB_FINDSTRINGEXACT} -1 "STR:Search for me case insensitively" $R0

At which point, $R0 is the index of the item or -1 otherwise.

Stu

Stu, it took me a little to understand what I had to do, but when I thought I could use WM_GETTEXT to retrieve the user's selection from the combo box, your suggestion became clearer.
The following code does the work perfectly. I hope it can be useful to post it here.
Thanks.
DD.


push $R2
push $R1
push $R0

/* ... */

FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $R0 $R0 1017
System::Call "User32::GetWindowText(i $R0, t .R1, i 256)"
SendMessage $R0 ${CB_FINDSTRINGEXACT} -1 "STR:$R1" $R1
SendMessage $R0 ${CB_GETCOUNT} 0 0 $R2
IntOp $R2 $R2 - 1
IntCmp $R1 $R2 +2
MessageBox MB_OK "Do whatever needed if this is not a custom install."
#end

/* ... */

pop $R0
pop $R1
pop $R2

Are you basically checking if the last item is selected then?
Why not just send CB_GETCURSEL and compare the value to CB_GETCOUNT-1?

Stu