Page 1 of 1
Requiring at least one feature in componentstree?
Posted: Fri Mar 13, 2009 1:36 pm
by keith
Hello,
I would like to disable the "Next" button in the componentstree dialog if no features have been selected. I can't see how I can do that using the component properties available in the rule builder of the dialog editor.
Suggestions?
Keith
Posted: Sat Mar 14, 2009 5:51 am
by bokkie
Keith,
Until someone else can offer a better solution the best I've been able to achieve is this and that's to display a message box if neither of my test features (A and B) are selected:
Set Variable SELECTEDA to FALSE
Set Variable SELECTEDB to FALSE
label: Custom Setup
Display Dialog: componentstree (if variable PERSONALIZED is TRUE), wait for dialog to return (modal)
if Variable WIZARD Equals BACK
GoTo Label: Setup Type
else
if Variable WIZARD Equals CANCEL
GoTo Label: Main Install
end
end
Get Component FEATUREA Selection State into Variable SELECTEDA
Get Component FEATUREB Selection State into Variable SELECTEDB
if Variable SELECTEDA Equals FALSE
if Variable SELECTEDB Equals FALSE
MessageBox: , You must select feature A or B. Try again.
GoTo Label: Custom Setup
end
end
I've copied the MSIcode that works in my test project. The
italicised code is what I added around the existing componentstree dialog. Like you, I could not find a rule that could toggle the state of the Next button.
Perhaps my solution might get you out of jail until someone else possessing an abundance of scintillating perspicacity suggests a better and more practical answer.

Posted: Sat Mar 14, 2009 7:49 am
by MichaelNesmith
Easily done. Set a variable in script to whatever value you like, set a label on the form to "hidden" and set its caption property to dereference the value of this variable, and define a dialog rule based on that caption property.
Ex: Call your variable DISABLENEXT, set it to TRUE, add a label control in your dialog and call it IsDisabledNext, set its caption to $DISABLENEXT$, and then define a dialog rule If IsDisabledNext is TRUE then Next.Enabled is TRUE, etc...
Posted: Mon Mar 16, 2009 1:47 pm
by keith
[quote="MichaelNesmith"]Easily done. Set a variable in script to whatever value you like, set a label on the form to "hidden" and set its caption property to dereference the value of this variable, and define a dialog rule based on that caption property.
Ex: Call your variable [i]DISABLENEXT[/i], set it to [i]TRUE[/i], add a label control in your dialog and call it [i]IsDisabledNext[/i], set its caption to [b]$DISABLENEXT$[/b], and then define a dialog rule [b]If IsDisabledNext is TRUE then Next.Enabled is TRUE[/b], etc...[/quote]
Michael,
I think we are talking about different things. I understand how to pass external values into dialogs.
In the componentstree dialog, I would like to be able to add an object rule that says
IF (Components.HasSelection = TRUE) THEN Next.Enabled := TRUE
and vice versa.
Basically I want to be able to toggle the Enabled-ness of the Next button as the user changes if features are selected; much like the Next button is toggled when the user checks the "I accept..." checkbox in the license dialog. No features selected? Next is disabled. At least one selected? Next is enabled.
However, neither Components nor Components.Items seem to have the ability to tell me if they have anything selected while the dialog is still open. Of course I can check when the dialog is closed (Get Component State) but then it is too late.
It also appears that actual controls (Delphi right? TTreeView and TTreeNodes?) don't support anything like this, so I was wondering of you knew of any sneaky way to accomplish this.
Keith
Posted: Mon Mar 16, 2009 1:55 pm
by MichaelNesmith
No way, sorry...