Page 1 of 1

Preventing \"Next\" button flicker on Registration dialog

Posted: Thu Apr 02, 2009 8:27 pm
by DaveL
Not too long ago in another thread, I posted this:
DaveL wrote:We recently created an installer with a Registration dialog. I started with the registration dialog included with one of InstallAware's existing themes and added several more edit fields, all of which are required to be filled in before the "Next" button is enabled. We have observed that as text is typed into the edit fields, the "Next" button flickers enabled/disabled...
The response, confirming the issue, was:
CandiceJones wrote:The button can occasionally flicker based on the speed of the host system...
Now, for posterity, I present my solution below!

Okay, for background, the idea is that the "Next" button will be disabled unless all fields of a form contain some text. As of IA8, the default included themes accomplish this for the Registration (and RegistrationWithSerial) dialog by way of Object Rules (controlled via the InstallAware Dialog Designer) like the following:

Code: Select all

IF (Name.Text <> ) THEN Next.Enabled := True;
IF (Company.Text <> ) THEN Next.Enabled := True;
...
IF (Name.Text = ) THEN Next.Enabled := False;
IF (Company.Text = ) THEN Next.Enabled := False;
...
PROBLEM: Basically, after each one of those Rules is processed, the dialog control is going to be told whether or not it should be enabled and it will then redraw itself as necessary. When not all fields are filled in, we have the filled-in fields telling the "Next" button to draw as enabled, followed by the empty fields telling the button do draw as disabled--and this happens each time a field changes (e.g. after each key-press). Because of evil technical things like window message loops and video refresh rates, there is a high likelihood of visible flickering.

SOLUTION: Now, I can imagine ways of IA maybe being able to address this problem internally so that the user would never have to worry about it. However, happily, there is a workaround that is quite effective without having to appeal to the IA devs, heheh... An epiphany struck me one day and I decided to create a hidden label (i.e. having its "Visible" property set to "False") on the dialog and update the caption of the label to be "True" or "False" depending on whether or not the "Next" button should be enabled. This way I am not setting the button's state after checking each and every edit field, but can instead wait until the very end and just check the hidden label's caption to determine if the button should be enabled! This results in something like the following:

Code: Select all

IF (Name.Text <> ) THEN HiddenLabel.Caption := True;
IF (Company.Text <> ) THEN HiddenLabel.Caption := True;
...
IF (Name.Text = ) THEN HiddenLabel.Caption := False;
IF (Company.Text = ) THEN HiddenLabel.Caption := False;
...
IF (HiddenLabel.Caption <> False) THEN Next.Enabled := True;
IF (HiddenLabel.Caption = False) THEN Next.Enabled := False;
So, I hope this might be useful to someone somewhere/sometime, as having a flickering button in one's installer can potentially diminish the professional feel of a product. :wink:

--
DaveL