Sandor
Posts: 6
Joined: Sun Apr 20, 2008 9:09 pm

Can .NET Custom Action set attributes of UI components?

Hi,

I would like to disable the "Cancel"-Button on the "ProcessDlg", but only for the duration of my .NET Custom Action.
Is it possible to set Attributes of UI components from the .NET Custom Action, or is there any other
possibility ?

Regards
sándor
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Can .NET Custom Action set attributes of UI components?

Hi,

During the actual installation process the "Cancel" button cannot be disabled. However, you can hide it by using a custom action:

Code: Select all

Function HideCancelButton()
  Dim Record
  Const msiMessageTypeCommonData = &H0B000000
  Set Record = Installer.CreateRecord(2)
  Record.IntegerData(1) = 2
  Record.IntegerData(2) = 0
  Session.Message msiMessageTypeCommonData, Record

  ' return success
  HideCancelButton = 1
  Exit Function
End Function
This VBScript code can be added as an Attached custom action right before your .NET custom action. Note that you need to set the "Function Name" field in the Custom Action Properties page to HideCancelButton.

If you want to show the "Cancel" button after the .NET custom action is executed you can use another VBScript custom action:

Code: Select all

Function ShowCancelButton()
  Dim Record
  Const msiMessageTypeCommonData = &H0B000000
  Set Record = Installer.CreateRecord(2)
  Record.IntegerData(1) = 2
  Record.IntegerData(2) = 1
  Session.Message msiMessageTypeCommonData, Record

  ' return success
  HideCancelButton = 1
  Exit Function
End Function
This code can be added as an Attached custom action right after your .NET custom action.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Sandor
Posts: 6
Joined: Sun Apr 20, 2008 9:09 pm

Re: Can .NET Custom Action set attributes of UI components?

Hi Cosmin,

thank you, it works fine.

However I've got another idea, by setting a new condition for the Cancel-Button:
in Edit Condition panel select Component State, then select your appropriate .NET Custom Action DLL.
Now if we could set the right condition for the state of that Custom Action,
then setting the action (Disable) for the Cancel button wouldn't be a big deal.

Could you please comment this idea ?

Thank you and best regards

sándor
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Can .NET Custom Action set attributes of UI components?

Hi,

An installation package is organized into components and features. These components contain all the resources in the package (files, registry entries, SQL scripts etc.).

Please note that the custom actions in your package are not contained by these components because they are not resources. Also, a Component State refers to the install state of a component (if the component is already installed or not), not to what a custom action is doing. The only solution for what you need to do is the one I explained.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”