使用WiX时,我可以阻止缩放图像以适合我的显示设置吗?

时间:2013-10-11 13:21:33

标签: wix wix3.7

我遇到与this question中讨论的问题类似的问题。

我已经按照上面链接(493px x 58px)中建议的尺寸创建了一个自定义WiXUIBannerBmp图像,但它看起来很糟糕,因为它仍在缩放。屏幕上的实际尺寸似乎约为616像素x 73像素。 616 = 493 * 1.25和73 = 58 * 1.25(约)。你猜怎么着?在我的显示设置中,我将屏幕缩放了125%。

有人知道如何处理这个问题吗?我可以,例如:

  • 检测分辨率比例并为不同比例提供不同的文件?
  • 在我的图片上设置“不缩放”标志?
  • 提供可靠缩放的图像格式,即不是bmp或jpg?
  • 还有其他想法吗?

非常感谢

更新

我发现此问题的唯一参考是this post on SourceForge,但我找不到Rob在回复中提到的错误。有人知道是否有人被提出并且是否被采取了行动?

1 个答案:

答案 0 :(得分:0)

您可以使用自定义操作来读取屏幕分辨率并以这种方式动态填充图像控件:

[CustomAction]
public static ActionResult GenInstallationReview(Session session)
{
    // Insert Control Bitmap in Control table (MSI database).
    Record record = session.Database.CreateRecord(12);
    record.SetString(1, "Dialog_Review"); // Dialog_
    record.SetString(2, "Bitmap_Background"); // Control
    record.SetString(3, "Bitmap"); // Type
    record.SetInteger(4, 0); // X
    record.SetInteger(5, 0); // Y
    record.SetInteger(6, 518); // Width
    record.SetInteger(7, 392); // Height
    record.SetInteger(8, 1); // Attributes
    record.SetString(9, ""); // Property
    record.SetString(10, "Binary_Background"); // Text
    record.SetString(11, ""); // Control_Next
    record.SetString(12, ""); // Help

    // Queries the Control table to check if the control was already created.
    List<string> resultList = new List<string>();
    resultList = (List<string>)session.Database.ExecuteStringQuery(
      "SELECT `Control` FROM `Control` WHERE `Control` = 'Bitmap_Background'");

    // Insert or update the table based on if the control was already created.
    if (resultList.Count < 1)
        session.Database.Execute(
          "INSERT INTO `Control` (`Dialog_`, `Control`, `Type`, `X`, `Y`, " +
          "`Width`, `Height`, `Attributes`, `Property`, `Text`, " + 
          "`Control_Next`, `Help`) " + 
          "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) TEMPORARY", record);
    else
        session.Database.Execute(
          "UPDATE `Control` SET `Dialog_`=?, `Control`=?, `Type`=?, `X`=?, " +
          "`Y`=?, `Width`=?, `Height`=?, `Attributes`=?, `Property`=?, " +
          "`Text`=?, `Control_Next`=?, `Help`=? WHERE " +
          "`Control`='Bitmap_Background'", record);

    return ActionResult.Success;
}

这里有一个警告,如果图像填充对话框(例如背景图像),z顺序将被搞砸。您需要做出一些调整:

  • 使用自定义操作创建所有控件;或
  • 更改Control_Next以使动态控制成为焦点循环的一部分(尽管未使用),并更新对话表中的Control_First以使用它。