问题
I'm trying to write a custom WiX dialog which, as part of its workflow, shows an error image in response to certain conditions. However, WiX appears to be ignoring my dimensions and displaying as it feels fit. Here's my code:
<Binary Id="WixUI_FailureImg" SourceFile="$(sys.SOURCEFILEDIR)..\Resources\Failure.ico" />
<Control Id="TestResult_Failure" Type="Icon" IconSize="16" X="15" Y="206" Width="16" Height="16" Text="WixUI_FailureImg">
<Condition Action="hide">LOGON_VALID = "1"</Condition>
<Condition Action="show">LOGON_VALID = "0"</Condition>
</Control>
I've included a snippet of the resulting dialog below, with the original image (a 16x16 .ico) in the background. As you can see, the image has been scaled upwards, and there is no transparency around the image. I've tried 8-bit and 24-bit bitmaps as well icons, but they all produce the same result. Is there something that I am doing obviously wrong?
UPDATE:
In case you were wondering how the dynamic images works, here's the relevant section:
<Control Id="TestResult_Success" Type="Icon" IconSize="16" X="15" Y="210" Width="12" Height="12" Text="WixUI_SuccessImg">
<Condition Action="hide">LOGON_VALID = "0"</Condition>
<Condition Action="show">LOGON_VALID = "1"</Condition>
</Control>
<Control Id="TestPrompt_Success" Type="Text" X="35" Y="210" Width="322" Height="10" Text="!(loc.SqlSelectDlgConnectionValid)">
<Condition Action="hide">LOGON_VALID = "0"</Condition>
<Condition Action="show">LOGON_VALID = "1"</Condition>
</Control>
<Control Id="TestResult_Failure" Type="Icon" IconSize="16" X="15" Y="210" Width="12" Height="12" Text="WixUI_FailureImg">
<Condition Action="hide">LOGON_VALID = "1"</Condition>
<Condition Action="show">LOGON_VALID = "0"</Condition>
</Control>
<Control Id="TestPrompt_Failure" Type="Text" X="35" Y="210" Width="322" Height="10" Text="!(loc.SqlSelectDlgConnectionInvalid)">
<Condition Action="hide">LOGON_VALID = "1"</Condition>
<Condition Action="show">LOGON_VALID = "0"</Condition>
</Control>
As you can guess from the screenshot, the page is related to establishing a SQL connection; I have a custom action that creates a connection string based on the user's input, and attempts to validate it. If it's valid (LOGON_VALID = "1"
), I get a tick image and some text to say everything is good, otherwise I get a warning icon and some text to warn the user. Of course, the Next button is also controlled by this value.
回答1:
X, Y, Width, and Height are in "installer units," not pixels. Converting installer units to pixels depends on the visual theme, font size, and DPI settings. Your best bet is to make it look good on default settings.
来源:https://stackoverflow.com/questions/8351801/wix-not-rendering-images-correctly