您可以使用自定义操作来读取屏幕分辨率并动态填充图像控件,这样:
[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-order 将会被打乱。你需要做一些调整:
- 使用自定义操作创建所有控件;或者
- 更改
Control_Next
以使您的动态控制成为焦点循环的一部分(尽管未使用)并更新Control_First
Dialog 表以使用它。